// This file is automatically generated.  Do not edit
#include "sah_config.h"

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>

#include "parse.h"
#include "xml_util.h"
#include "db_table.h"
#include "ap_schema.h"

#ifdef _WIN32
#pragma warning( disable : 4355 )
#endif

#define found(x) ((x != std::string::npos))

const char *db_name="ap_db";
int db_is_open;

template <> const char * const db_type<coordinate_t>::type_name="coordinate_t";
template <> const char * db_type<coordinate_t>::_search_tag=type_name;
template <> const int db_type<coordinate_t>::_nfields=3;
template <> const char * const db_type<coordinate_t>::column_names[3]={"time","ra","dec"};

coordinate_t::coordinate_t() : 
	db_type<coordinate_t>(*this),
	time(0),
	ra(0),
	dec(0)
{
	db_open();
}


coordinate_t::coordinate_t(const coordinate_t &a) : 
	db_type<coordinate_t>(*this),
	time(a.time),
	ra(a.ra),
	dec(a.dec)
{
	db_open();
}


coordinate_t::coordinate_t(const SQL_ROW &a) : 
	db_type<coordinate_t>(*this)
{
	db_open();
	parse(a);
}


coordinate_t::coordinate_t(const std::string &s,const char *tag) : 
	db_type<coordinate_t>(*this)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


coordinate_t &coordinate_t::operator =(const coordinate_t &a) {
	if (&a != this) {
		time=a.time;
		ra=a.ra;
		dec=a.dec;
	}
	return (*this);
}


std::string coordinate_t::update_format() const
{	std::ostringstream rv("");

	rv << "ROW(";
	for (int i=1;i<3;i++) rv << "?,";
	rv << "?";
rv << ")";

	return rv.str();
}


std::string coordinate_t::insert_format() const
{	return update_format();
}

std::string coordinate_t::select_format() const
{
std::string rv("");
for (int i=0; i<2;i++) rv+="?,";
rv+="?";
return rv;
}

std::string coordinate_t::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	rv << "ROW(";
	rv << time;
	rv << ',';
	rv << ra;
	rv << ',';
	rv << dec;
	rv << ")";
	return rv.str();
}


std::string coordinate_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	rv << xml_indent() << "<time>" << time << "</time>\n";
	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
	rv << xml_indent() << "<dec>" << dec << "</dec>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void coordinate_t::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> time;
	      }
	    if (extract_xml_record(field,"ra",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> ra;
	      }
	    if (extract_xml_record(field,"dec",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dec;
	      }
	      }
	      }

	void coordinate_t::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> time;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> ra;
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> dec;
	    }
	      }

	void coordinate_t::parse(const std::string &s) {
	      SQL_ROW row(&s,3);
	      parse(row);
	      }

template <> const char * const db_type<threshold_t>::type_name="threshold_t";
template <> const char * db_type<threshold_t>::_search_tag=type_name;
template <> const int db_type<threshold_t>::_nfields=2;
template <> const char * const db_type<threshold_t>::column_names[2]={"coadds","threshold"};

threshold_t::threshold_t() : 
	db_type<threshold_t>(*this),
	coadds(0),
	threshold(0)
{
	db_open();
}


threshold_t::threshold_t(const threshold_t &a) : 
	db_type<threshold_t>(*this),
	coadds(a.coadds),
	threshold(a.threshold)
{
	db_open();
}


threshold_t::threshold_t(const SQL_ROW &a) : 
	db_type<threshold_t>(*this)
{
	db_open();
	parse(a);
}


threshold_t::threshold_t(const std::string &s,const char *tag) : 
	db_type<threshold_t>(*this)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


threshold_t &threshold_t::operator =(const threshold_t &a) {
	if (&a != this) {
		coadds=a.coadds;
		threshold=a.threshold;
	}
	return (*this);
}


std::string threshold_t::update_format() const
{	std::ostringstream rv("");

	rv << "ROW(";
	for (int i=1;i<2;i++) rv << "?,";
	rv << "?";
rv << ")";

	return rv.str();
}


std::string threshold_t::insert_format() const
{	return update_format();
}

std::string threshold_t::select_format() const
{
std::string rv("");
for (int i=0; i<1;i++) rv+="?,";
rv+="?";
return rv;
}

std::string threshold_t::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	rv << "ROW(";
	rv << coadds;
	rv << ',';
	rv << threshold;
	rv << ")";
	return rv.str();
}


std::string threshold_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	rv << xml_indent() << "<coadds>" << coadds << "</coadds>\n";
	rv << xml_indent() << "<threshold>" << threshold << "</threshold>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void threshold_t::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"coadds",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> coadds;
	      }
	    if (extract_xml_record(field,"threshold",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> threshold;
	      }
	      }
	      }

	void threshold_t::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> coadds;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> threshold;
	    }
	      }

	void threshold_t::parse(const std::string &s) {
	      SQL_ROW row(&s,2);
	      parse(row);
	      }

template <> const char * const db_type<data_description_t>::type_name="data_description_t";
template <> const char * db_type<data_description_t>::_search_tag=type_name;
template <> const int db_type<data_description_t>::_nfields=4;
template <> const char * const db_type<data_description_t>::column_names[4]={"start","end","block_num","nsamples"};

data_description_t::data_description_t() : 
	db_type<data_description_t>(*this),
	start(),
	end(),
	block_num(0),
	nsamples(0)
{
	db_open();
}


data_description_t::data_description_t(const data_description_t &a) : 
	db_type<data_description_t>(*this),
	start(a.start),
	end(a.end),
	block_num(a.block_num),
	nsamples(a.nsamples)
{
	db_open();
}


data_description_t::data_description_t(const SQL_ROW &a) : 
	db_type<data_description_t>(*this)
{
	db_open();
	parse(a);
}


data_description_t::data_description_t(const std::string &s,const char *tag) : 
	db_type<data_description_t>(*this)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


data_description_t &data_description_t::operator =(const data_description_t &a) {
	if (&a != this) {
		start=a.start;
		end=a.end;
		block_num=a.block_num;
		nsamples=a.nsamples;
	}
	return (*this);
}


std::string data_description_t::update_format() const
{	std::ostringstream rv("");

	rv << "ROW(";
	for (int i=1;i<4;i++) rv << "?,";
	rv << "?";
rv << ")";

	return rv.str();
}


std::string data_description_t::insert_format() const
{	return update_format();
}

std::string data_description_t::select_format() const
{
std::string rv("");
for (int i=0; i<3;i++) rv+="?,";
rv+="?";
return rv;
}

std::string data_description_t::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	rv << "ROW(";
	rv << start.print(full_subtables,show_ids,no_refs);
	rv << ',';
	rv << end.print(full_subtables,show_ids,no_refs);
	rv << ',';
	rv << block_num;
	rv << ',';
	rv << nsamples;
	rv << ")";
	return rv.str();
}


std::string data_description_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	rv << start.print_xml(full_subtables,show_ids,no_refs,"start");
	rv << end.print_xml(full_subtables,show_ids,no_refs,"end");
	rv << xml_indent() << "<block_num>" << block_num << "</block_num>\n";
	rv << xml_indent() << "<nsamples>" << nsamples << "</nsamples>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void data_description_t::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"start",sub)) {
	      start.parse_xml(sub,"start");
	    }
	    if (extract_xml_record(field,"end",sub)) {
	      end.parse_xml(sub,"end");
	    }
	    if (extract_xml_record(field,"block_num",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> block_num;
	      }
	    if (extract_xml_record(field,"nsamples",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> nsamples;
	      }
	      }
	      }

	void data_description_t::parse(const SQL_ROW &s) {
	  {  
	  start.parse(SQL_ROW(s[0],0));
	    }
	  {  
	  end.parse(SQL_ROW(s[1],0));
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> block_num;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> nsamples;
	    }
	      }

	void data_description_t::parse(const std::string &s) {
	      SQL_ROW row(&s,4);
	      parse(row);
	      }

template <> const char * const db_table<tape>::table_name="tape";
template <> const char * db_table<tape>::_search_tag=table_name;
template <> const int db_table<tape>::_nfields=8;
template <> const char * const db_table<tape>::column_names[8]={"id","name","start_time","last_block_time","last_block_done","wu_count","beam","polarization"};

