40 #include "hex-arrays.h" 41 #include "hex-vec3d.h" 93 inline std::ostream & operator << (std::ostream & os, std::pair<geom::vec3d,geom::vec3d>
const & p)
95 os << p.first <<
" " << p.second;
102 inline std::istream &
operator >> (std::istream & is, std::pair<geom::vec3d,geom::vec3d> & p)
117 while (std::getline(is, token,
','))
119 std::size_t idx, idx1, idx2;
120 int value = std::stoi(token, &idx);
123 if (idx == token.size())
131 std::size_t pos = token.find(
'-', 1);
132 if (pos == std::string::npos)
133 HexException(
"Failed to parse \"%s\"", token.c_str());
135 std::string str_a = token.substr(0, pos);
136 std::string str_b = token.substr(pos + 1);
137 int a = std::stoi(str_a, &idx1);
138 int b = std::stoi(str_b, &idx2);
139 if (idx1 != str_a.size() or idx2 != str_b.size())
140 HexException(
"Failed to parse \"%s\"", token.c_str());
142 iArray values = linspace(a, b, b - a + 1);
143 p.append(values.begin(), values.end());
157 while (not std::cin.eof())
179 template <
typename T> T
Conv 181 std::map<std::string,std::string>
const & dict,
182 std::string
const & keyword,
183 std::string
const & name
187 std::map<std::string,std::string>::const_iterator it = dict.find(keyword);
188 if (it == dict.end())
189 throw exception (
"ERROR: \"%s\" requires specifying the parameter \"--%s\"!\n", name.c_str(), keyword.c_str());
193 std::istringstream ss(it->second);
std::istream & operator>>(std::istream &is, std::pair< geom::vec3d, geom::vec3d > &p)
Definition: utils.h:102
std::vector< T > readStandardInput()
Definition: utils.h:152
std::string unit_name(eUnit u)
Energy unit name.
Definition: utils.cpp:101
eUnit
Energy units.
Definition: db.h:44
T Conv(std::map< std::string, std::string > const &dict, std::string const &keyword, std::string const &name)
Convert dictionary entry to a numeric type.
Definition: utils.h:180
lUnit
Output (length) units.
Definition: db.h:52
double change_units(eUnit A, eUnit B)
Energy units change.
Definition: utils.cpp:40