16 static const char VALUE_TAG[] =
"<value>";
17 static const char VALUE_ETAG[] =
"</value>";
19 static const char BOOLEAN_TAG[] =
"<boolean>";
20 static const char BOOLEAN_ETAG[] =
"</boolean>";
21 static const char DOUBLE_TAG[] =
"<double>";
22 static const char DOUBLE_ETAG[] =
"</double>";
23 static const char INT_TAG[] =
"<int>";
24 static const char I4_TAG[] =
"<i4>";
25 static const char I4_ETAG[] =
"</i4>";
26 static const char STRING_TAG[] =
"<string>";
27 static const char DATETIME_TAG[] =
"<dateTime.iso8601>";
28 static const char DATETIME_ETAG[] =
"</dateTime.iso8601>";
29 static const char BASE64_TAG[] =
"<base64>";
30 static const char BASE64_ETAG[] =
"</base64>";
32 static const char ARRAY_TAG[] =
"<array>";
33 static const char DATA_TAG[] =
"<data>";
34 static const char DATA_ETAG[] =
"</data>";
35 static const char ARRAY_ETAG[] =
"</array>";
37 static const char STRUCT_TAG[] =
"<struct>";
38 static const char MEMBER_TAG[] =
"<member>";
39 static const char NAME_TAG[] =
"<name>";
40 static const char NAME_ETAG[] =
"</name>";
41 static const char MEMBER_ETAG[] =
"</member>";
42 static const char STRUCT_ETAG[] =
"</struct>";
74 default:
_value.asBinary = 0;
break;
82 else if (
int(
_value.asArray->size() ) <
size )
124 default:
_value.asBinary = 0;
break;
131 static bool tmEq(
struct tm
const& t1,
struct tm
const& t2 ) {
132 return t1.tm_sec == t2.tm_sec && t1.tm_min == t2.tm_min && t1.tm_hour == t2.tm_hour &&
133 t1.tm_mday == t1.tm_mday && t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year;
137 if (
_type != other._type )
return false;
142 return ( !
_value.asBool && !other._value.asBool ) ||
143 (
_value.asBool && other._value.asBool );
154 if (
_value.asStruct->size() != other._value.asStruct->size() )
return false;
156 ValueStruct::const_iterator it1 =
_value.asStruct->begin();
157 ValueStruct::const_iterator it2 = other._value.asStruct->begin();
158 while ( it1 !=
_value.asStruct->end() )
162 if ( !( v1 == v2 ) )
return false;
174 return !( *
this == other );
199 int savedOffset = *offset;
205 int afterValueOffset = *offset;
208 if ( typeTag == BOOLEAN_TAG ) result =
boolFromXml( valueXml, offset );
209 else if ( typeTag == I4_TAG || typeTag == INT_TAG )
211 else if ( typeTag == DOUBLE_TAG ) result =
doubleFromXml( valueXml, offset );
212 else if ( typeTag.empty() || typeTag == STRING_TAG )
214 else if ( typeTag == DATETIME_TAG ) result =
timeFromXml( valueXml, offset );
215 else if ( typeTag == BASE64_TAG ) result =
binaryFromXml( valueXml, offset );
216 else if ( typeTag == ARRAY_TAG ) result =
arrayFromXml( valueXml, offset );
217 else if ( typeTag == STRUCT_TAG ) result =
structFromXml( valueXml, offset );
219 else if ( typeTag == VALUE_ETAG )
221 *offset = afterValueOffset;
228 *offset = savedOffset;
247 return std::string();
252 const char* valueStart = valueXml.c_str() + *offset;
254 long ivalue = strtol( valueStart, &valueEnd, 10 );
255 if ( valueEnd == valueStart || ( ivalue != 0 && ivalue != 1 ) )
return false;
258 _value.asBool = ( ivalue == 1 );
259 *offset += int( valueEnd - valueStart );
264 std::string xml = VALUE_TAG;
266 xml += (
_value.asBool ?
"1" :
"0" );
274 const char* valueStart = valueXml.c_str() + *offset;
276 long ivalue = strtol( valueStart, &valueEnd, 10 );
277 if ( valueEnd == valueStart )
return false;
280 _value.asInt = int( ivalue );
281 *offset += int( valueEnd - valueStart );
287 snprintf( buf,
sizeof( buf ) - 1,
"%d",
_value.asInt );
288 buf[
sizeof( buf ) - 1] = 0;
289 std::string xml = VALUE_TAG;
299 const char* valueStart = valueXml.c_str() + *offset;
301 double dvalue = strtod( valueStart, &valueEnd );
302 if ( valueEnd == valueStart )
return false;
306 *offset += int( valueEnd - valueStart );
313 buf[
sizeof( buf ) - 1] = 0;
315 std::string xml = VALUE_TAG;
325 size_t valueEnd = valueXml.find(
'<', *offset );
326 if ( valueEnd == std::string::npos )
return false;
329 _value.asString =
new std::string(
331 *offset += int(
_value.asString->length() );
336 std::string xml = VALUE_TAG;
346 size_t valueEnd = valueXml.find(
'<', *offset );
347 if ( valueEnd == std::string::npos )
return false;
349 std::string stime = valueXml.substr( *offset, valueEnd - *offset );
352 if ( sscanf( stime.c_str(),
"%4d%2d%2dT%2d:%2d:%2d", &
t.tm_year, &
t.tm_mon, &
t.tm_mday,
353 &
t.tm_hour, &
t.tm_min, &
t.tm_sec ) != 6 )
358 _value.asTime =
new struct tm(
t );
359 *offset += int( stime.length() );
366 snprintf( buf,
sizeof( buf ) - 1,
"%4d%02d%02dT%02d:%02d:%02d",
t->tm_year,
t->tm_mon,
367 t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec );
368 buf[
sizeof( buf ) - 1] = 0;
370 std::string xml = VALUE_TAG;
373 xml += DATETIME_ETAG;
380 size_t valueEnd = valueXml.find(
'<', *offset );
381 if ( valueEnd == std::string::npos )
return false;
384 std::string
asString = valueXml.substr( *offset, valueEnd - *offset );
391 std::back_insert_iterator<BinaryData> ins = std::back_inserter( *(
_value.asBinary ) );
394 *offset += int(
asString.length() );
400 std::vector<char> base64data;
403 std::back_insert_iterator<std::vector<char>> ins = std::back_inserter( base64data );
404 encoder.
put(
_value.asBinary->begin(),
_value.asBinary->end(), ins, iostatus,
408 std::string xml = VALUE_TAG;
410 xml.append( base64data.begin(), base64data.end() );
423 while (
v.fromXml( valueXml, offset ) )
_value.asArray->push_back(
v );
433 std::string xml = VALUE_TAG;
437 int s = int(
_value.asArray->size() );
438 for (
int i = 0; i <
s; ++i ) xml +=
_value.asArray->at( i ).toXml();
462 const std::pair<const std::string, XmlRpcValue> p( name, val );
463 _value.asStruct->insert( p );
473 std::string xml = VALUE_TAG;
476 ValueStruct::const_iterator it;
477 for ( it =
_value.asStruct->begin(); it !=
_value.asStruct->end(); ++it )
483 xml += it->second.toXml();
504 snprintf( buf,
sizeof( buf ) - 1,
"%4d%02d%02dT%02d:%02d:%02d",
t->tm_year,
t->tm_mon,
505 t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec );
506 buf[
sizeof( buf ) - 1] = 0;
512 std::ostreambuf_iterator<char> out( os );
514 encoder.
put(
_value.asBinary->begin(),
_value.asBinary->end(), out, iostatus,
519 int s = int(
_value.asArray->size() );
521 for (
int i = 0; i <
s; ++i )
523 if ( i > 0 ) os <<
',';
524 _value.asArray->at( i ).write( os );
531 ValueStruct::const_iterator it;
532 for ( it =
_value.asStruct->begin(); it !=
_value.asStruct->end(); ++it )
534 if ( it !=
_value.asStruct->begin() ) os <<
',';
535 os << it->first <<
':';
536 it->second.write( os );
552 return v.write( os );
**********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
std::ostream & operator<<(std::ostream &os, XmlRpc::XmlRpcValue &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
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
union XmlRpc::XmlRpcValue::@050363270230164230256327115202057142222030207371 _value
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
XmlRpcValue()
Constructors.
_II put(_II _First, _II _Last, _OI _To, _State &_St, _Endline _Endl) const
_II get(_II _First, _II _Last, _OI _To, _State &_St) const