tape::tape() : 
	db_table<tape>(*this,-1),
	id(0),
	start_time(0),
	last_block_time(0),
	last_block_done(0),
	wu_count(0),
	beam(0),
	polarization(0)
{
	db_open();
	name[0]=0;
}


tape::tape(const tape &a) : 
	db_table<tape>(*this,-1),
	id(a.id),
	start_time(a.start_time),
	last_block_time(a.last_block_time),
	last_block_done(a.last_block_done),
	wu_count(a.wu_count),
	beam(a.beam),
	polarization(a.polarization)
{
	db_open();
	strcpy(name,a.name);
}


tape::tape(const SQL_ROW &a) : 
	db_table<tape>(*this,-1)
{
	db_open();
	parse(a);
}


tape::tape(const std::string &s,const char *tag) : 
	db_table<tape>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


tape &tape::operator =(const tape &a) {
	if (&a != this) {
		id=a.id;
		start_time=a.start_time;
		last_block_time=a.last_block_time;
		last_block_done=a.last_block_done;
		wu_count=a.wu_count;
		beam=a.beam;
		polarization=a.polarization;
	strcpy(name,a.name);
	}
	return (*this);
}


std::string tape::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<8;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string tape::insert_format() const
{	return std::string("?,")+update_format();
}

std::string tape::select_format() const
{
std::string rv("");
for (int i=0; i<7;i++) rv+="?,";
rv+="?";
return rv;
}

std::string tape::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << "'" << name << "'";
	rv << ',';
	rv << start_time;
	rv << ',';
	rv << last_block_time;
	rv << ',';
	rv << last_block_done;
	rv << ',';
	rv << wu_count;
	rv << ',';
	rv << beam;
	rv << ',';
	rv << polarization;
	return rv.str();
}


