Converter.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef CONVERTER_H_
00004 #define CONVERTER_H_
00005 
00006 #include <fesa-core/Utilities/StringUtilities.h>
00007 
00008 #include <string>
00009 #include <cstring>
00010 #include <boost/lexical_cast.hpp>
00011 
00012 namespace fesa
00013 {
00014 
00020 template<typename T>
00021 class Converter
00022 {
00023   public:
00029     static void valueToString(T value, std::string& str);
00030 
00036     static void stringToValue(const std::string& value, T* pVal);
00037 
00038 };
00039 
00040 template<typename T>
00041 inline void Converter<T>::valueToString(T value,std::string& str)
00042 {
00043 
00044     str = boost::lexical_cast<std::string>(value);
00045 
00046 }
00047 
00048 template<typename T>
00049 inline void Converter<T>::stringToValue(const std::string& value, T* pVal)
00050 {
00051 
00052     if (strcasecmp(value.c_str(), "nan") == 0)
00053     {
00054         *pVal = std::numeric_limits<T>::quiet_NaN();
00055     }
00056     else
00057     {
00058         StringUtilities::fromString<T>(*pVal, value);
00059     }
00060 }
00061 
00062 } // fesa
00063 
00064 #include <fesa-core/DataStore/ConverterSignedChar.h>
00065 #include <fesa-core/DataStore/ConverterBool.h>
00066 #include <fesa-core/DataStore/ConverterDeviceRelations.h>
00067 #include <fesa-core/DataStore/ConverterHostHardwareAddress.h>
00068 #include <fesa-core/DataStore/ConverterLogicalHardwareAddress.h>
00069 #include <fesa-core/DataStore/ConverterPortHostHardwareAddress.h>
00070 
00071 #endif // CONVERTER_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1