/usr/include/xmlrpc-c/base.hpp is in libxmlrpc-c++4-dev 1.16.33-3.1ubuntu5.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | #ifndef XMLRPC_BASE_HPP_INCLUDED
#define XMLRPC_BASE_HPP_INCLUDED
#include <xmlrpc-c/config.h>
#include <climits>
#include <cfloat>
#include <ctime>
#include <vector>
#include <map>
#include <string>
#if XMLRPC_HAVE_TIMEVAL
#include <sys/time.h>
#endif
#include <xmlrpc-c/base.h>
namespace xmlrpc_c {
class value {
// This is a handle. You don't want to create a pointer to this;
// it is in fact a pointer itself.
public:
value();
// This creates a placeholder. It can't be used for anything, but
// holds memory. instantiate() can turn it into a real object.
value(xmlrpc_c::value const &value); // copy constructor
~value();
enum type_t {
TYPE_INT = 0,
TYPE_BOOLEAN = 1,
TYPE_DOUBLE = 2,
TYPE_DATETIME = 3,
TYPE_STRING = 4,
TYPE_BYTESTRING = 5,
TYPE_ARRAY = 6,
TYPE_STRUCT = 7,
TYPE_C_PTR = 8,
TYPE_NIL = 9,
TYPE_I8 = 10,
TYPE_DEAD = 0xDEAD
};
type_t type() const;
xmlrpc_c::value&
operator=(xmlrpc_c::value const&);
bool
isInstantiated() const;
// The following are not meant to be public to users, but just to
// other Xmlrpc-c library modules. If we ever go to a pure C++
// implementation, not based on C xmlrpc_value objects, this shouldn't
// be necessary.
void
appendToCArray(xmlrpc_value * const arrayP) const;
void
addToCStruct(xmlrpc_value * const structP,
std::string const key) const;
xmlrpc_value *
cValue() const;
value(xmlrpc_value * const valueP);
void
instantiate(xmlrpc_value * const valueP);
// Works only on a placeholder object created by the no-argument
// constructor.
xmlrpc_value * cValueP;
// NULL means this is merely a placeholder object.
};
class value_int : public value {
public:
value_int(int const cvalue);
value_int(xmlrpc_c::value const baseValue);
operator int() const;
};
class value_boolean : public value {
public:
value_boolean(bool const cvalue);
value_boolean(xmlrpc_c::value const baseValue);
operator bool() const;
};
class value_string : public value {
public:
enum nlCode {nlCode_all, nlCode_lf};
value_string(std::string const& cppvalue,
nlCode const nlCode);
value_string(std::string const& cppvalue);
value_string(xmlrpc_c::value const baseValue);
std::string
crlfValue() const;
operator std::string() const;
};
class value_double : public value {
public:
value_double(double const cvalue);
value_double(xmlrpc_c::value const baseValue);
operator double() const;
};
class value_datetime : public value {
public:
value_datetime(std::string const cvalue);
value_datetime(time_t const cvalue);
#if XMLRPC_HAVE_TIMEVAL
value_datetime(struct timeval const& cvalue);
operator timeval() const;
#endif
#if XMLRPC_HAVE_TIMESPEC
value_datetime(struct timespec const& cvalue);
operator timespec() const;
#endif
value_datetime(xmlrpc_c::value const baseValue);
operator time_t() const;
};
class value_bytestring : public value {
public:
value_bytestring(std::vector<unsigned char> const& cvalue);
value_bytestring(xmlrpc_c::value const baseValue);
// You can't cast to a vector because the compiler can't tell which
// constructor to use (complains about ambiguity). So we have this:
std::vector<unsigned char>
vectorUcharValue() const;
size_t
length() const;
};
class value_struct : public value {
public:
value_struct(std::map<std::string, xmlrpc_c::value> const& cvalue);
value_struct(xmlrpc_c::value const baseValue);
operator std::map<std::string, xmlrpc_c::value>() const;
};
class value_array : public value {
public:
value_array(std::vector<xmlrpc_c::value> const& cvalue);
value_array(xmlrpc_c::value const baseValue);
std::vector<xmlrpc_c::value>
vectorValueValue() const;
size_t
size() const;
};
class value_nil : public value {
public:
value_nil();
value_nil(xmlrpc_c::value const baseValue);
};
class value_i8 : public value {
public:
value_i8(xmlrpc_int64 const cvalue);
value_i8(xmlrpc_c::value const baseValue);
operator xmlrpc_int64() const;
};
class fault {
/*----------------------------------------------------------------------------
This is an XML-RPC fault.
This object is not intended to be used to represent a fault in the
execution of XML-RPC client/server software -- just a fault in an
XML-RPC RPC as described by the XML-RPC spec.
There is no way to represent "no fault" with this object. The object is
meaningful only in the context of some fault.
-----------------------------------------------------------------------------*/
public:
enum code_t {
CODE_UNSPECIFIED = 0,
CODE_INTERNAL = -500,
CODE_TYPE = -501,
CODE_INDEX = -502,
CODE_PARSE = -503,
CODE_NETWORK = -504,
CODE_TIMEOUT = -505,
CODE_NO_SUCH_METHOD = -506,
CODE_REQUEST_REFUSED = -507,
CODE_INTROSPECTION_DISABLED = -508,
CODE_LIMIT_EXCEEDED = -509,
CODE_INVALID_UTF8 = -510
};
fault();
fault(std::string const _faultString,
xmlrpc_c::fault::code_t const _faultCode
= xmlrpc_c::fault::CODE_UNSPECIFIED
);
xmlrpc_c::fault::code_t getCode() const;
std::string getDescription() const;
private:
bool valid;
xmlrpc_c::fault::code_t code;
std::string description;
};
class rpcOutcome {
/*----------------------------------------------------------------------------
The outcome of a validly executed RPC -- either an XML-RPC fault
or an XML-RPC value of the result.
-----------------------------------------------------------------------------*/
public:
rpcOutcome();
rpcOutcome(xmlrpc_c::value const result);
rpcOutcome(xmlrpc_c::fault const fault);
bool succeeded() const;
xmlrpc_c::fault getFault() const;
xmlrpc_c::value getResult() const;
private:
bool valid;
// This is false in a placeholder variable -- i.e. an object you
// create with the no-argument constructor, which is waiting to be
// assigned a value. When false, nothing below is valid.
bool _succeeded;
xmlrpc_c::value result; // valid if 'succeeded'
xmlrpc_c::fault fault; // valid if not 'succeeded'
};
class paramList {
/*----------------------------------------------------------------------------
A parameter list of an XML-RPC call.
-----------------------------------------------------------------------------*/
public:
paramList(unsigned int const paramCount = 0);
paramList&
add(xmlrpc_c::value const param);
paramList&
addx(xmlrpc_c::value const param);
unsigned int
size() const;
xmlrpc_c::value operator[](unsigned int const subscript) const;
int
getInt(unsigned int const paramNumber,
int const minimum = INT_MIN,
int const maximum = INT_MAX) const;
bool
getBoolean(unsigned int const paramNumber) const;
double
getDouble(unsigned int const paramNumber,
double const minimum = -DBL_MAX,
double const maximum = DBL_MAX) const;
enum timeConstraint {TC_ANY, TC_NO_PAST, TC_NO_FUTURE};
time_t
getDatetime_sec(unsigned int const paramNumber,
timeConstraint const constraint
= paramList::TC_ANY) const;
std::string
getString(unsigned int const paramNumber) const;
std::vector<unsigned char>
getBytestring(unsigned int const paramNumber) const;
std::vector<xmlrpc_c::value>
getArray(unsigned int const paramNumber,
unsigned int const minSize = 0,
unsigned int const maxSize = UINT_MAX) const;
std::map<std::string, xmlrpc_c::value>
getStruct(unsigned int const paramNumber) const;
void
getNil(unsigned int const paramNumber) const;
xmlrpc_int64
getI8(unsigned int const paramNumber,
xmlrpc_int64 const minimum = XMLRPC_INT64_MIN,
xmlrpc_int64 const maximum = XMLRPC_INT64_MAX) const;
void
verifyEnd(unsigned int const paramNumber) const;
private:
std::vector<xmlrpc_c::value> paramVector;
};
} // namespace
#endif
|