std::string tape::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	{
	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
	  rv << xml_indent() << "<name>";
	  rv << enc_field << "</name>\n";
	}
	rv << xml_indent() << "<start_time>" << start_time << "</start_time>\n";
	rv << xml_indent() << "<last_block_time>" << last_block_time << "</last_block_time>\n";
	rv << xml_indent() << "<last_block_done>" << last_block_done << "</last_block_done>\n";
	rv << xml_indent() << "<wu_count>" << wu_count << "</wu_count>\n";
	rv << xml_indent() << "<beam>" << beam << "</beam>\n";
	rv << xml_indent() << "<polarization>" << polarization << "</polarization>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void tape::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"name",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::string::size_type epos=sub.find("<",pos);
	        if (epos==std::string::npos) epos=sub.find('\n',pos);
	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)20));
	        name[std::min(in.size(),(size_t)19)]=0;
	      }
	    if (extract_xml_record(field,"start_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> start_time;
	      }
	    if (extract_xml_record(field,"last_block_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> last_block_time;
	      }
	    if (extract_xml_record(field,"last_block_done",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> last_block_done;
	      }
	    if (extract_xml_record(field,"wu_count",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> wu_count;
	      }
	    if (extract_xml_record(field,"beam",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> beam;
	      }
	    if (extract_xml_record(field,"polarization",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> polarization;
	      }
	      }
	      }

	void tape::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        strncpy(name,s[1]->c_str(),20);
	        name[19]=0;
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> start_time;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> last_block_time;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> last_block_done;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> wu_count;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> beam;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> polarization;
	    }
	      }

	void tape::parse(const std::string &s) {
	      SQL_ROW row(&s,8);
	      parse(row);
	      }

template <> const char * const db_table<analysis_config>::table_name="analysis_config";
template <> const char * db_table<analysis_config>::_search_tag=table_name;
template <> const int db_table<analysis_config>::_nfields=12;
template <> const char * const db_table<analysis_config>::column_names[12]={"id","dm_low","dm_high","dm_chunk_small","dm_chunk_large","fold_buf_bytes_short","max_coadd","fft_len","remove_radar","high_pass","ffa_threshold","thresholds"};

analysis_config::analysis_config() : 
	db_table<analysis_config>(*this,-1),
	id(0),
	dm_low(0),
	dm_high(0),
	dm_chunk_small(0),
	dm_chunk_large(0),
	fold_buf_bytes_short(0),
	max_coadd(0),
	fft_len(0),
	remove_radar(0),
	high_pass(0),
	ffa_threshold(0),
	thresholds((threshold_t *)0,0,_x_xml_values)
{
	db_open();
}


analysis_config::analysis_config(const analysis_config &a) : 
	db_table<analysis_config>(*this,-1),
	id(a.id),
	dm_low(a.dm_low),
	dm_high(a.dm_high),
	dm_chunk_small(a.dm_chunk_small),
	dm_chunk_large(a.dm_chunk_large),
	fold_buf_bytes_short(a.fold_buf_bytes_short),
	max_coadd(a.max_coadd),
	fft_len(a.fft_len),
	remove_radar(a.remove_radar),
	high_pass(a.high_pass),
	ffa_threshold(a.ffa_threshold),
	thresholds(a.thresholds)
{
	db_open();
}


analysis_config::analysis_config(const SQL_ROW &a) : 
	db_table<analysis_config>(*this,-1)
{
	db_open();
	parse(a);
}


analysis_config::analysis_config(const std::string &s,const char *tag) : 
	db_table<analysis_config>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


analysis_config &analysis_config::operator =(const analysis_config &a) {
	if (&a != this) {
		id=a.id;
		dm_low=a.dm_low;
		dm_high=a.dm_high;
		dm_chunk_small=a.dm_chunk_small;
		dm_chunk_large=a.dm_chunk_large;
		fold_buf_bytes_short=a.fold_buf_bytes_short;
		max_coadd=a.max_coadd;
		fft_len=a.fft_len;
		remove_radar=a.remove_radar;
		high_pass=a.high_pass;
		ffa_threshold=a.ffa_threshold;
		{
		  thresholds.clear();
		  std::vector<threshold_t>::const_iterator i(a.thresholds.begin());
		  for (;i!=a.thresholds.end();i++) {
		    thresholds.push_back(*i); 
		  }
		}
	}
	return (*this);
}


std::string analysis_config::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<12;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string analysis_config::insert_format() const
{	return std::string("?,")+update_format();
}

std::string analysis_config::select_format() const
{
std::string rv("");
for (int i=0; i<11;i++) rv+="?,";
rv+="?";
return rv;
}

std::string analysis_config::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << dm_low;
	rv << ',';
	rv << dm_high;
	rv << ',';
	rv << dm_chunk_small;
	rv << ',';
	rv << dm_chunk_large;
	rv << ',';
	rv << fold_buf_bytes_short;
	rv << ',';
	rv << max_coadd;
	rv << ',';
	rv << fft_len;
	rv << ',';
	rv << remove_radar;
	rv << ',';
	rv << high_pass;
	rv << ',';
	rv << ffa_threshold;
	rv << ',';
	rv << "LIST {";
	{
	std::vector<threshold_t>::const_iterator p=thresholds.begin();
	for (;p<thresholds.end();p++) {
	  rv << p->print();
	  if (p != thresholds.end()-1) {
	    rv << ',';
	  } else {
	    rv << "}";
	  }
	}
	}
	return rv.str();
}


std::string analysis_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	rv << xml_indent() << "<dm_low>" << dm_low << "</dm_low>\n";
	rv << xml_indent() << "<dm_high>" << dm_high << "</dm_high>\n";
	rv << xml_indent() << "<dm_chunk_small>" << dm_chunk_small << "</dm_chunk_small>\n";
	rv << xml_indent() << "<dm_chunk_large>" << dm_chunk_large << "</dm_chunk_large>\n";
	rv << xml_indent() << "<fold_buf_bytes_short>" << fold_buf_bytes_short << "</fold_buf_bytes_short>\n";
	rv << xml_indent() << "<max_coadd>" << max_coadd << "</max_coadd>\n";
	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
	rv << xml_indent() << "<remove_radar>" << remove_radar << "</remove_radar>\n";
	rv << xml_indent() << "<high_pass>" << high_pass << "</high_pass>\n";
	rv << xml_indent() << "<ffa_threshold>" << ffa_threshold << "</ffa_threshold>\n";
	if (thresholds.size()) {
	  rv << xml_indent() << "<thresholds";
	  {
	    std::string enc_string=thresholds.print_xml();
	    rv << ">\n" ;
	    rv << enc_string;
	  }
}
	rv << xml_indent(-2);
	rv << "</thresholds>\n"; 
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void analysis_config::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"dm_low",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dm_low;
	      }
	    if (extract_xml_record(field,"dm_high",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dm_high;
	      }
	    if (extract_xml_record(field,"dm_chunk_small",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dm_chunk_small;
	      }
	    if (extract_xml_record(field,"dm_chunk_large",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dm_chunk_large;
	      }
	    if (extract_xml_record(field,"fold_buf_bytes_short",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> fold_buf_bytes_short;
	      }
	    if (extract_xml_record(field,"max_coadd",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> max_coadd;
	      }
	    if (extract_xml_record(field,"fft_len",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> fft_len;
	      }
	    if (extract_xml_record(field,"remove_radar",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> remove_radar;
	      }
	    if (extract_xml_record(field,"high_pass",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> high_pass;
	      }
	    if (extract_xml_record(field,"ffa_threshold",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> ffa_threshold;
	      }
	    thresholds.clear();
	    if (extract_xml_record(field,"thresholds",sub)) {
	      pos=0;
	      while ((pos=sub.find("<threshold_t",pos)) != std::string::npos) { 
	        thresholds.push_back(threshold_t(std::string(sub.c_str()+pos))); 
	         pos=sub.find("</threshold_t",pos);
	      pos=sub.find(">",pos);
	      }
	    }
	      }
	      }

	void analysis_config::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> dm_low;
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> dm_high;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> dm_chunk_small;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> dm_chunk_large;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> fold_buf_bytes_short;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> max_coadd;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> fft_len;
	    }
	  {  
	        std::istringstream row(*(s[8]));
	        row >> remove_radar;
	    }
	  {  
	        std::istringstream row(*(s[9]));
	        row >> high_pass;
	    }
	  {  
	        std::istringstream row(*(s[10]));
	        row >> ffa_threshold;
	    }
	  {  
	  std::string::size_type p,q;
	  int i;
	    thresholds.clear();
	      SQL_ROW tmp(s[11]); 
	      for (i=0;i<tmp.argc();i++) {
	 thresholds.push_back(threshold_t(SQL_ROW(tmp[i])));
	      }
	    }
	      }

	void analysis_config::parse(const std::string &s) {
	      SQL_ROW row(&s,12);
	      parse(row);
	      }

template <> const char * const db_table<recorder_config>::table_name="recorder_config";
template <> const char * db_table<recorder_config>::_search_tag=table_name;
template <> const int db_table<recorder_config>::_nfields=6;
template <> const char * const db_table<recorder_config>::column_names[6]={"id","name","bits_per_sample","sample_rate","beams","version"};

recorder_config::recorder_config() : 
	db_table<recorder_config>(*this,-1),
	id(0),
	bits_per_sample(0),
	sample_rate(0),
	beams(0),
	version(0)
{
	db_open();
	name[0]=0;
}


recorder_config::recorder_config(const recorder_config &a) : 
	db_table<recorder_config>(*this,-1),
	id(a.id),
	bits_per_sample(a.bits_per_sample),
	sample_rate(a.sample_rate),
	beams(a.beams),
	version(a.version)
{
	db_open();
	strcpy(name,a.name);
}


recorder_config::recorder_config(const SQL_ROW &a) : 
	db_table<recorder_config>(*this,-1)
{
	db_open();
	parse(a);
}


recorder_config::recorder_config(const std::string &s,const char *tag) : 
	db_table<recorder_config>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


recorder_config &recorder_config::operator =(const recorder_config &a) {
	if (&a != this) {
		id=a.id;
		bits_per_sample=a.bits_per_sample;
		sample_rate=a.sample_rate;
		beams=a.beams;
		version=a.version;
	strcpy(name,a.name);
	}
	return (*this);
}


std::string recorder_config::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<6;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string recorder_config::insert_format() const
{	return std::string("?,")+update_format();
}

std::string recorder_config::select_format() const
{
std::string rv("");
for (int i=0; i<5;i++) rv+="?,";
rv+="?";
return rv;
}

std::string recorder_config::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << "'" << name << "'";
	rv << ',';
	rv << bits_per_sample;
	rv << ',';
	rv << sample_rate;
	rv << ',';
	rv << beams;
	rv << ',';
	rv << version;
	return rv.str();
}


std::string recorder_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	{
	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
	  rv << xml_indent() << "<name>";
	  rv << enc_field << "</name>\n";
	}
	rv << xml_indent() << "<bits_per_sample>" << bits_per_sample << "</bits_per_sample>\n";
	rv << xml_indent() << "<sample_rate>" << sample_rate << "</sample_rate>\n";
	rv << xml_indent() << "<beams>" << beams << "</beams>\n";
	rv << xml_indent() << "<version>" << version << "</version>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void recorder_config::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"name",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::string::size_type epos=sub.find("<",pos);
	        if (epos==std::string::npos) epos=sub.find('\n',pos);
	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
	        name[std::min(in.size(),(size_t)63)]=0;
	      }
	    if (extract_xml_record(field,"bits_per_sample",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> bits_per_sample;
	      }
	    if (extract_xml_record(field,"sample_rate",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> sample_rate;
	      }
	    if (extract_xml_record(field,"beams",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> beams;
	      }
	    if (extract_xml_record(field,"version",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> version;
	      }
	      }
	      }

	void recorder_config::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        strncpy(name,s[1]->c_str(),64);
	        name[63]=0;
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> bits_per_sample;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> sample_rate;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> beams;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> version;
	    }
	      }

	void recorder_config::parse(const std::string &s) {
	      SQL_ROW row(&s,6);
	      parse(row);
	      }

template <> const char * const db_table<receiver_config>::table_name="receiver_config";
template <> const char * db_table<receiver_config>::_search_tag=table_name;
template <> const int db_table<receiver_config>::_nfields=15;
template <> const char * const db_table<receiver_config>::column_names[15]={"id","s4_id","name","beam_width","center_freq","latitude","longitude","elevation","diameter","az_orientation","az_corr_coeff","zen_corr_coeff","array_az_ellipse","array_za_ellipse","array_angle"};

receiver_config::receiver_config() : 
	db_table<receiver_config>(*this,-1),
	id(0),
	s4_id(0),
	beam_width(0),
	center_freq(0),
	latitude(0),
	longitude(0),
	elevation(0),
	diameter(0),
	az_orientation(0),
	az_corr_coeff((float *)0,0,_x_csv),
	zen_corr_coeff((float *)0,0,_x_csv),
	array_az_ellipse(0),
	array_za_ellipse(0),
	array_angle(0)
{
	db_open();
	name[0]=0;
}


receiver_config::receiver_config(const receiver_config &a) : 
	db_table<receiver_config>(*this,-1),
	id(a.id),
	s4_id(a.s4_id),
	beam_width(a.beam_width),
	center_freq(a.center_freq),
	latitude(a.latitude),
	longitude(a.longitude),
	elevation(a.elevation),
	diameter(a.diameter),
	az_orientation(a.az_orientation),
	az_corr_coeff(a.az_corr_coeff),
	zen_corr_coeff(a.zen_corr_coeff),
	array_az_ellipse(a.array_az_ellipse),
	array_za_ellipse(a.array_za_ellipse),
	array_angle(a.array_angle)
{
	db_open();
	strcpy(name,a.name);
}


receiver_config::receiver_config(const SQL_ROW &a) : 
	db_table<receiver_config>(*this,-1)
{
	db_open();
	parse(a);
}


receiver_config::receiver_config(const std::string &s,const char *tag) : 
	db_table<receiver_config>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


receiver_config &receiver_config::operator =(const receiver_config &a) {
	if (&a != this) {
		id=a.id;
		s4_id=a.s4_id;
		beam_width=a.beam_width;
		center_freq=a.center_freq;
		latitude=a.latitude;
		longitude=a.longitude;
		elevation=a.elevation;
		diameter=a.diameter;
		az_orientation=a.az_orientation;
		{
		  az_corr_coeff.clear();
		  std::vector<float>::const_iterator i(a.az_corr_coeff.begin());
		  for (;i!=a.az_corr_coeff.end();i++) {
		    az_corr_coeff.push_back(*i); 
		  }
		}
		{
		  zen_corr_coeff.clear();
		  std::vector<float>::const_iterator i(a.zen_corr_coeff.begin());
		  for (;i!=a.zen_corr_coeff.end();i++) {
		    zen_corr_coeff.push_back(*i); 
		  }
		}
		array_az_ellipse=a.array_az_ellipse;
		array_za_ellipse=a.array_za_ellipse;
		array_angle=a.array_angle;
	strcpy(name,a.name);
	}
	return (*this);
}


std::string receiver_config::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<15;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string receiver_config::insert_format() const
{	return std::string("?,")+update_format();
}

std::string receiver_config::select_format() const
{
std::string rv("");
for (int i=0; i<14;i++) rv+="?,";
rv+="?";
return rv;
}

std::string receiver_config::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << s4_id;
	rv << ',';
	rv << "'" << name << "'";
	rv << ',';
	rv << beam_width;
	rv << ',';
	rv << center_freq;
	rv << ',';
	rv << latitude;
	rv << ',';
	rv << longitude;
	rv << ',';
	rv << elevation;
	rv << ',';
	rv << diameter;
	rv << ',';
	rv << az_orientation;
	rv << ',';
	rv << "LIST {";
	{
	std::vector<float>::const_iterator p=az_corr_coeff.begin();
	for (;p<az_corr_coeff.end();p++) {
	  rv << *p;
	  if (p != az_corr_coeff.end()-1) {
	    rv << ',';
	  } else {
	    rv << "}";
	  }
	}
	}
	rv << ',';
	rv << "LIST {";
	{
	std::vector<float>::const_iterator p=zen_corr_coeff.begin();
	for (;p<zen_corr_coeff.end();p++) {
	  rv << *p;
	  if (p != zen_corr_coeff.end()-1) {
	    rv << ',';
	  } else {
	    rv << "}";
	  }
	}
	}
	rv << ',';
	rv << array_az_ellipse;
	rv << ',';
	rv << array_za_ellipse;
	rv << ',';
	rv << array_angle;
	return rv.str();
}


std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	rv << xml_indent() << "<s4_id>" << s4_id << "</s4_id>\n";
	{
	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
	  rv << xml_indent() << "<name>";
	  rv << enc_field << "</name>\n";
	}
	rv << xml_indent() << "<beam_width>" << beam_width << "</beam_width>\n";
	rv << xml_indent() << "<center_freq>" << center_freq << "</center_freq>\n";
	rv << xml_indent() << "<latitude>" << latitude << "</latitude>\n";
	rv << xml_indent() << "<longitude>" << longitude << "</longitude>\n";
	rv << xml_indent() << "<elevation>" << elevation << "</elevation>\n";
	rv << xml_indent() << "<diameter>" << diameter << "</diameter>\n";
	rv << xml_indent() << "<az_orientation>" << az_orientation << "</az_orientation>\n";
	if (az_corr_coeff.size()) {
	  rv << xml_indent() << "<az_corr_coeff";
	  {
	    std::string enc_string=az_corr_coeff.print_xml();
	    rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[az_corr_coeff.encoding] << "\">" ;
	    rv << enc_string;
	  }
}
	rv << "</az_corr_coeff>\n"; 
	if (zen_corr_coeff.size()) {
	  rv << xml_indent() << "<zen_corr_coeff";
	  {
	    std::string enc_string=zen_corr_coeff.print_xml();
	    rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[zen_corr_coeff.encoding] << "\">" ;
	    rv << enc_string;
	  }
}
	rv << "</zen_corr_coeff>\n"; 
	rv << xml_indent() << "<array_az_ellipse>" << array_az_ellipse << "</array_az_ellipse>\n";
	rv << xml_indent() << "<array_za_ellipse>" << array_za_ellipse << "</array_za_ellipse>\n";
	rv << xml_indent() << "<array_angle>" << array_angle << "</array_angle>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void receiver_config::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"s4_id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> s4_id;
	      }
	    if (extract_xml_record(field,"name",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::string::size_type epos=sub.find("<",pos);
	        if (epos==std::string::npos) epos=sub.find('\n',pos);
	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
	        name[std::min(in.size(),(size_t)254)]=0;
	      }
	    if (extract_xml_record(field,"beam_width",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> beam_width;
	      }
	    if (extract_xml_record(field,"center_freq",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> center_freq;
	      }
	    if (extract_xml_record(field,"latitude",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> latitude;
	      }
	    if (extract_xml_record(field,"longitude",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> longitude;
	      }
	    if (extract_xml_record(field,"elevation",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> elevation;
	      }
	    if (extract_xml_record(field,"diameter",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> diameter;
	      }
	    if (extract_xml_record(field,"az_orientation",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> az_orientation;
	      }
	    az_corr_coeff.clear();
	    if (extract_xml_record(field,"az_corr_coeff",sub)) {
	      pos=sub.find(">");
	      do {
	        if (pos!=std::string::npos) {
	          do { pos++; } while ((sub[pos]=='\n') || (sub[pos]==','));
	          std::istringstream in(std::string(sub.c_str()+pos)); 
	          float tmp;
	          in >> tmp;
	          az_corr_coeff.push_back(tmp);
	        }
	      } while ((pos=sub.find(",",pos)) != std::string::npos); 
	    }
	    zen_corr_coeff.clear();
	    if (extract_xml_record(field,"zen_corr_coeff",sub)) {
	      pos=sub.find(">");
	      do {
	        if (pos!=std::string::npos) {
	          do { pos++; } while ((sub[pos]=='\n') || (sub[pos]==','));
	          std::istringstream in(std::string(sub.c_str()+pos)); 
	          float tmp;
	          in >> tmp;
	          zen_corr_coeff.push_back(tmp);
	        }
	      } while ((pos=sub.find(",",pos)) != std::string::npos); 
	    }
	    if (extract_xml_record(field,"array_az_ellipse",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> array_az_ellipse;
	      }
	    if (extract_xml_record(field,"array_za_ellipse",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> array_za_ellipse;
	      }
	    if (extract_xml_record(field,"array_angle",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> array_angle;
	      }
	      }
	      }

	void receiver_config::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> s4_id;
	    }
	  {  
	        strncpy(name,s[2]->c_str(),255);
	        name[254]=0;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> beam_width;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> center_freq;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> latitude;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> longitude;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> elevation;
	    }
	  {  
	        std::istringstream row(*(s[8]));
	        row >> diameter;
	    }
	  {  
	        std::istringstream row(*(s[9]));
	        row >> az_orientation;
	    }
	  {  
	  std::string::size_type p,q;
	  int i;
	    az_corr_coeff.clear();
	      SQL_ROW tmp(s[10]); 
	        for (i=0;i<tmp.argc();i++) {
	          std::istringstream in(*(tmp[i]));
	          float tmp0;
	          in >> tmp0;
	          az_corr_coeff.push_back(tmp0);
	      }
	    }
	  {  
	  std::string::size_type p,q;
	  int i;
	    zen_corr_coeff.clear();
	      SQL_ROW tmp(s[11]); 
	        for (i=0;i<tmp.argc();i++) {
	          std::istringstream in(*(tmp[i]));
	          float tmp0;
	          in >> tmp0;
	          zen_corr_coeff.push_back(tmp0);
	      }
	    }
	  {  
	        std::istringstream row(*(s[12]));
	        row >> array_az_ellipse;
	    }
	  {  
	        std::istringstream row(*(s[13]));
	        row >> array_za_ellipse;
	    }
	  {  
	        std::istringstream row(*(s[14]));
	        row >> array_angle;
	    }
	      }

	void receiver_config::parse(const std::string &s) {
	      SQL_ROW row(&s,15);
	      parse(row);
	      }

template <> const char * const db_table<splitter_config>::table_name="splitter_config";
template <> const char * db_table<splitter_config>::_search_tag=table_name;
template <> const int db_table<splitter_config>::_nfields=3;
template <> const char * const db_table<splitter_config>::column_names[3]={"id","version","blocks_per_wu"};

splitter_config::splitter_config() : 
	db_table<splitter_config>(*this,-1),
	id(0),
	version(0),
	blocks_per_wu(0)
{
	db_open();
}


splitter_config::splitter_config(const splitter_config &a) : 
	db_table<splitter_config>(*this,-1),
	id(a.id),
	version(a.version),
	blocks_per_wu(a.blocks_per_wu)
{
	db_open();
}


splitter_config::splitter_config(const SQL_ROW &a) : 
	db_table<splitter_config>(*this,-1)
{
	db_open();
	parse(a);
}


splitter_config::splitter_config(const std::string &s,const char *tag) : 
	db_table<splitter_config>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


splitter_config &splitter_config::operator =(const splitter_config &a) {
	if (&a != this) {
		id=a.id;
		version=a.version;
		blocks_per_wu=a.blocks_per_wu;
	}
	return (*this);
}


std::string splitter_config::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<3;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string splitter_config::insert_format() const
{	return std::string("?,")+update_format();
}

std::string splitter_config::select_format() const
{
std::string rv("");
for (int i=0; i<2;i++) rv+="?,";
rv+="?";
return rv;
}

std::string splitter_config::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << version;
	rv << ',';
	rv << blocks_per_wu;
	return rv.str();
}


std::string splitter_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	rv << xml_indent() << "<version>" << version << "</version>\n";
	rv << xml_indent() << "<blocks_per_wu>" << blocks_per_wu << "</blocks_per_wu>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void splitter_config::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"version",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> version;
	      }
	    if (extract_xml_record(field,"blocks_per_wu",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> blocks_per_wu;
	      }
	      }
	      }

	void splitter_config::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> version;
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> blocks_per_wu;
	    }
	      }

	void splitter_config::parse(const std::string &s) {
	      SQL_ROW row(&s,3);
	      parse(row);
	      }

template <> const char * const db_table<settings>::table_name="settings";
template <> const char * db_table<settings>::_search_tag=table_name;
template <> const int db_table<settings>::_nfields=6;
template <> const char * const db_table<settings>::column_names[6]={"id","active","receiver_cfg","recorder_cfg","splitter_cfg","analysis_cfg"};

settings::settings() : 
	db_table<settings>(*this,-1),
	id(0),
	active(0),
	receiver_cfg(),
	recorder_cfg(),
	splitter_cfg(),
	analysis_cfg()
{
	db_open();
}


settings::settings(const settings &a) : 
	db_table<settings>(*this,-1),
	id(a.id),
	active(a.active),
	receiver_cfg(a.receiver_cfg),
	recorder_cfg(a.recorder_cfg),
	splitter_cfg(a.splitter_cfg),
	analysis_cfg(a.analysis_cfg)
{
	db_open();
}


settings::settings(const SQL_ROW &a) : 
	db_table<settings>(*this,-1)
{
	db_open();
	parse(a);
}


settings::settings(const std::string &s,const char *tag) : 
	db_table<settings>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


settings &settings::operator =(const settings &a) {
	if (&a != this) {
		id=a.id;
		active=a.active;
		receiver_cfg=a.receiver_cfg;
		recorder_cfg=a.recorder_cfg;
		splitter_cfg=a.splitter_cfg;
		analysis_cfg=a.analysis_cfg;
	}
	return (*this);
}


std::string settings::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<6;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string settings::insert_format() const
{	return std::string("?,")+update_format();
}

std::string settings::select_format() const
{
std::string rv("");
for (int i=0; i<5;i++) rv+="?,";
rv+="?";
return rv;
}

std::string settings::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << active;
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << receiver_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << recorder_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << splitter_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << analysis_cfg.id;
	  }
	}
	return rv.str();
}


