Changes in src/Actions/MapOfActions.cpp [7230be:bd2390]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
r7230be rbd2390 31 31 #include <boost/optional.hpp> 32 32 #include <boost/program_options.hpp> 33 #include <boost/filesystem.hpp> 33 34 34 35 #include <iostream> … … 190 191 BV.zz = boost::lexical_cast<double>(components.at(5)); 191 192 v = boost::any(BoxValue(BV)); 193 } 194 195 void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int) 196 { 197 boost::filesystem::path filename; 198 std::vector<std::string> components; 199 200 std::cout << "boost::filesystem::path validator used." << std::endl; 201 202 // split comma-separated values 203 if (values.size() != 1) { 204 cerr << "Not one file but " << components.size() << " given " << endl; 205 throw boost::program_options::validation_error("Unequal to one file given"); 206 } 207 filename = values.at(0); 208 v = boost::any(boost::filesystem::path(filename)); 192 209 } 193 210 … … 367 384 TypeMap["fill-void"] = &typeid(std::string); 368 385 TypeMap["fragment-mol"] = &typeid(std::string); 369 TypeMap["input"] = &typeid( std::string);386 TypeMap["input"] = &typeid(boost::filesystem::path); 370 387 TypeMap["linear-interpolate"] = &typeid(std::string); 371 388 TypeMap["molecular-volume"] = &typeid(molecule); … … 446 463 TypeEnumMap[&typeid(bool)] = Boolean; 447 464 TypeEnumMap[&typeid(int)] = Integer; 465 TypeEnumMap[&typeid(boost::filesystem::path)] = File; 448 466 TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers; 449 467 TypeEnumMap[&typeid(double)] = Double; … … 825 843 } 826 844 845 void MapOfActions::queryCurrentValue(const char * name, boost::filesystem::path&_T) 846 { 847 std::string tmp; 848 if (typeid( boost::filesystem::path ) == *TypeMap[name]) { 849 if (CurrentValue.find(name) == CurrentValue.end()) 850 throw MissingValueException(__FILE__, __LINE__); 851 std::istringstream stream(CurrentValue[name]); 852 CurrentValue.erase(name); 853 if (!stream.fail()) { 854 stream >> tmp >> ws; 855 _T = tmp; 856 } 857 } else 858 throw IllegalTypeException(__FILE__,__LINE__); 859 } 860 827 861 828 862 void MapOfActions::setCurrentValue(const char * name, class atom * &_T) … … 927 961 stream << (*iter)->getId() << " "; 928 962 } 963 CurrentValue[name] = stream.str(); 964 } else 965 throw IllegalTypeException(__FILE__,__LINE__); 966 } 967 968 void MapOfActions::setCurrentValue(const char * name, boost::filesystem::path &_T) 969 { 970 if (typeid( boost::filesystem::path ) == *TypeMap[name]) { 971 std::ostringstream stream; 972 stream << _T.string(); 929 973 CurrentValue[name] = stream.str(); 930 974 } else … … 1051 1095 ; 1052 1096 break; 1097 case File: 1098 ListRunner->second->add_options() 1099 (getKeyAndShortForm(*OptionRunner).c_str(), 1100 po::value< boost::filesystem::path >(), 1101 getDescription(*OptionRunner).c_str()) 1102 ; 1103 break; 1053 1104 case Integer: 1054 1105 ListRunner->second->add_options()
Note:
See TracChangeset
for help on using the changeset viewer.