Generic hardware access library
/home/cschwick/hal/generic/src/common/AbstractCommandFactory.cc
Go to the documentation of this file.
00001 #include <string>
00002 #include "hal/AbstractCommandFactory.hh"
00003 
00004 
00005 uint32_t 
00006 HAL::AbstractCommandFactory::stringToNumber( std::string numberString ) 
00007   throw (HAL::SequencerSyntaxError) {
00008   uint32_t data;
00009   int success;
00010   // dirty conversion of the data string to a number:
00011   if ( numberString.size() >= 2 &&
00012        numberString[0] == '0' &&
00013        ( numberString[1] == 'x' || numberString[1] == 'X') ) {
00014     // we need to scan a hex number
00015     success = sscanf(numberString.c_str(),"%x", &data);
00016   } else {
00017     // we need to scan a dec string
00018     success = sscanf(numberString.c_str(),"%d", &data);
00019   }
00020   if (success == 0) {
00021     throw (HAL::SequencerSyntaxError("Wrong data number format."));
00022   }
00023   return data;
00024 }