mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-15 16:51:54 +00:00
FS-2746 --resolve large xmlrpc update thanks garmt
This commit is contained in:
+208
-24
@@ -64,6 +64,22 @@ public:
|
||||
this->valueP = xmlrpc_datetime_new_sec(&env.env_c, cppvalue);
|
||||
throwIfError(env);
|
||||
}
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
cDatetimeValueWrapper(struct timeval const cppvalue) {
|
||||
env_wrap env;
|
||||
|
||||
this->valueP = xmlrpc_datetime_new_timeval(&env.env_c, cppvalue);
|
||||
throwIfError(env);
|
||||
}
|
||||
#endif
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
cDatetimeValueWrapper(struct timespec const cppvalue) {
|
||||
env_wrap env;
|
||||
|
||||
this->valueP = xmlrpc_datetime_new_timespec(&env.env_c, cppvalue);
|
||||
throwIfError(env);
|
||||
}
|
||||
#endif
|
||||
~cDatetimeValueWrapper() {
|
||||
xmlrpc_DECREF(this->valueP);
|
||||
}
|
||||
@@ -93,13 +109,13 @@ public:
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
value::value() {
|
||||
value::value() { // default constructor
|
||||
this->cValueP = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
value::value(xmlrpc_value * const valueP) { // default constructor
|
||||
value::value(xmlrpc_value * const valueP) {
|
||||
|
||||
this->instantiate(valueP);
|
||||
}
|
||||
@@ -135,7 +151,7 @@ value::~value() {
|
||||
bool
|
||||
value::isInstantiated() const {
|
||||
/*----------------------------------------------------------------------------
|
||||
Return whether the value is actually a value, as opposed to a placeholder
|
||||
Return whether the object is actually a value, as opposed to a placeholder
|
||||
variable waiting to be assigned a value.
|
||||
-----------------------------------------------------------------------------*/
|
||||
return (this->cValueP != NULL);
|
||||
@@ -143,6 +159,20 @@ value::isInstantiated() const {
|
||||
|
||||
|
||||
|
||||
void
|
||||
value::validateInstantiated() const { // private
|
||||
/*----------------------------------------------------------------------------
|
||||
Throw an exception if the object is just a placeholder, rather than an
|
||||
actual XML-RPC value.
|
||||
-----------------------------------------------------------------------------*/
|
||||
if (!this->cValueP)
|
||||
throw(error("Reference to xmlrpc_c::value that has not been "
|
||||
"instantiated. (xmlrpc_c::value::isInstantiated may be "
|
||||
"useful in diagnosing)"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
value::instantiate(xmlrpc_value * const valueP) {
|
||||
|
||||
@@ -168,6 +198,8 @@ value::appendToCArray(xmlrpc_value * const arrayP) const {
|
||||
/*----------------------------------------------------------------------------
|
||||
Append this value to the C array 'arrayP'.
|
||||
----------------------------------------------------------------------------*/
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
|
||||
xmlrpc_array_append_item(&env.env_c, arrayP, this->cValueP);
|
||||
@@ -183,6 +215,8 @@ value::addToCStruct(xmlrpc_value * const structP,
|
||||
/*----------------------------------------------------------------------------
|
||||
Add this value to the C array 'arrayP' with key 'key'.
|
||||
----------------------------------------------------------------------------*/
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
|
||||
xmlrpc_struct_set_value_n(&env.env_c, structP,
|
||||
@@ -196,8 +230,11 @@ value::addToCStruct(xmlrpc_value * const structP,
|
||||
|
||||
value::type_t
|
||||
value::type() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
/* You'd think we could just cast from xmlrpc_type to
|
||||
value:type_t, but Gcc warns if we do that. So we have to do this
|
||||
value::type_t, but Gcc warns if we do that. So we have to do this
|
||||
even messier union nonsense.
|
||||
*/
|
||||
union {
|
||||
@@ -212,6 +249,15 @@ value::type() const {
|
||||
|
||||
|
||||
|
||||
ostream& operator<<(ostream& out, value::type_t const& type) {
|
||||
|
||||
string typeName;
|
||||
|
||||
return out << string(xmlrpc_type_name((xmlrpc_type)type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_int::value_int(int const cppvalue) {
|
||||
|
||||
class cWrapper {
|
||||
@@ -249,6 +295,8 @@ value_int::value_int(xmlrpc_c::value const baseValue) {
|
||||
|
||||
value_int::operator int() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
int retval;
|
||||
env_wrap env;
|
||||
|
||||
@@ -260,6 +308,14 @@ value_int::operator int() const {
|
||||
|
||||
|
||||
|
||||
int
|
||||
value_int::cvalue() const {
|
||||
|
||||
return static_cast<int>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_double::value_double(double const cppvalue) {
|
||||
|
||||
class cWrapper {
|
||||
@@ -295,6 +351,8 @@ value_double::value_double(xmlrpc_c::value const baseValue) {
|
||||
|
||||
value_double::operator double() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
double retval;
|
||||
|
||||
env_wrap env;
|
||||
@@ -307,6 +365,14 @@ value_double::operator double() const {
|
||||
|
||||
|
||||
|
||||
double
|
||||
value_double::cvalue() const {
|
||||
|
||||
return static_cast<double>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_boolean::value_boolean(bool const cppvalue) {
|
||||
|
||||
class cWrapper {
|
||||
@@ -331,8 +397,21 @@ value_boolean::value_boolean(bool const cppvalue) {
|
||||
|
||||
|
||||
|
||||
value_boolean::value_boolean(xmlrpc_c::value const baseValue) {
|
||||
|
||||
if (baseValue.type() != xmlrpc_c::value::TYPE_BOOLEAN)
|
||||
throw(error("Not boolean type. See type() method"));
|
||||
else {
|
||||
this->instantiate(baseValue.cValueP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_boolean::operator bool() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
xmlrpc_bool retval;
|
||||
|
||||
env_wrap env;
|
||||
@@ -345,13 +424,10 @@ value_boolean::operator bool() const {
|
||||
|
||||
|
||||
|
||||
value_boolean::value_boolean(xmlrpc_c::value const baseValue) {
|
||||
bool
|
||||
value_boolean::cvalue() const {
|
||||
|
||||
if (baseValue.type() != xmlrpc_c::value::TYPE_BOOLEAN)
|
||||
throw(error("Not boolean type. See type() method"));
|
||||
else {
|
||||
this->instantiate(baseValue.cValueP);
|
||||
}
|
||||
return static_cast<bool>(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +469,7 @@ value_datetime::value_datetime(time_t const cppvalue) {
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
value_datetime::value_datetime(struct timeval const& cppvalue) {
|
||||
|
||||
cDatetimeValueWrapper wrapper(cppvalue.tv_sec);
|
||||
cDatetimeValueWrapper wrapper(cppvalue);
|
||||
|
||||
this->instantiate(wrapper.valueP);
|
||||
}
|
||||
@@ -404,7 +480,7 @@ value_datetime::value_datetime(struct timeval const& cppvalue) {
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
value_datetime::value_datetime(struct timespec const& cppvalue) {
|
||||
|
||||
cDatetimeValueWrapper wrapper(cppvalue.tv_sec);
|
||||
cDatetimeValueWrapper wrapper(cppvalue);
|
||||
|
||||
this->instantiate(wrapper.valueP);
|
||||
}
|
||||
@@ -425,6 +501,8 @@ value_datetime::value_datetime(xmlrpc_c::value const baseValue) {
|
||||
|
||||
value_datetime::operator time_t() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
time_t retval;
|
||||
env_wrap env;
|
||||
|
||||
@@ -436,6 +514,50 @@ value_datetime::operator time_t() const {
|
||||
|
||||
|
||||
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
|
||||
value_datetime::operator timeval() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
struct timeval retval;
|
||||
env_wrap env;
|
||||
|
||||
xmlrpc_read_datetime_timeval(&env.env_c, this->cValueP, &retval);
|
||||
throwIfError(env);
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
|
||||
value_datetime::operator timespec() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
struct timespec retval;
|
||||
env_wrap env;
|
||||
|
||||
xmlrpc_read_datetime_timespec(&env.env_c, this->cValueP, &retval);
|
||||
throwIfError(env);
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
time_t
|
||||
value_datetime::cvalue() const {
|
||||
|
||||
return static_cast<time_t>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class cNewStringWrapper {
|
||||
public:
|
||||
xmlrpc_value * valueP;
|
||||
@@ -517,6 +639,8 @@ value_string::crlfValue() const {
|
||||
}
|
||||
};
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
cWrapper wrapper(this->cValueP);
|
||||
|
||||
return string(wrapper.str, wrapper.length);
|
||||
@@ -526,7 +650,7 @@ value_string::crlfValue() const {
|
||||
|
||||
value_string::operator string() const {
|
||||
|
||||
env_wrap env;
|
||||
this->validateInstantiated();
|
||||
|
||||
cStringWrapper adapter(this->cValueP);
|
||||
|
||||
@@ -535,6 +659,14 @@ value_string::operator string() const {
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
value_string::cvalue() const {
|
||||
|
||||
return static_cast<std::string>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_bytestring::value_bytestring(
|
||||
vector<unsigned char> const& cppvalue) {
|
||||
|
||||
@@ -561,6 +693,17 @@ value_bytestring::value_bytestring(
|
||||
|
||||
|
||||
|
||||
value_bytestring::value_bytestring(xmlrpc_c::value const baseValue) {
|
||||
|
||||
if (baseValue.type() != xmlrpc_c::value::TYPE_BYTESTRING)
|
||||
throw(error("Not byte string type. See type() method"));
|
||||
else {
|
||||
this->instantiate(baseValue.cValueP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
vector<unsigned char>
|
||||
value_bytestring::vectorUcharValue() const {
|
||||
|
||||
@@ -580,6 +723,8 @@ value_bytestring::vectorUcharValue() const {
|
||||
}
|
||||
};
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
cWrapper wrapper(this->cValueP);
|
||||
|
||||
return vector<unsigned char>(&wrapper.contents[0],
|
||||
@@ -588,9 +733,19 @@ value_bytestring::vectorUcharValue() const {
|
||||
|
||||
|
||||
|
||||
vector<unsigned char>
|
||||
value_bytestring::cvalue() const {
|
||||
|
||||
return this->vectorUcharValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
value_bytestring::length() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
size_t length;
|
||||
|
||||
@@ -602,17 +757,6 @@ value_bytestring::length() const {
|
||||
|
||||
|
||||
|
||||
value_bytestring::value_bytestring(xmlrpc_c::value const baseValue) {
|
||||
|
||||
if (baseValue.type() != xmlrpc_c::value::TYPE_BYTESTRING)
|
||||
throw(error("Not byte string type. See type() method"));
|
||||
else {
|
||||
this->instantiate(baseValue.cValueP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_array::value_array(vector<xmlrpc_c::value> const& cppvalue) {
|
||||
|
||||
class cWrapper {
|
||||
@@ -655,6 +799,8 @@ value_array::value_array(xmlrpc_c::value const baseValue) {
|
||||
vector<xmlrpc_c::value>
|
||||
value_array::vectorValueValue() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
|
||||
unsigned int arraySize;
|
||||
@@ -693,9 +839,19 @@ value_array::vectorValueValue() const {
|
||||
|
||||
|
||||
|
||||
vector<xmlrpc_c::value>
|
||||
value_array::cvalue() const {
|
||||
|
||||
return this->vectorValueValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
value_array::size() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
unsigned int arraySize;
|
||||
|
||||
@@ -752,6 +908,8 @@ value_struct::value_struct(xmlrpc_c::value const baseValue) {
|
||||
|
||||
value_struct::operator map<string, xmlrpc_c::value>() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
env_wrap env;
|
||||
unsigned int structSize;
|
||||
|
||||
@@ -796,6 +954,14 @@ value_struct::operator map<string, xmlrpc_c::value>() const {
|
||||
|
||||
|
||||
|
||||
map<string, xmlrpc_c::value>
|
||||
value_struct::cvalue() const {
|
||||
|
||||
return static_cast<map<string, xmlrpc_c::value> >(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_nil::value_nil() {
|
||||
|
||||
class cWrapper {
|
||||
@@ -831,6 +997,14 @@ value_nil::value_nil(xmlrpc_c::value const baseValue) {
|
||||
|
||||
|
||||
|
||||
void *
|
||||
value_nil::cvalue() const {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
value_i8::value_i8(xmlrpc_int64 const cppvalue) {
|
||||
|
||||
class cWrapper {
|
||||
@@ -868,6 +1042,8 @@ value_i8::value_i8(xmlrpc_c::value const baseValue) {
|
||||
|
||||
value_i8::operator xmlrpc_int64() const {
|
||||
|
||||
this->validateInstantiated();
|
||||
|
||||
xmlrpc_int64 retval;
|
||||
env_wrap env;
|
||||
|
||||
@@ -879,4 +1055,12 @@ value_i8::operator xmlrpc_int64() const {
|
||||
|
||||
|
||||
|
||||
xmlrpc_int64
|
||||
value_i8::cvalue() const {
|
||||
|
||||
return static_cast<xmlrpc_int64>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user