Changeset 530 for XIOS


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.

Location:
XIOS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/node/variable.hpp

    r501 r530  
    9898      }; // class CVar 
    9999 
    100       template<> 
    101       inline bool CVariable::getData(void) const 
    102       { 
    103          if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 
    104          else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 
    105          else ERROR("CVariable::getdata()", 
    106                << "Cannot convert string <" << content << "> into type required" ); 
    107          return false ; 
    108       } 
    109  
    110100      template <typename T> 
    111101      inline T CVariable::getData(void) const 
     
    119109         return retval ; 
    120110      } 
     111 
     112      template<> 
     113      inline bool CVariable::getData(void) const 
     114      { 
     115         if (content.compare("true")==0 || content.compare(".true.")==0 || content.compare(".TRUE.")==0) return true ; 
     116         else if (content.compare("false")==0 || content.compare(".false.")==0 || content.compare(".FALSE.")==0) return false ; 
     117         else ERROR("CVariable::getdata()", 
     118               << "Cannot convert string <" << content << "> into type required" ); 
     119         return false ; 
     120      } 
     121 
     122      template<> 
     123      inline std::string CVariable::getData(void) const 
     124      { return content; } 
    121125 
    122126      template<> 
  • 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.