ParameterIOimpl.cc

00001 #include "ParameterIOimpl.hh"
00002 //#include "Message.hh"
00003 #include <stdexcept>
00004 #include "phrase.hh"
00005 
00006 //allow hex base for unsigned ints
00007 unsigned long ParameterIOimpl::ReadUnsignedInt(std::istream& in)
00008 {
00009   std::string temp;
00010   in>>temp;
00011   if(temp[0] == '0' && (temp[1] == 'x' || temp[1] == 'X'))
00012     return std::strtoul(temp.c_str(),0,16);
00013   else
00014     return std::strtoul(temp.c_str(),0,10);
00015 }
00016 
00017 
00018 
00020 std::istream& ParameterIOimpl::read(std::istream& in, std::string& s)
00021 {
00022   phrase temp;
00023   in>>temp;
00024   s = temp;
00025   return in;
00026     
00027 }
00028   
00030 std::ostream& ParameterIOimpl::write(std::ostream& out, const std::string& s, 
00031                                      bool, int)
00032 {
00033   phrase temp(s);
00034   return out<<temp;
00035 }
00036 
00037 //override bool to allow true and false
00038 std::istream& ParameterIOimpl::read(std::istream& in, bool& b)
00039 {
00040   std::string temp;
00041   in>>temp;
00042   if(temp == "1" || temp == "true" || temp == "TRUE")
00043     b = true;
00044   else if( temp == "0" || temp == "false" || temp == "FALSE" )
00045     b = false;
00046   else{
00047     //Message e(EXCEPTION);
00048     std::cerr<<"Expected boolean value, got "<<temp<<std::endl;
00049     throw std::invalid_argument("Expected boolean value");
00050   }
00051   return in;
00052 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1