Ignore:
Timestamp:
12/09/14 13:02:34 (7 years ago)
Author:
rlacroix
Message:

Fix: String variable with whitespaces were incorrectly parsed.

The strings were only parsed until the first whitespace was encountered. Note that leading and trailing whitespaces are removed by design.

Also backport that fix to XIOS 1.0.

This commit fixes ticket #60.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/variable.hpp

    r527 r530  
    9494      }; // class CVar 
    9595 
    96       template<> 
    97       inline bool CVariable::getData(void) const 
    98       { 
    99          if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 
    100          else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 
    101          else ERROR("CVariable::getdata()", 
    102                << "Cannot convert string <" << content << "> into type required" ); 
    103          return false ; 
    104       } 
    105  
    10696      template <typename T> 
    10797      inline T CVariable::getData(void) const 
     
    115105         return retval ; 
    116106      } 
     107 
     108      template<> 
     109      inline bool CVariable::getData(void) const 
     110      { 
     111         if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 
     112         else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 
     113         else ERROR("CVariable::getdata()", 
     114               << "Cannot convert string <" << content << "> into type required" ); 
     115         return false ; 
     116      } 
     117 
     118      template<> 
     119      inline std::string CVariable::getData(void) const 
     120      { return content; } 
    117121 
    118122      template<> 
Note: See TracChangeset for help on using the changeset viewer.