std::string settings::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	rv << xml_indent() << "<active>" << active << "</active>\n";
	if (!no_refs) {
	  if (full_subtables) {
	    rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
	} else {
	    rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
	} else {
	    rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
	} else {
	    rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
	} else {
	    rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
	  }
	}
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void settings::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"active",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> active;
	      }
	    if (extract_xml_record(field,"receiver_cfg",sub)) {
	      receiver_cfg.parse_xml(sub,"receiver_cfg");
	    }
	    if (extract_xml_record(field,"recorder_cfg",sub)) {
	      recorder_cfg.parse_xml(sub,"recorder_cfg");
	    }
	    if (extract_xml_record(field,"splitter_cfg",sub)) {
	      splitter_cfg.parse_xml(sub,"splitter_cfg");
	    }
	    if (extract_xml_record(field,"analysis_cfg",sub)) {
	      analysis_cfg.parse_xml(sub,"analysis_cfg");
	    }
	      }
	      }

	void settings::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> active;
	    }
	  {  
	  receiver_cfg.parse(SQL_ROW(s[2],0));
	    }
	  {  
	  recorder_cfg.parse(SQL_ROW(s[3],0));
	    }
	  {  
	  splitter_cfg.parse(SQL_ROW(s[4],0));
	    }
	  {  
	  analysis_cfg.parse(SQL_ROW(s[5],0));
	    }
	      }

	void settings::parse(const std::string &s) {
	      SQL_ROW row(&s,6);
	      parse(row);
	      }

