6 #include <boost/tokenizer.hpp>
7 #include <boost/foreach.hpp>
8 #include <boost/lexical_cast.hpp>
9 #include <boost/algorithm/string/trim.hpp>
17 if (s_domid.find(
":") == std::string::npos) {
18 return boost::lexical_cast<uint32_t>(s_domid);
20 boost::char_separator<char>
const args_sep(
":");
21 boost::tokenizer<boost::char_separator<char> > tok(s_domid, args_sep);
26 BOOST_FOREACH(std::string byte, tok) {
27 if (byte.size() != 2) {
28 throw std::runtime_error(
"Error: malformed MAC address");
34 if (count == 0 && byte ==
"08") {
35 }
else if (count == 1 && byte ==
"00") {
37 throw std::runtime_error(
38 "Error: the provided MAC address is not a CLB MAC."
45 return std::strtol(ss.str().c_str(), 0, 16);
51 boost::char_separator<char>
const args_sep(
";");
52 boost::char_separator<char>
const fields_sep(
"=");
57 while (map.peek() != EOF) {
61 std::string::size_type
const pound = line.find(
'#');
63 if (pound != std::string::npos) {
64 line = line.substr(0, pound);
68 boost::tokenizer<boost::char_separator<char> > tok(line, args_sep);
70 BOOST_FOREACH(std::string s, tok) {
72 boost::tokenizer<boost::char_separator<char> > fields(s, fields_sep);
73 typedef boost::tokenizer<boost::char_separator<char> >::iterator Iter;
75 Iter it = fields.begin();
77 std::string s_domid = *it;
79 uint32_t
const domid =
getDomId(s_domid);
82 if (it != fields.end()) {
83 std::string
name = *it;
86 dom_map.insert(std::make_pair(domid, name));
88 throw std::runtime_error(
"Error: malformed assignment");
uint32_t getDomId(std::string const &s_domid)
static const boost::char_separator< char > fields_sep("=")
static const boost::char_separator< char > white_spaces("\t ")
then usage $script< input file >[option] nPossible options count
std::string trim(const std::string &buffer)
Trim string.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
then fatal The output file must have the wildcard in the name
dom_map_type load_dom_map(std::istream &map)
static const boost::char_separator< char > args_sep(";")