Changeset 201 for XMLIO_V2/dev/dev_rv/src/xmlio/attribute_template.cpp
- Timestamp:
- 05/24/11 08:21:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/attribute_template.cpp
r171 r201 1 1 #include "attribute_template.hpp" 2 3 2 #include "attribute_template_impl.hpp" 3 4 #include <cfloat> 4 5 5 6 namespace xmlioserver … … 31 32 template <> // Chaîne de caractÚres. 32 33 void CAttributeTemplate<StdString>::fromString(const StdString & str) 33 { this->setValue(str); } 34 { 35 this->setValue(str); 36 } 34 37 35 38 template <> // Entier … … 43 46 { 44 47 ERROR("void CAttributeTemplate<int>::fromString(const StdString & str)", 48 << "[ str = " << str << " ] Bad cast !"); 49 } 50 } 51 52 template <> // Double 53 void CAttributeTemplate<double>::fromString(const StdString & str) 54 { 55 if (str.find("max") != StdString::npos) 56 { 57 this->setValue(DBL_MAX); 58 return; 59 } 60 if (str.find("min") != StdString::npos) 61 { 62 this->setValue(DBL_MIN); 63 return; 64 } 65 66 try 67 { 68 this->setValue(boost::lexical_cast<double>(str)); 69 } 70 catch(boost::bad_lexical_cast &) 71 { 72 ERROR("void CAttributeTemplate<double>::fromString(const StdString & str)", 45 73 << "[ str = " << str << " ] Bad cast !"); 46 74 } … … 141 169 } 142 170 171 template <> // Double 172 void CAttributeTemplate<double>::toBinary(StdOStream & os) const 173 { 174 double value = this->getValue(); 175 os.write (reinterpret_cast<const char*>(&value) , sizeof(double)); 176 } 177 143 178 //--------------------------------------------------------------- 144 179 … … 171 206 } 172 207 208 template <> // Double 209 void CAttributeTemplate<double>::fromBinary(StdIStream & is) 210 { 211 double value = 0.; 212 is.read (reinterpret_cast<char*>(&value), sizeof(double)); 213 this->setValue(value); 214 } 215 173 216 ///-------------------------------------------------------------- 174 217 } // namespace tree
Note: See TracChangeset
for help on using the changeset viewer.