template <> const char * const db_table<workunit_header>::table_name="workunit_header";
template <> const char * db_table<workunit_header>::_search_tag=table_name;
template <> const int db_table<workunit_header>::_nfields=8;
template <> const char * const db_table<workunit_header>::column_names[8]={"id","name","tape_info","receiver_cfg","recorder_cfg","splitter_cfg","analysis_cfg","data_desc"};

workunit_header::workunit_header() : 
	db_table<workunit_header>(*this,-1),
	id(0),
	tape_info(),
	receiver_cfg(),
	recorder_cfg(),
	splitter_cfg(),
	analysis_cfg(),
	data_desc()
{
	db_open();
	name[0]=0;
}


workunit_header::workunit_header(const workunit_header &a) : 
	db_table<workunit_header>(*this,-1),
	id(a.id),
	tape_info(a.tape_info),
	receiver_cfg(a.receiver_cfg),
	recorder_cfg(a.recorder_cfg),
	splitter_cfg(a.splitter_cfg),
	analysis_cfg(a.analysis_cfg),
	data_desc(a.data_desc)
{
	db_open();
	strcpy(name,a.name);
}


workunit_header::workunit_header(const SQL_ROW &a) : 
	db_table<workunit_header>(*this,-1)
{
	db_open();
	parse(a);
}


workunit_header::workunit_header(const std::string &s,const char *tag) : 
	db_table<workunit_header>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


workunit_header &workunit_header::operator =(const workunit_header &a) {
	if (&a != this) {
		id=a.id;
		tape_info=a.tape_info;
		receiver_cfg=a.receiver_cfg;
		recorder_cfg=a.recorder_cfg;
		splitter_cfg=a.splitter_cfg;
		analysis_cfg=a.analysis_cfg;
		data_desc=a.data_desc;
	strcpy(name,a.name);
	}
	return (*this);
}


std::string workunit_header::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<8;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string workunit_header::insert_format() const
{	return std::string("?,")+update_format();
}

std::string workunit_header::select_format() const
{
std::string rv("");
for (int i=0; i<7;i++) rv+="?,";
rv+="?";
return rv;
}

std::string workunit_header::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << "'" << name << "'";
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << tape_info.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << tape_info.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << receiver_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << recorder_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << splitter_cfg.id;
	  }
	}
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << analysis_cfg.id;
	  }
	}
	rv << ',';
	rv << data_desc.print(full_subtables,show_ids,no_refs);
	return rv.str();
}


