| 44 | 
  | 
 * | 
| 45 | 
  | 
 *  Created by Charles F. Vardeman II on 11/15/05. | 
| 46 | 
  | 
 *  @author  Charles F. Vardeman II  | 
| 47 | 
< | 
 *  @version $Id: OptionSectionParser.cpp,v 1.1 2005-11-16 21:37:41 chuckv Exp $ | 
| 47 | 
> | 
 *  @version $Id: OptionSectionParser.cpp,v 1.2 2005-11-16 23:10:02 tim Exp $ | 
| 48 | 
  | 
 * | 
| 49 | 
  | 
 */ | 
| 50 | 
  | 
 | 
| 52 | 
  | 
#include "types/AtomType.hpp" | 
| 53 | 
  | 
#include "UseTheForce/ForceField.hpp" | 
| 54 | 
  | 
#include "utils/simError.h" | 
| 55 | 
+ | 
#include "utils/StringUtils.hpp" | 
| 56 | 
  | 
namespace oopse { | 
| 57 | 
< | 
   | 
| 58 | 
< | 
  OptionSectionParser::OptionSectionParser() { | 
| 59 | 
< | 
    setSectionName("Options"); | 
| 60 | 
< | 
    DefineOptionalParameter(MixingRule, "standard"); | 
| 61 | 
< | 
     | 
| 62 | 
< | 
     | 
| 57 | 
> | 
 | 
| 58 | 
> | 
  bool ForceFieldOptions::setData(const std::string& keyword, const std::string& value) { | 
| 59 | 
> | 
      bool result; | 
| 60 | 
> | 
      ParamMap::iterator i =parameters_.find(keyword); | 
| 61 | 
> | 
      if (i != parameters_.end()) { | 
| 62 | 
> | 
        if(isType<int>(value)){ | 
| 63 | 
> | 
          int ival = lexi_cast<int>(value); | 
| 64 | 
> | 
          result = i->second->setData(ival); | 
| 65 | 
> | 
        }       | 
| 66 | 
> | 
        else if (isType<double>(value)){ | 
| 67 | 
> | 
          double dval = lexi_cast<double>(value); | 
| 68 | 
> | 
          result = i->second->setData(dval); | 
| 69 | 
> | 
        } else{ | 
| 70 | 
> | 
           result = i->second->setData(value); | 
| 71 | 
> | 
        } | 
| 72 | 
> | 
      } else { | 
| 73 | 
> | 
        sprintf(painCave.errMsg,  "%s is an unrecognized keyword\n", keyword.c_str() ); | 
| 74 | 
> | 
          painCave.isFatal = 0; | 
| 75 | 
> | 
          simError();         | 
| 76 | 
> | 
      } | 
| 77 | 
> | 
 | 
| 78 | 
> | 
      return result; | 
| 79 | 
  | 
  } | 
| 80 | 
+ | 
  | 
| 81 | 
+ | 
  OptionSectionParser::OptionSectionParser(ForceFieldOptions& options) : options_(options) { | 
| 82 | 
+ | 
    setSectionName("Options");         | 
| 83 | 
+ | 
  } | 
| 84 | 
  | 
   | 
| 85 | 
  | 
  void OptionSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ | 
| 86 | 
  | 
     | 
| 87 | 
  | 
    StringTokenizer tokenizer(line); | 
| 88 | 
  | 
     | 
| 89 | 
  | 
    if (tokenizer.countTokens() >= 2) { | 
| 90 | 
< | 
      std::string OptionName = tokenizer.nextToken(); | 
| 91 | 
< | 
      std::string OptionValue = tokenizer.nextToken(); | 
| 90 | 
> | 
      std::string optionName = tokenizer.nextToken(); | 
| 91 | 
> | 
      std::string optionValue = tokenizer.nextToken(); | 
| 92 | 
  | 
       | 
| 93 | 
+ | 
      options_.setData(optionName, optionValue); | 
| 94 | 
  | 
       | 
| 73 | 
– | 
       | 
| 95 | 
  | 
    } else { | 
| 96 | 
  | 
      sprintf(painCave.errMsg, "OptionSectionParser Error: Not enough tokens at line %d\n", | 
| 97 | 
  | 
              lineNo); | 
| 100 | 
  | 
    } | 
| 101 | 
  | 
     | 
| 102 | 
  | 
  } | 
| 82 | 
– | 
   | 
| 103 | 
  | 
 | 
| 104 | 
+ | 
  void OptionSectionParser::validateSection() { | 
| 105 | 
+ | 
    options_.validateOptions(); | 
| 106 | 
+ | 
  } | 
| 107 | 
+ | 
 | 
| 108 | 
  | 
} //end namespace oopse   |