Feature_AMOS.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include "Feature_AMOS.hh"
00011 using namespace AMOS;
00012 using namespace std;
00013 
00014 
00015 
00016 
00017 //====================================================== Feature_t =============
00018 const NCode_t Feature_t::NCODE = M_FEATURE;
00019 
00020 //----------------------------------------------------- readMessage ------------
00021 void Feature_t::readMessage (const Message_t & msg)
00022 {
00023   Universal_t::readMessage (msg);
00024 
00025   try {
00026     istringstream ss;
00027 
00028     if ( msg . exists (F_CLEAR) )
00029       {
00030         ss . str (msg . getField (F_CLEAR));
00031         ss >> range_m . begin;
00032         ss . ignore( );
00033         ss >> range_m . end;
00034         if ( !ss )
00035           AMOS_THROW_ARGUMENT ("Invalid clear range format");
00036         ss . clear( );
00037       }
00038  
00039     if ( msg . exists (F_TYPE) )
00040       {
00041         ss . str (msg . getField (F_TYPE));
00042         ss . get (type_m);
00043         ss . clear( );
00044       }
00045 
00046     if ( msg . exists (F_SOURCE) )
00047       {
00048         string str;
00049 
00050         ss . str (msg . getField (F_SOURCE));
00051         ss >> source_m . first;
00052         ss . ignore( );
00053         ss >> str;
00054         if ( !ss  ||  str . length( ) != NCODE_SIZE )
00055           AMOS_THROW_ARGUMENT ("Invalid source format");
00056         ss . clear( );
00057         source_m . second = Encode (str);
00058       }
00059   }
00060   catch (ArgumentException_t) {
00061     
00062     clear( );
00063     throw;
00064   }
00065 }
00066 
00067 
00068 //----------------------------------------------------- readRecord -------------
00069 void Feature_t::readRecord (istream & fix, istream & var)
00070 {
00071   Universal_t::readRecord (fix, var);
00072 
00073   readLE (fix, &(range_m . begin));
00074   readLE (fix, &(range_m . end));
00075   readLE (fix, &(source_m . first));
00076   readLE (fix, &(source_m . second));
00077   fix . get (type_m);
00078 }
00079 
00080 
00081 //----------------------------------------------------- readRecordFix ----------
00082 void Feature_t::readRecordFix (istream & fix)
00083 {
00084   Universal_t::readRecordFix (fix);
00085 
00086   readLE (fix, &(range_m . begin));
00087   readLE (fix, &(range_m . end));
00088   readLE (fix, &(source_m . first));
00089   readLE (fix, &(source_m . second));
00090   fix . get (type_m);
00091 }
00092 
00093 
00094 //----------------------------------------------------- writeMessage -----------
00095 void Feature_t::writeMessage (Message_t & msg) const
00096 {
00097   Universal_t::writeMessage (msg);
00098 
00099   try {
00100     ostringstream ss;
00101 
00102     msg . setMessageCode (Feature_t::NCODE);
00103 
00104     if ( range_m . getLength( ) != 0 )
00105       {
00106         ss << range_m . begin << ',' << range_m . end;
00107         msg . setField (F_CLEAR, ss . str( ));
00108         ss . str (NULL_STRING);
00109       }
00110     
00111     if ( type_m != NULL_FEATURE )
00112       {
00113         ss << type_m;
00114         msg . setField (F_TYPE, ss . str( ));
00115         ss . str (NULL_STRING);
00116       }
00117     
00118     if ( source_m . first != NULL_ID  ||  source_m . second != NULL_NCODE )
00119       {
00120         ss << source_m . first << ',' << Decode (source_m . second);
00121         msg . setField (F_SOURCE, ss . str( ));
00122         ss . str (NULL_STRING);
00123       }
00124   }
00125   catch (ArgumentException_t) {
00126 
00127     msg . clear( );
00128     throw;
00129   }
00130 }
00131 
00132 
00133 //----------------------------------------------------- writeRecord ------------
00134 void Feature_t::writeRecord (ostream & fix, ostream & var) const
00135 {
00136   Universal_t::writeRecord (fix, var);
00137 
00138   writeLE (fix, &(range_m . begin));
00139   writeLE (fix, &(range_m . end));
00140   writeLE (fix, &(source_m . first));
00141   writeLE (fix, &(source_m . second));
00142   fix . put (type_m);
00143 }

Generated on Mon Feb 22 17:36:27 2010 for libAMOS by  doxygen 1.4.7