00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SBUILD_PARSE_VALUE_H
00021 #define SBUILD_PARSE_VALUE_H
00022
00023 #include <string>
00024
00025 #include "sbuild-log.h"
00026
00027 namespace sbuild
00028 {
00037 bool
00038 parse_value (std::string const& stringval,
00039 bool& value);
00040
00047 bool
00048 parse_value (std::string const& stringval,
00049 std::string& value);
00050
00057 template <typename T>
00058 bool
00059 parse_value (std::string const& stringval,
00060 T& value)
00061 {
00062 std::istringstream is(stringval);
00063 is.imbue(std::locale("C"));
00064 T tmpval;
00065 if (is >> tmpval)
00066 {
00067 value = tmpval;
00068 log_debug(DEBUG_NOTICE) << "value=" << value << std::endl;
00069 return true;
00070 }
00071 log_debug(DEBUG_NOTICE) << "parse error" << std::endl;
00072 return false;
00073 }
00074
00075 }
00076
00077 #endif
00078
00079
00080
00081
00082
00083