11 #include "boost/lexical_cast.hpp" 27 static char to_hex(
unsigned int i) {
return i + (i < 10u ?
'0' : (
'A' - 10)); }
76 }
else if (from ==
"false") {
87 to = from ?
"true" :
"false";
96 std::vector<std::string>
temp;
97 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}')) {
102 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
118 for (std::vector<bool>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
122 if (
b != from.begin()) {
136 std::string::const_iterator
b = from.begin(),
e = from.end();
138 if (*b !=
'+' && *b !=
'-') {
141 int sign = (*b ==
'+') ? +1 : -1;
145 if (!std::isdigit(*b)) {
148 to = 10 * to + (*b -
'0');
158 bool is_negative = (from < 0);
164 to =
static_cast<char>(from % 10 +
'0') + to;
167 to = (is_negative ?
'-' :
'+') + to;
177 std::string::const_iterator
b = from.begin(),
e = from.end();
179 if (*b !=
'+' && *b !=
'-') {
182 int sign = (*b ==
'+') ? +1 : -1;
186 if (!std::isdigit(*b)) {
189 to = 10 * to + (*b -
'0');
199 bool is_negative = (from < 0);
206 to =
static_cast<char>(from % 10 +
'0') + to;
209 to = (is_negative ?
'-' :
'+') + to;
219 std::vector<std::string>
temp;
220 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}')) {
225 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
242 for (std::vector<int>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
247 if (
b != from.begin()) {
262 std::vector<std::string>
temp;
263 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}')) {
268 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
285 for (std::vector<long long>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
289 if (
b != from.begin()) {
303 std::string::const_iterator
b = from.begin(),
e = from.end();
306 for (; b !=
e; ++
b) {
307 if (*b ==
'u' || *b ==
'U') {
310 if (!std::isdigit(*b)) {
313 to = 10u * to + (*b -
'0');
323 to =
static_cast<char>(from % 10 +
'0') + to;
335 std::string::const_iterator
b = from.begin(),
e = from.end();
337 for (; b !=
e; ++
b) {
338 if (*b ==
'u' || *b ==
'U') {
341 if (!std::isdigit(*b)) {
344 to = 10u * to + (*b -
'0');
354 to =
static_cast<char>(from % 10 +
'0') + to;
366 std::vector<std::string>
temp;
367 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}')) {
371 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
372 unsigned int val = 0;
388 for (std::vector<unsigned int>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
392 if (
b != from.begin()) {
407 std::vector<std::string>
temp;
408 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}')) {
412 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
413 unsigned long long val = 0ULL;
429 for (std::vector<unsigned long long>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
434 if (
b != from.begin()) {
450 to = std::numeric_limits<double>::quiet_NaN();
451 }
else if (from ==
"+inf" || from ==
"inf") {
454 }
else if (from ==
"-inf") {
462 to = boost::lexical_cast<
double>(from);
464 }
catch (boost::bad_lexical_cast&) {
474 std::ostringstream ost;
475 ost.precision(std::numeric_limits<double>::digits10 + 1);
488 std::vector<std::string>
temp;
489 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}'))
493 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
509 for (std::vector<double>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
513 if (
b != from.begin())
528 std::string::const_iterator
b = from.begin(),
e = from.end();
531 to.reserve((
e - b) / 2);
533 for (
bool even_pos =
true; b !=
e; ++
b, even_pos = !even_pos) {
540 c =
static_cast<char>(
from_hex(*b));
547 c =
static_cast<char>(c * 16 +
from_hex(*b));
567 std::istringstream is(from);
577 std::ostringstream ost;
604 std::vector<std::string>
strings;
607 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
608 stringItr != stringItrEnd;
616 std::vector<std::string>
strings;
617 for (std::vector<InputTag>::const_iterator tagItr = from.begin(), tagItrEnd = from.end(); tagItr != tagItrEnd;
619 strings.push_back(tagItr->encode());
644 std::vector<std::string>
strings;
647 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
648 stringItr != stringItrEnd;
656 std::vector<std::string>
strings;
657 for (std::vector<ESInputTag>::const_iterator tagItr = from.begin(), tagItrEnd = from.end(); tagItr != tagItrEnd;
659 strings.push_back(tagItr->encode());
671 assert(tokens.size() == 2 || tokens.size() == 3);
672 unsigned int run = strtoul(tokens[0].c_str(),
nullptr, 0);
673 unsigned int lumi = (tokens.size() == 2 ? 0 : strtoul(tokens[1].c_str(),
nullptr, 0));
674 unsigned long long event = strtoull(tokens[tokens.size() - 1].c_str(),
nullptr, 0);
681 std::ostringstream os;
683 os << from.
run() <<
":" << from.
event();
696 std::vector<std::string>
strings;
699 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
700 stringItr != stringItrEnd;
703 decode(eventID, *stringItr);
704 to.push_back(eventID);
710 std::vector<std::string>
strings;
711 for (std::vector<edm::EventID>::const_iterator idItr = from.begin(), idItrEnd = from.end(); idItr != idItrEnd;
714 encode(encodedEventID, *idItr);
715 strings.push_back(encodedEventID);
727 assert(tokens.size() == 2);
728 unsigned int run = strtoul(tokens[0].c_str(),
nullptr, 0);
729 unsigned int lumi = strtoul(tokens[1].c_str(),
nullptr, 0);
735 std::ostringstream os;
746 std::vector<std::string>
strings;
749 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
750 stringItr != stringItrEnd;
753 decode(lumiID, *stringItr);
754 to.push_back(lumiID);
760 std::vector<std::string>
strings;
761 for (std::vector<edm::LuminosityBlockID>::const_iterator idItr = from.begin(), idItrEnd = from.end();
765 encode(encodedLuminosityBlockID, *idItr);
766 strings.push_back(encodedLuminosityBlockID);
778 assert(tokens.size() == 2);
788 std::ostringstream os;
799 std::vector<std::string>
strings;
802 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
803 stringItr != stringItrEnd;
806 decode(lumiRange, *stringItr);
807 to.push_back(lumiRange);
813 std::vector<std::string>
strings;
814 for (std::vector<edm::LuminosityBlockRange>::const_iterator idItr = from.begin(), idItrEnd = from.end();
818 encode(encodedLuminosityBlockRange, *idItr);
819 strings.push_back(encodedLuminosityBlockRange);
831 assert(tokens.size() == 2);
836 assert((begin.luminosityBlock() == 0) == (end.
luminosityBlock() == 0));
843 std::ostringstream os;
861 std::vector<std::string>
strings;
864 for (std::vector<std::string>::const_iterator stringItr = strings.begin(), stringItrEnd = strings.end();
865 stringItr != stringItrEnd;
868 decode(eventRange, *stringItr);
869 to.push_back(eventRange);
875 std::vector<std::string>
strings;
876 for (std::vector<edm::EventRange>::const_iterator idItr = from.begin(), idItrEnd = from.end(); idItr != idItrEnd;
879 encode(encodedEventRange, *idItr);
880 strings.push_back(encodedEventRange);
889 std::string::const_iterator
b = from.begin(),
e = from.end();
891 enum escape_state {
NONE, BACKSLASH, HEX, HEX1, OCT1, OCT2 };
893 escape_state state =
NONE;
896 for (; b !=
e; ++
b) {
999 throw std::logic_error(
"can't happen");
1013 std::vector<std::string>
temp;
1014 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}'))
1018 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
1023 }
else if (!
decode(val, *
b)) {
1038 for (std::vector<std::string>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
1042 }
else if (!
encode(converted, *
b)) {
1046 if (
b != from.begin())
1076 std::vector<std::string>
temp;
1077 if (!
split(std::back_inserter(temp), from,
'{',
',',
'}'))
1081 for (std::vector<std::string>::const_iterator
b = temp.begin(),
e = temp.end();
b !=
e; ++
b) {
1098 for (std::vector<ParameterSet>::const_iterator
b = from.begin(),
e = from.end();
b !=
e; ++
b) {
1102 if (
b != from.begin()) {
EventNumber_t event() const
std::string toString() const
static char to_hex(unsigned int i)
bool encode(std::string &, bool)
RunNumber_t startRun() const
LuminosityBlockNumber_t luminosityBlock() const
LuminosityBlockNumber_t startLumi() const
static unsigned int from_hex(char c)
RunNumber_t endRun() const
EventNumber_t endEvent() const
bool decode(bool &, std::string const &)
bool split(OutIter result, std::string const &string_to_split, char first, char sep, char last)
RunNumber_t startRun() const
static void append_hex_rep(std::string &s, unsigned int c)
LuminosityBlockNumber_t endLumi() const
EventNumber_t startEvent() const
LuminosityBlockNumber_t luminosityBlock() const
LuminosityBlockNumber_t startLumi() const
void readFromParameterSetBlob(std::istream &is)
RunNumber_t endRun() const
LuminosityBlockNumber_t endLumi() const
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator