Ignore:
Timestamp:
05/24/11 08:21:57 (13 years ago)
Author:
hozdoba
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/xmlio/attribute_template.cpp

    r171 r201  
    11#include "attribute_template.hpp" 
    2  
    32#include "attribute_template_impl.hpp" 
     3 
     4#include <cfloat> 
    45 
    56namespace xmlioserver 
     
    3132      template <> // Chaîne de caractÚres. 
    3233         void CAttributeTemplate<StdString>::fromString(const StdString & str) 
    33       { this->setValue(str); } 
     34      {  
     35         this->setValue(str);  
     36      } 
    3437 
    3538      template <> // Entier 
     
    4346         { 
    4447            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)", 
    4573                  << "[ str = " << str << " ] Bad cast !"); 
    4674         } 
     
    141169      } 
    142170 
     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 
    143178      //--------------------------------------------------------------- 
    144179 
     
    171206      } 
    172207 
     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 
    173216      ///-------------------------------------------------------------- 
    174217   } // namespace tree 
Note: See TracChangeset for help on using the changeset viewer.