std::string workunit_header::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	{
	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
	  rv << xml_indent() << "<name>";
	  rv << enc_field << "</name>\n";
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << tape_info.print_xml(full_subtables,show_ids,no_refs,"tape_info");
	} else {
	    rv << xml_indent() << "<tape_info><id>" << tape_info.id << "</id></tape_info>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
	} else {
	    rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
	} else {
	    rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
	} else {
	    rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
	  }
	}
	if (!no_refs) {
	  if (full_subtables) {
	    rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
	} else {
	    rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
	  }
	}
	rv << data_desc.print_xml(full_subtables,show_ids,no_refs,"data_desc");
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void workunit_header::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"name",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::string::size_type epos=sub.find("<",pos);
	        if (epos==std::string::npos) epos=sub.find('\n',pos);
	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)128));
	        name[std::min(in.size(),(size_t)127)]=0;
	      }
	    if (extract_xml_record(field,"tape_info",sub)) {
	      tape_info.parse_xml(sub,"tape_info");
	    }
	    if (extract_xml_record(field,"receiver_cfg",sub)) {
	      receiver_cfg.parse_xml(sub,"receiver_cfg");
	    }
	    if (extract_xml_record(field,"recorder_cfg",sub)) {
	      recorder_cfg.parse_xml(sub,"recorder_cfg");
	    }
	    if (extract_xml_record(field,"splitter_cfg",sub)) {
	      splitter_cfg.parse_xml(sub,"splitter_cfg");
	    }
	    if (extract_xml_record(field,"analysis_cfg",sub)) {
	      analysis_cfg.parse_xml(sub,"analysis_cfg");
	    }
	    if (extract_xml_record(field,"data_desc",sub)) {
	      data_desc.parse_xml(sub,"data_desc");
	    }
	      }
	      }

	void workunit_header::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        strncpy(name,s[1]->c_str(),128);
	        name[127]=0;
	    }
	  {  
	  tape_info.parse(SQL_ROW(s[2],0));
	    }
	  {  
	  receiver_cfg.parse(SQL_ROW(s[3],0));
	    }
	  {  
	  recorder_cfg.parse(SQL_ROW(s[4],0));
	    }
	  {  
	  splitter_cfg.parse(SQL_ROW(s[5],0));
	    }
	  {  
	  analysis_cfg.parse(SQL_ROW(s[6],0));
	    }
	  {  
	  data_desc.parse(SQL_ROW(s[7],0));
	    }
	      }

	void workunit_header::parse(const std::string &s) {
	      SQL_ROW row(&s,8);
	      parse(row);
	      }

template <> const char * const db_table<result>::table_name="result";
template <> const char * db_table<result>::_search_tag=table_name;
template <> const int db_table<result>::_nfields=10;
template <> const char * const db_table<result>::column_names[10]={"id","boinc_result","wuid","received","hostid","versionid","fraction_blanked","return_code","overflow","reserved"};

result::result() : 
	db_table<result>(*this,-1),
	id(0),
	boinc_result(0),
	wuid(),
	received(0),
	hostid(0),
	versionid(0),
	fraction_blanked(0),
	return_code(0),
	overflow(0),
	reserved(0)
{
	db_open();
}


result::result(const result &a) : 
	db_table<result>(*this,-1),
	id(a.id),
	boinc_result(a.boinc_result),
	wuid(a.wuid),
	received(a.received),
	hostid(a.hostid),
	versionid(a.versionid),
	fraction_blanked(a.fraction_blanked),
	return_code(a.return_code),
	overflow(a.overflow),
	reserved(a.reserved)
{
	db_open();
}


result::result(const SQL_ROW &a) : 
	db_table<result>(*this,-1)
{
	db_open();
	parse(a);
}


result::result(const std::string &s,const char *tag) : 
	db_table<result>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


result &result::operator =(const result &a) {
	if (&a != this) {
		id=a.id;
		boinc_result=a.boinc_result;
		wuid=a.wuid;
		received=a.received;
		hostid=a.hostid;
		versionid=a.versionid;
		fraction_blanked=a.fraction_blanked;
		return_code=a.return_code;
		overflow=a.overflow;
		reserved=a.reserved;
	}
	return (*this);
}


std::string result::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<10;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string result::insert_format() const
{	return std::string("?,")+update_format();
}

std::string result::select_format() const
{
std::string rv("");
for (int i=0; i<9;i++) rv+="?,";
rv+="?";
return rv;
}

std::string result::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	rv << boinc_result;
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << wuid.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << wuid.id;
	  }
	}
	rv << ',';
	rv << received;
	rv << ',';
	rv << hostid;
	rv << ',';
	rv << versionid;
	rv << ',';
	rv << fraction_blanked;
	rv << ',';
	rv << return_code;
	rv << ',';
	rv << overflow;
	rv << ',';
	rv << reserved;
	return rv.str();
}


std::string result::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	rv << xml_indent() << "<boinc_result>" << boinc_result << "</boinc_result>\n";
	if (!no_refs) {
	  if (full_subtables) {
	    rv << wuid.print_xml(full_subtables,show_ids,no_refs,"wuid");
	} else {
	    rv << xml_indent() << "<wuid><id>" << wuid.id << "</id></wuid>\n";
	  }
	}
	rv << xml_indent() << "<received>" << received << "</received>\n";
	rv << xml_indent() << "<hostid>" << hostid << "</hostid>\n";
	rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
	rv << xml_indent() << "<fraction_blanked>" << fraction_blanked << "</fraction_blanked>\n";
	rv << xml_indent() << "<return_code>" << return_code << "</return_code>\n";
	rv << xml_indent() << "<overflow>" << overflow << "</overflow>\n";
	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void result::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"boinc_result",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> boinc_result;
	      }
	    if (extract_xml_record(field,"wuid",sub)) {
	      wuid.parse_xml(sub,"wuid");
	    }
	    if (extract_xml_record(field,"received",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> received;
	      }
	    if (extract_xml_record(field,"hostid",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> hostid;
	      }
	    if (extract_xml_record(field,"versionid",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> versionid;
	      }
	    if (extract_xml_record(field,"fraction_blanked",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> fraction_blanked;
	      }
	    if (extract_xml_record(field,"return_code",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> return_code;
	      }
	    if (extract_xml_record(field,"overflow",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> overflow;
	      }
	    if (extract_xml_record(field,"reserved",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> reserved;
	      }
	      }
	      }

	void result::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	        std::istringstream row(*(s[1]));
	        row >> boinc_result;
	    }
	  {  
	  wuid.parse(SQL_ROW(s[2],0));
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> received;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> hostid;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> versionid;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> fraction_blanked;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> return_code;
	    }
	  {  
	        std::istringstream row(*(s[8]));
	        row >> overflow;
	    }
	  {  
	        std::istringstream row(*(s[9]));
	        row >> reserved;
	    }
	      }

	void result::parse(const std::string &s) {
	      SQL_ROW row(&s,10);
	      parse(row);
	      }

template <> const char * const db_table<ap_signal>::table_name="ap_signal";
template <> const char * db_table<ap_signal>::_search_tag=table_name;
template <> const int db_table<ap_signal>::_nfields=20;
template <> const char * const db_table<ap_signal>::column_names[20]={"id","resultid","fft_num","peak_bin","peak_power","scale","dm","period","ffa_scale","num_std_devs","ra","decl","time","qpix","rfi_found","reserved","time_series_len","raw_data_len","time_series","raw_data"};

ap_signal::ap_signal() : 
	db_table<ap_signal>(*this,-1),
	id(0),
	resultid(),
	fft_num(0),
	peak_bin(0),
	peak_power(0),
	scale(0),
	dm(0),
	period(0),
	ffa_scale(0),
	num_std_devs(0),
	ra(0),
	decl(0),
	time(0),
	qpix(0),
	rfi_found(0),
	reserved(0),
	time_series_len(0),
	raw_data_len(0),
	time_series((unsigned char *)0,0,_x_csv),
	raw_data((unsigned char *)0,0,_x_csv)
{
	db_open();
}


ap_signal::ap_signal(const ap_signal &a) : 
	db_table<ap_signal>(*this,-1),
	id(a.id),
	resultid(a.resultid),
	fft_num(a.fft_num),
	peak_bin(a.peak_bin),
	peak_power(a.peak_power),
	scale(a.scale),
	dm(a.dm),
	period(a.period),
	ffa_scale(a.ffa_scale),
	num_std_devs(a.num_std_devs),
	ra(a.ra),
	decl(a.decl),
	time(a.time),
	qpix(a.qpix),
	rfi_found(a.rfi_found),
	reserved(a.reserved),
	time_series_len(a.time_series_len),
	raw_data_len(a.raw_data_len),
	time_series(a.time_series),
	raw_data(a.raw_data)
{
	db_open();
}


ap_signal::ap_signal(const SQL_ROW &a) : 
	db_table<ap_signal>(*this,-1)
{
	db_open();
	parse(a);
}


ap_signal::ap_signal(const std::string &s,const char *tag) : 
	db_table<ap_signal>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


ap_signal &ap_signal::operator =(const ap_signal &a) {
	if (&a != this) {
		id=a.id;
		resultid=a.resultid;
		fft_num=a.fft_num;
		peak_bin=a.peak_bin;
		peak_power=a.peak_power;
		scale=a.scale;
		dm=a.dm;
		period=a.period;
		ffa_scale=a.ffa_scale;
		num_std_devs=a.num_std_devs;
		ra=a.ra;
		decl=a.decl;
		time=a.time;
		qpix=a.qpix;
		rfi_found=a.rfi_found;
		reserved=a.reserved;
		time_series_len=a.time_series_len;
		raw_data_len=a.raw_data_len;
		time_series=a.time_series;
		raw_data=a.raw_data;
	}
	return (*this);
}


std::string ap_signal::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<20;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string ap_signal::insert_format() const
{	return std::string("?,")+update_format();
}

std::string ap_signal::select_format() const
{
std::string rv("");
for (int i=0; i<19;i++) rv+="?,";
rv+="?";
return rv;
}

std::string ap_signal::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << resultid.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << resultid.id;
	  }
	}
	rv << ',';
	rv << fft_num;
	rv << ',';
	rv << peak_bin;
	rv << ',';
	rv << peak_power;
	rv << ',';
	rv << scale;
	rv << ',';
	rv << dm;
	rv << ',';
	rv << period;
	rv << ',';
	rv << ffa_scale;
	rv << ',';
	rv << num_std_devs;
	rv << ',';
	rv << ra;
	rv << ',';
	rv << decl;
	rv << ',';
	rv << time;
	rv << ',';
	rv << qpix;
	rv << ',';
	rv << rfi_found;
	rv << ',';
	rv << reserved;
	rv << ',';
	rv << time_series_len;
	rv << ',';
	rv << raw_data_len;
	rv << ',';
	rv << "<BYTE len=" << std::max(time_series.size(),(size_t)1) << ">" << time_series.print_raw() ;
	rv << ',';
	rv << "<BYTE len=" << std::max(raw_data.size(),(size_t)1) << ">" << raw_data.print_raw() ;
	return rv.str();
}


