ulxmlrpcpp implements all basic variable types from XML-RPC as classes
which are derived from a common type
Used for the boolean values
Directly corresponds to the C++ type bool.
Intended for signed integer values that need at most 32bit to store. The C++ type is system dependent and usually an int.
The type of choice for floating point numbers. The range is system
dependent but usually around +-1.8E308. The default format for transportation is
using only +, -, digits and the decimal point. This leads to large strings for huge
values with no actual precision in most of the digits. If you are sure there are
no compatibility problems on the other side of your connection you can switch to
scientific mode which uses a shorter format with mantissa and exponent like
1.23E-456. This mode is enabled with a call to
Take this type to pass messages.
|There is a pitfall|
Since there is no commeon census how characters have to be interpreted and
every system uses its own encoding. For that reason ulxmlrpcpp (and
Due to this all you have to take care on how to move your strings into
String type as you must know your encoding when you
have characters beyond the ASCII range. If you have
iconv installed on your system you
may simply convert from your encoding to UTF-8 with
encodingToUtf8("your-string", "encoding-name"). ulxmlrpcpp
contains some more helper functions to cover the most common conversions
See Section 1.15, “Worth to Know About UNICODE” for more about this topic.
There is no limitation in the length of the strings nor is there something like a termination character ('\0' in C).
This type is similar to
String but is intended
for binary data. Since XML has some limitations in using characters such binary
data should be converted for transportation, in this case
For the user this is transparent and you simply store/retrieve your values and the library does the rest.
This type is also similar to
String but is intended
for time values according to the
XML-RPC uses only a small subset of this specification. Basically
only the 17 characters you need to express a complete timestamp like
"20061002T17:26:00" but no details like partial dates, milliseconds or timezones.
This is not really a data type but a possiblity to collect variables. Unlike
arrays in many other programming languages an
may contain different data types. You access the members by their index.
Similar to the
Array type this is also a
collection of variables.
The difference is that you don't get access by an index
but by an identifier. So this is like an associative array or a map in C++.
For convenience reasons there is also the possibility to use streaming-like
methods to add parameters to
Arrays. This works similar to the way you would output
std::cout. To avoid abiguities it is by default not
possible to add intrinsic values like int or double.
Double if possible. If you really want to handle the
built-in types add the following line before the ulxmlrpcpp
headers in your sources:
Handling the data types might look like this:
Array arr; arr.addItem(Integer(1)); arr.addItem(String("My String in the array")); arr.addItem(Base64("base64-encoded string")); Integer xi = arr.getItem(0); int i = xi.getInteger(); String xs = arr.getItem(1); string s = xs.getString(); Struct st; st.addMember("first member", Double(3.1415)); st.addMember("second member", Boolean(true)); st << make_member("ima_wstring", String(L"wstring")) << make_member("ima_double", Double(1.0)) << make_member("ima_bool", Boolean(true)); Double d = st.getMember("first member");
Access the array, convert to native data type.
Get a value from the
|In case you should wonder why it is rather complicated to assign values to these types:
I did not implement implicit type conversion because I think it leads to subtle errors.
The compiler might choose to convert in a totally different way than you might
it should happen. For the same reason there are no overloaded methods like