17 static const char VALUE_TAG[] =
"<value>";
18 static const char VALUE_ETAG[] =
"</value>";
20 static const char BOOLEAN_TAG[] =
"<boolean>";
21 static const char BOOLEAN_ETAG[] =
"</boolean>";
22 static const char DOUBLE_TAG[] =
"<double>";
23 static const char DOUBLE_ETAG[] =
"</double>";
24 static const char INT_TAG[] =
"<int>";
25 static const char I4_TAG[] =
"<i4>";
26 static const char I4_ETAG[] =
"</i4>";
27 static const char STRING_TAG[] =
"<string>";
28 static const char DATETIME_TAG[] =
"<dateTime.iso8601>";
29 static const char DATETIME_ETAG[] =
"</dateTime.iso8601>";
30 static const char BASE64_TAG[] =
"<base64>";
31 static const char BASE64_ETAG[] =
"</base64>";
33 static const char ARRAY_TAG[] =
"<array>";
34 static const char DATA_TAG[] =
"<data>";
35 static const char DATA_ETAG[] =
"</data>";
36 static const char ARRAY_ETAG[] =
"</array>";
38 static const char STRUCT_TAG[] =
"<struct>";
39 static const char MEMBER_TAG[] =
"<member>";
40 static const char NAME_TAG[] =
"<name>";
41 static const char NAME_ETAG[] =
"</name>";
42 static const char MEMBER_ETAG[] =
"</member>";
43 static const char STRUCT_ETAG[] =
"</struct>";
80 default:
_value.asBinary = 0;
break;
134 default:
_value.asBinary = 0;
break;
142 static bool tmEq(
struct tm
const& t1,
struct tm
const& t2) {
143 return t1.tm_sec == t2.tm_sec && t1.tm_min == t2.tm_min &&
144 t1.tm_hour == t2.tm_hour && t1.tm_mday == t1.tm_mday &&
145 t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year;
150 if (
_type != other._type)
155 (
_value.asBool && other._value.asBool);
166 if (
_value.asStruct->size() != other._value.asStruct->size())
169 ValueStruct::const_iterator it1=
_value.asStruct->begin();
170 ValueStruct::const_iterator it2=other._value.asStruct->begin();
171 while (it1 !=
_value.asStruct->end()) {
188 return !(*
this == other);
216 int savedOffset = *offset;
222 int afterValueOffset = *offset;
225 if (typeTag == BOOLEAN_TAG)
227 else if (typeTag == I4_TAG || typeTag == INT_TAG)
229 else if (typeTag == DOUBLE_TAG)
231 else if (typeTag.empty() || typeTag == STRING_TAG)
233 else if (typeTag == DATETIME_TAG)
235 else if (typeTag == BASE64_TAG)
237 else if (typeTag == ARRAY_TAG)
239 else if (typeTag == STRUCT_TAG)
242 else if (typeTag == VALUE_ETAG)
244 *offset = afterValueOffset;
251 *offset = savedOffset;
270 return std::string();
277 const char* valueStart = valueXml.c_str() + *offset;
279 long ivalue = strtol(valueStart, &valueEnd, 10);
280 if (valueEnd == valueStart || (ivalue != 0 && ivalue != 1))
284 _value.asBool = (ivalue == 1);
285 *offset += int(valueEnd - valueStart);
291 std::string xml = VALUE_TAG;
293 xml += (
_value.asBool ?
"1" :
"0");
302 const char* valueStart = valueXml.c_str() + *offset;
304 long ivalue = strtol(valueStart, &valueEnd, 10);
305 if (valueEnd == valueStart)
309 _value.asInt = int(ivalue);
310 *offset += int(valueEnd - valueStart);
317 snprintf(buf,
sizeof(buf)-1,
"%d",
_value.asInt);
318 buf[
sizeof(buf)-1] = 0;
319 std::string xml = VALUE_TAG;
330 const char* valueStart = valueXml.c_str() + *offset;
332 double dvalue = strtod(valueStart, &valueEnd);
333 if (valueEnd == valueStart)
338 *offset += int(valueEnd - valueStart);
346 buf[
sizeof(buf)-1] = 0;
348 std::string xml = VALUE_TAG;
359 size_t valueEnd = valueXml.find(
'<', *offset);
360 if (valueEnd == std::string::npos)
365 *offset += int(
_value.asString->length());
371 std::string xml = VALUE_TAG;
382 size_t valueEnd = valueXml.find(
'<', *offset);
383 if (valueEnd == std::string::npos)
386 std::string stime = valueXml.substr(*offset, valueEnd-*offset);
389 if (sscanf(stime.c_str(),
"%4d%2d%2dT%2d:%2d:%2d",&
t.tm_year,&
t.tm_mon,&
t.tm_mday,&
t.tm_hour,&
t.tm_min,&
t.tm_sec) != 6)
394 _value.asTime =
new struct tm(t);
395 *offset += int(stime.length());
403 snprintf(buf,
sizeof(buf)-1,
"%4d%02d%02dT%02d:%02d:%02d",
404 t->tm_year,
t->tm_mon,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
405 buf[
sizeof(buf)-1] = 0;
407 std::string xml = VALUE_TAG;
410 xml += DATETIME_ETAG;
419 size_t valueEnd = valueXml.find(
'<', *offset);
420 if (valueEnd == std::string::npos)
424 std::string
asString = valueXml.substr(*offset, valueEnd-*offset);
431 std::back_insert_iterator<BinaryData> ins = std::back_inserter(*(
_value.asBinary));
442 std::vector<char> base64data;
445 std::back_insert_iterator<std::vector<char> > ins = std::back_inserter(base64data);
449 std::string xml = VALUE_TAG;
451 xml.append(base64data.begin(), base64data.end());
467 while (
v.fromXml(valueXml, offset))
480 std::string xml = VALUE_TAG;
484 int s = int(
_value.asArray->size());
485 for (
int i=0; i<
s; ++i)
486 xml +=
_value.asArray->at(i).toXml();
506 if ( ! val.
valid()) {
510 const std::pair<const std::string, XmlRpcValue> p(name, val);
511 _value.asStruct->insert(p);
523 std::string xml = VALUE_TAG;
526 ValueStruct::const_iterator it;
527 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it) {
532 xml += it->second.toXml();
555 snprintf(buf,
sizeof(buf)-1,
"%4d%02d%02dT%02d:%02d:%02d",
556 t->tm_year,
t->tm_mon,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
557 buf[
sizeof(buf)-1] = 0;
564 std::ostreambuf_iterator<char> out(os);
571 int s = int(
_value.asArray->size());
573 for (
int i=0; i<
s; ++i)
575 if (i > 0) os <<
',';
576 _value.asArray->at(i).write(os);
584 ValueStruct::const_iterator it;
585 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it)
587 if (it!=
_value.asStruct->begin()) os <<
',';
588 os << it->first <<
':';
589 it->second.write(os);
std::ostream & operator<<(std::ostream &out, const SelectInfo &info)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
static std::string getNextTag(std::string const &xml, int *offset)
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
RPC method arguments and results are represented by Values.
std::vector< char > BinaryData
std::string intToXml() const
union XmlRpc::XmlRpcValue::@101 _value
std::string doubleToXml() const
bool timeFromXml(std::string const &valueXml, int *offset)
bool hasMember(const std::string &name) const
Check for the existence of a struct member by name.
bool operator==(XmlRpcValue const &other) const
bool binaryFromXml(std::string const &valueXml, int *offset)
int size() const
Return the size for string, base64, array, and struct values.
XmlRpcValue & operator=(XmlRpcValue const &rhs)
bool intFromXml(std::string const &valueXml, int *offset)
void assertArray(int size) const
std::string arrayToXml() const
std::string timeToXml() const
void assertTypeOrInvalid(Type t)
std::string structToXml() const
bool doubleFromXml(std::string const &valueXml, int *offset)
bool arrayFromXml(std::string const &valueXml, int *offset)
bool operator!=(XmlRpcValue const &other) const
bool fromXml(std::string const &valueXml, int *offset)
Decode xml. Destroys any existing value.
bool structFromXml(std::string const &valueXml, int *offset)
std::string binaryToXml() const
static std::string _doubleFormat
std::map< std::string, XmlRpcValue > ValueStruct
std::string boolToXml() const
static std::string const & getDoubleFormat()
Return the format used to write double values.
std::vector< XmlRpcValue > ValueArray
bool stringFromXml(std::string const &valueXml, int *offset)
std::ostream & write(std::ostream &os) const
Write the value (no xml encoding)
bool valid() const
Return true if the value has been set to something.
bool boolFromXml(std::string const &valueXml, int *offset)
std::string toXml() const
Encode the Value in xml.
std::string stringToXml() const
_II put(_II _First, _II _Last, _OI _To, _State &_St, _Endline _Endl) const
_II get(_II _First, _II _Last, _OI _To, _State &_St) const