std::string ap_signal::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	if (!no_refs) {
	  if (full_subtables) {
	    rv << resultid.print_xml(full_subtables,show_ids,no_refs,"resultid");
	} else {
	    rv << xml_indent() << "<resultid><id>" << resultid.id << "</id></resultid>\n";
	  }
	}
	rv << xml_indent() << "<fft_num>" << fft_num << "</fft_num>\n";
	rv << xml_indent() << "<peak_bin>" << peak_bin << "</peak_bin>\n";
	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
	rv << xml_indent() << "<scale>" << scale << "</scale>\n";
	rv << xml_indent() << "<dm>" << dm << "</dm>\n";
	rv << xml_indent() << "<period>" << period << "</period>\n";
	rv << xml_indent() << "<ffa_scale>" << ffa_scale << "</ffa_scale>\n";
	rv << xml_indent() << "<num_std_devs>" << num_std_devs << "</num_std_devs>\n";
	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
	rv << xml_indent() << "<time>" << time << "</time>\n";
	rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
	rv << xml_indent() << "<time_series_len>" << time_series_len << "</time_series_len>\n";
	rv << xml_indent() << "<raw_data_len>" << raw_data_len << "</raw_data_len>\n";
	if (time_series.size()) {
	  std::string enc_field=xml_encode_string(time_series,time_series.encoding);
	  rv << xml_indent() << "<time_series length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[time_series.encoding] << "\">"; 
	  rv << enc_field << "</time_series>\n";
	}
	if (raw_data.size()) {
	  std::string enc_field=xml_encode_string(raw_data,raw_data.encoding);
	  rv << xml_indent() << "<raw_data length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[raw_data.encoding] << "\">"; 
	  rv << enc_field << "</raw_data>\n";
	}
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void ap_signal::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"resultid",sub)) {
	      resultid.parse_xml(sub,"resultid");
	    }
	    if (extract_xml_record(field,"fft_num",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> fft_num;
	      }
	    if (extract_xml_record(field,"peak_bin",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> peak_bin;
	      }
	    if (extract_xml_record(field,"peak_power",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> peak_power;
	      }
	    if (extract_xml_record(field,"scale",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> scale;
	      }
	    if (extract_xml_record(field,"dm",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> dm;
	      }
	    if (extract_xml_record(field,"period",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> period;
	      }
	    if (extract_xml_record(field,"ffa_scale",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> ffa_scale;
	      }
	    if (extract_xml_record(field,"num_std_devs",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> num_std_devs;
	      }
	    if (extract_xml_record(field,"ra",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> ra;
	      }
	    if (extract_xml_record(field,"decl",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> decl;
	      }
	    if (extract_xml_record(field,"time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> time;
	      }
	    if (extract_xml_record(field,"qpix",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> qpix;
	      }
	    if (extract_xml_record(field,"rfi_found",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> rfi_found;
	      }
	    if (extract_xml_record(field,"reserved",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> reserved;
	      }
	    if (extract_xml_record(field,"time_series_len",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> time_series_len;
	      }
	    if (extract_xml_record(field,"raw_data_len",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> raw_data_len;
	      }
	    if (extract_xml_record(field,"time_series",sub)) {
	        std::istringstream in(sub.c_str());
	        in >> time_series;
	      }
	    if (extract_xml_record(field,"raw_data",sub)) {
	        std::istringstream in(sub.c_str());
	        in >> raw_data;
	      }
	      }
	      }

	void ap_signal::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	  resultid.parse(SQL_ROW(s[1],0));
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> fft_num;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> peak_bin;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> peak_power;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> scale;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> dm;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> period;
	    }
	  {  
	        std::istringstream row(*(s[8]));
	        row >> ffa_scale;
	    }
	  {  
	        std::istringstream row(*(s[9]));
	        row >> num_std_devs;
	    }
	  {  
	        std::istringstream row(*(s[10]));
	        row >> ra;
	    }
	  {  
	        std::istringstream row(*(s[11]));
	        row >> decl;
	    }
	  {  
	        std::istringstream row(*(s[12]));
	        row >> time;
	    }
	  {  
	        std::istringstream row(*(s[13]));
	        row >> qpix;
	    }
	  {  
	        std::istringstream row(*(s[14]));
	        row >> rfi_found;
	    }
	  {  
	        std::istringstream row(*(s[15]));
	        row >> reserved;
	    }
	  {  
	        std::istringstream row(*(s[16]));
	        row >> time_series_len;
	    }
	  {  
	        std::istringstream row(*(s[17]));
	        row >> raw_data_len;
	    }
	  {  
	        time_series=sqlblob<unsigned char>(*(s[18]));
	    }
	  {  
	        raw_data=sqlblob<unsigned char>(*(s[19]));
	    }
	      }

	void ap_signal::parse(const std::string &s) {
	      SQL_ROW row(&s,20);
	      parse(row);
	      }

template <> const char * const db_table<rfi>::table_name="rfi";
template <> const char * db_table<rfi>::_search_tag=table_name;
template <> const int db_table<rfi>::_nfields=14;
template <> const char * const db_table<rfi>::column_names[14]={"id","ap_signalid","chisq","log_prob","chisq_time","rep_at_dm","rep_at_dm_time","fraction_blanked","user_marked","user_marked_time","edge_pulse_diff","edge_pulse_time","multi_beams","multi_beams_time"};

rfi::rfi() : 
	db_table<rfi>(*this,-1),
	id(0),
	ap_signalid(),
	chisq(0),
	log_prob(0),
	chisq_time(0),
	rep_at_dm(0),
	rep_at_dm_time(0),
	fraction_blanked(0),
	user_marked(0),
	user_marked_time(0),
	edge_pulse_diff(0),
	edge_pulse_time(0),
	multi_beams(0),
	multi_beams_time(0)
{
	db_open();
}


rfi::rfi(const rfi &a) : 
	db_table<rfi>(*this,-1),
	id(a.id),
	ap_signalid(a.ap_signalid),
	chisq(a.chisq),
	log_prob(a.log_prob),
	chisq_time(a.chisq_time),
	rep_at_dm(a.rep_at_dm),
	rep_at_dm_time(a.rep_at_dm_time),
	fraction_blanked(a.fraction_blanked),
	user_marked(a.user_marked),
	user_marked_time(a.user_marked_time),
	edge_pulse_diff(a.edge_pulse_diff),
	edge_pulse_time(a.edge_pulse_time),
	multi_beams(a.multi_beams),
	multi_beams_time(a.multi_beams_time)
{
	db_open();
}


rfi::rfi(const SQL_ROW &a) : 
	db_table<rfi>(*this,-1)
{
	db_open();
	parse(a);
}


rfi::rfi(const std::string &s,const char *tag) : 
	db_table<rfi>(*this,-1)
{
	db_open();
	if (xml_match_tag(s,tag)) {
	  parse_xml(s,tag);
	} else {
	  parse(s);
	}
}


rfi &rfi::operator =(const rfi &a) {
	if (&a != this) {
		id=a.id;
		ap_signalid=a.ap_signalid;
		chisq=a.chisq;
		log_prob=a.log_prob;
		chisq_time=a.chisq_time;
		rep_at_dm=a.rep_at_dm;
		rep_at_dm_time=a.rep_at_dm_time;
		fraction_blanked=a.fraction_blanked;
		user_marked=a.user_marked;
		user_marked_time=a.user_marked_time;
		edge_pulse_diff=a.edge_pulse_diff;
		edge_pulse_time=a.edge_pulse_time;
		multi_beams=a.multi_beams;
		multi_beams_time=a.multi_beams_time;
	}
	return (*this);
}


std::string rfi::update_format() const
{	std::ostringstream rv("");

	for (int i=2;i<14;i++) rv << "?,";
	rv << "?";
	return rv.str();
}


std::string rfi::insert_format() const
{	return std::string("?,")+update_format();
}

std::string rfi::select_format() const
{
std::string rv("");
for (int i=0; i<13;i++) rv+="?,";
rv+="?";
return rv;
}

std::string rfi::print(int full_subtables, int show_ids, int no_refs) const
{	std::ostringstream rv("");

	rv.precision(14);
	if (show_ids) rv << id;
	rv << ',';
	if (!no_refs) {
	  if (full_subtables) {
	    rv << ap_signalid.print(full_subtables,show_ids,no_refs);
	} else {
	    rv << ap_signalid.id;
	  }
	}
	rv << ',';
	rv << chisq;
	rv << ',';
	rv << log_prob;
	rv << ',';
	rv << chisq_time;
	rv << ',';
	rv << rep_at_dm;
	rv << ',';
	rv << rep_at_dm_time;
	rv << ',';
	rv << fraction_blanked;
	rv << ',';
	rv << user_marked;
	rv << ',';
	rv << user_marked_time;
	rv << ',';
	rv << edge_pulse_diff;
	rv << ',';
	rv << edge_pulse_time;
	rv << ',';
	rv << multi_beams;
	rv << ',';
	rv << multi_beams_time;
	return rv.str();
}


std::string rfi::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
{
	std::ostringstream rv("");

	rv.precision(14);
	rv << xml_indent() << '<' << tag << ">\n";
	xml_indent(2);
	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
	if (!no_refs) {
	  if (full_subtables) {
	    rv << ap_signalid.print_xml(full_subtables,show_ids,no_refs,"ap_signalid");
	} else {
	    rv << xml_indent() << "<ap_signalid><id>" << ap_signalid.id << "</id></ap_signalid>\n";
	  }
	}
	rv << xml_indent() << "<chisq>" << chisq << "</chisq>\n";
	rv << xml_indent() << "<log_prob>" << log_prob << "</log_prob>\n";
	rv << xml_indent() << "<chisq_time>" << chisq_time << "</chisq_time>\n";
	rv << xml_indent() << "<rep_at_dm>" << rep_at_dm << "</rep_at_dm>\n";
	rv << xml_indent() << "<rep_at_dm_time>" << rep_at_dm_time << "</rep_at_dm_time>\n";
	rv << xml_indent() << "<fraction_blanked>" << fraction_blanked << "</fraction_blanked>\n";
	rv << xml_indent() << "<user_marked>" << user_marked << "</user_marked>\n";
	rv << xml_indent() << "<user_marked_time>" << user_marked_time << "</user_marked_time>\n";
	rv << xml_indent() << "<edge_pulse_diff>" << edge_pulse_diff << "</edge_pulse_diff>\n";
	rv << xml_indent() << "<edge_pulse_time>" << edge_pulse_time << "</edge_pulse_time>\n";
	rv << xml_indent() << "<multi_beams>" << multi_beams << "</multi_beams>\n";
	rv << xml_indent() << "<multi_beams_time>" << multi_beams_time << "</multi_beams_time>\n";
	xml_indent(-2);
	rv << xml_indent() << "</" << tag << ">\n";
	return rv.str();
}


	void rfi::parse_xml(const std::string &s,const char *tag) {
	  std::string field,sub;
	  if (extract_xml_record(s,tag,field)) {
	  std::string::size_type pos=0;
	    if (extract_xml_record(field,"id",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> id;
	      }
	    if (extract_xml_record(field,"ap_signalid",sub)) {
	      ap_signalid.parse_xml(sub,"ap_signalid");
	    }
	    if (extract_xml_record(field,"chisq",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> chisq;
	      }
	    if (extract_xml_record(field,"log_prob",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> log_prob;
	      }
	    if (extract_xml_record(field,"chisq_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> chisq_time;
	      }
	    if (extract_xml_record(field,"rep_at_dm",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> rep_at_dm;
	      }
	    if (extract_xml_record(field,"rep_at_dm_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> rep_at_dm_time;
	      }
	    if (extract_xml_record(field,"fraction_blanked",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> fraction_blanked;
	      }
	    if (extract_xml_record(field,"user_marked",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> user_marked;
	      }
	    if (extract_xml_record(field,"user_marked_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> user_marked_time;
	      }
	    if (extract_xml_record(field,"edge_pulse_diff",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> edge_pulse_diff;
	      }
	    if (extract_xml_record(field,"edge_pulse_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> edge_pulse_time;
	      }
	    if (extract_xml_record(field,"multi_beams",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> multi_beams;
	      }
	    if (extract_xml_record(field,"multi_beams_time",sub)) {
	        pos=sub.find(">");
	        do { pos++; } while(sub[pos]=='\n');
	        std::istringstream in(sub.c_str()+pos);
	        in >> multi_beams_time;
	      }
	      }
	      }

	void rfi::parse(const SQL_ROW &s) {
	  {  
	        std::istringstream row(*(s[0]));
	        row >> id;
	    }
	  {  
	  ap_signalid.parse(SQL_ROW(s[1],0));
	    }
	  {  
	        std::istringstream row(*(s[2]));
	        row >> chisq;
	    }
	  {  
	        std::istringstream row(*(s[3]));
	        row >> log_prob;
	    }
	  {  
	        std::istringstream row(*(s[4]));
	        row >> chisq_time;
	    }
	  {  
	        std::istringstream row(*(s[5]));
	        row >> rep_at_dm;
	    }
	  {  
	        std::istringstream row(*(s[6]));
	        row >> rep_at_dm_time;
	    }
	  {  
	        std::istringstream row(*(s[7]));
	        row >> fraction_blanked;
	    }
	  {  
	        std::istringstream row(*(s[8]));
	        row >> user_marked;
	    }
	  {  
	        std::istringstream row(*(s[9]));
	        row >> user_marked_time;
	    }
	  {  
	        std::istringstream row(*(s[10]));
	        row >> edge_pulse_diff;
	    }
	  {  
	        std::istringstream row(*(s[11]));
	        row >> edge_pulse_time;
	    }
	  {  
	        std::istringstream row(*(s[12]));
	        row >> multi_beams;
	    }
	  {  
	        std::istringstream row(*(s[13]));
	        row >> multi_beams_time;
	    }
	      }

	void rfi::parse(const std::string &s) {
	      SQL_ROW row(&s,14);
	      parse(row);
	      }

