Changeset 530 for XIOS/branchs/xios-1.0


Ignore:
Timestamp:
12/09/14 13:02:34 (9 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/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<> 
Note: See TracChangeset for help on using the changeset viewer.