Changeset 1143


Ignore:
Timestamp:
Jul 24, 2010, 5:05:34 AM (9 years ago)
Author:
Peter Johansson
Message:

be entirely case-insensitive when checking boolean variables in config file, and allow on/off and 1/0 values

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Configuration.cc

    r1136 r1143  
    2727#include "Functor.h"
    2828
     29#include <algorithm>
    2930#include <cassert>
    3031#include <fstream>
     
    109110
    110111
    111   bool Configuration::equal_false(const std::string& str) const
    112   {
    113     return str=="false" || str=="False" || str=="FALSE" ||
    114       str=="no" || str=="No" || str=="NO";
    115   }
    116 
    117 
    118   bool Configuration::equal_true(const std::string& str) const
    119   {
    120     return str=="true" || str=="True" || str=="TRUE" ||
    121       str=="yes" || str=="Yes" || str=="YES";
     112  bool Configuration::equal_false(std::string str) const
     113  {
     114    transform(str.begin(), str.end(), str.begin(), tolower);
     115    return str=="false" || str=="no" || str=="off" || str=="0";
     116  }
     117
     118
     119  bool Configuration::equal_true(std::string str) const
     120  {
     121    transform(str.begin(), str.end(), str.begin(), tolower);
     122    return str=="true" || str=="yes" || str=="on" || str=="1";
    122123  }
    123124
  • trunk/lib/Configuration.h

    r1136 r1143  
    140140    void clear(void);
    141141    const std::pair<std::string,std::string>* dictionary(std::string lhs) const;
    142     bool equal_false(const std::string&) const;
    143     bool equal_true(const std::string&) const;
     142    bool equal_false(std::string) const;
     143    bool equal_true(std::string) const;
    144144    ///
    145145    /// @brief load deafult configuration
Note: See TracChangeset for help on using the changeset viewer.