Public Member Functions | |
template<typename T_VALUE> | |
ClientProperty (std::string &name, T_VALUE &value, std::string &type="", std::string &encoding="", std::string &charset="") | |
Standard constructor. | |
ClientProperty (bool dummy, std::string &name, std::string &type, std::string &encoding, std::string &charset) | |
Constructor called by SAX parser. | |
ClientProperty (std::string &name, char *value, std::string &type="") | |
Specialized ctor for literal data. | |
ClientProperty (std::string &name, std::vector< unsigned char > &value, std::string &type="") | |
Specialized ctor for blob data. | |
std::string & | getName () |
The unique key of the property. | |
std::string | getType () |
Get the data type of the property value. | |
std::string | getEncoding () |
Get the internally used encoding to transfer data to/from xmlBlaster. | |
std::string | getCharset () |
If value is of type "String" and base64 encoded you can specify a charset (like "UTF-8" or "windows-1252"). | |
void | setCharset (std::string &charset) |
Set a charset, needed only it not "UTF-8" (default). | |
bool | isBase64 () |
Check if getValueRaw() is Base64 encoded. | |
std::string | getValueRaw () |
The raw, possibly still Base64 encoded value. | |
std::string | getStringValue () |
Convenience method for getValue(T_VALUE&). | |
std::vector< unsigned char > | getValue () |
Accessor for binary data (BLOB). | |
template<typename T_VALUE> | |
void | getValue (T_VALUE &value) |
Access with for supported data type. | |
void | setValue (std::string &value) |
Set the value, it will be encoded with the encoding specified in the constructor. | |
void | setValueRaw (std::string &value) |
Set the already correctly encoded value, used internally by SAX parser. | |
std::string | toXml (std::string extraOffset="", bool clearText=false, std::string tagName="clientProperty") |
Dump state of this object into a XML ASCII string. |
Examples:
<clientProperty name='transactionId' type='int'>120001</clientProperty> <clientProperty name='myKey'>Hello World</clientProperty> <clientProperty name='myBlob' type='byte[]' encoding='base64'>OKFKAL==</clientProperty>If the attribute
type
is missing we assume a 'String' property
For international character sets like "UTF-8" or "iso-8859-1" you need to force the type
to Constants::TYPE_BLOB
which will send the data base64 encoded.
The key name may only consist of US-ASCII characters
TestClientProperty
Definition at line 42 of file ClientProperty.h.
org::xmlBlaster::util::qos::ClientProperty::ClientProperty | ( | std::string & | name, | |
T_VALUE & | value, | |||
std::string & | type = "" , |
|||
std::string & | encoding = "" , |
|||
std::string & | charset = "" | |||
) |
Standard constructor.
A typical example is:
ClientProperty("myKey", "myValue");If you want to send a string in your own locale character set:
ClientProperty("myKey", "myValue", Constants::TYPE_STRING, Constants::ENCODING_BASE64, "windows-1252");
name | The unique property key in US-ASCII encoding (7-bit), UTF-8 should work as well A duplicate key will overwrite the old setting | |
value | Your data . The type (like "float") is guessed from T_VALUE NOTE: "vector<unsigned char>" "unsigned char*" are treated as BLOBs and will be transferred Base64 encoded. | |
type | The data type of the value, optional, e.g. Constants::TYPE_FLOAT ("float") | |
encoding | How the data is transferred, org::xmlBlaster::util::Constants::ENCODING_BASE64 or "" | |
charset | XmlBlaster expects all XML strings as UTF-8, however you can send your client properties in any other charset but you must then encode it with ENCODING_BASE64 and pass the charset used, for example "windows-1252". Please use the official IANA charset names. |
Definition at line 224 of file ClientProperty.h.
References org::xmlBlaster::util::Constants::ENCODING_BASE64, and org::xmlBlaster::util::lexical_cast().
org::xmlBlaster::util::qos::ClientProperty::ClientProperty | ( | bool | dummy, | |
std::string & | name, | |||
std::string & | type, | |||
std::string & | encoding, | |||
std::string & | charset | |||
) |
Constructor called by SAX parser.
Nothing is interpreted, all values are set as given
dummy | To distinguish the constructor from the others |
Definition at line 23 of file ClientProperty.cpp.
org::xmlBlaster::util::qos::ClientProperty::ClientProperty | ( | std::string & | name, | |
char * | value, | |||
std::string & | type = "" | |||
) |
Specialized ctor for literal data.
name | The unique property key in US-ASCII encoding (7-bit) | |
value | Your pointer to data | |
type | Optionally you can force another type than "String", for example Constant::TYPE_DOUBLE if the pointer contains such a number as a string representation. |
Definition at line 37 of file ClientProperty.cpp.
References org::xmlBlaster::util::Constants::ENCODING_BASE64.
org::xmlBlaster::util::qos::ClientProperty::ClientProperty | ( | std::string & | name, | |
std::vector< unsigned char > & | value, | |||
std::string & | type = "" | |||
) |
Specialized ctor for blob data.
name | The unique property key in US-ASCII encoding (7-bit) | |
value | Your BLOB data. | |
type | Optionally you can force another type than "byte[]", for example Constant::TYPE_DOUBLE if the vector contains such a number as a string representation. |
Definition at line 64 of file ClientProperty.cpp.
References org::xmlBlaster::util::Constants::ENCODING_BASE64, and org::xmlBlaster::util::Constants::TYPE_BLOB.
std::string & org::xmlBlaster::util::qos::ClientProperty::getName | ( | ) |
The unique key of the property.
Definition at line 104 of file ClientProperty.cpp.
Referenced by org::xmlBlaster::util::qos::address::AddressBase::addAttribute(), org::xmlBlaster::util::qos::QosData::addClientProperty(), org::xmlBlaster::util::qos::ConnectQosData::addClientProperty(), org::xmlBlaster::test::TestClientProperty::testClientProperty(), org::xmlBlaster::test::TestClientProperty::testQosData(), and toXml().
std::string org::xmlBlaster::util::qos::ClientProperty::getType | ( | ) |
Get the data type of the property value.
Definition at line 108 of file ClientProperty.cpp.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty(), org::xmlBlaster::test::TestClientProperty::testQosData(), and toXml().
std::string org::xmlBlaster::util::qos::ClientProperty::getEncoding | ( | ) |
Get the internally used encoding to transfer data to/from xmlBlaster.
Definition at line 116 of file ClientProperty.cpp.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty(), and toXml().
std::string org::xmlBlaster::util::qos::ClientProperty::getCharset | ( | ) |
If value is of type "String" and base64 encoded you can specify a charset (like "UTF-8" or "windows-1252").
Definition at line 120 of file ClientProperty.cpp.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty(), and toXml().
void org::xmlBlaster::util::qos::ClientProperty::setCharset | ( | std::string & | charset | ) |
Set a charset, needed only it not "UTF-8" (default).
charset | e.g. "windows-1252" |
Referenced by PublishDemo::initEnvironment(), and org::xmlBlaster::test::TestClientProperty::testClientProperty().
bool org::xmlBlaster::util::qos::ClientProperty::isBase64 | ( | ) |
Check if getValueRaw() is Base64 encoded.
Definition at line 124 of file ClientProperty.cpp.
References org::xmlBlaster::util::Constants::ENCODING_BASE64.
Referenced by getValue(), org::xmlBlaster::test::TestClientProperty::testClientProperty(), and org::xmlBlaster::test::TestClientProperty::testQosData().
std::string org::xmlBlaster::util::qos::ClientProperty::getValueRaw | ( | ) |
The raw, possibly still Base64 encoded value.
Definition at line 128 of file ClientProperty.cpp.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty(), and toXml().
std::string org::xmlBlaster::util::qos::ClientProperty::getStringValue | ( | ) |
Convenience method for getValue(T_VALUE&).
Definition at line 132 of file ClientProperty.cpp.
References org::xmlBlaster::util::Constants::ENCODING_BASE64.
Referenced by getValue(), org::xmlBlaster::test::TestClientProperty::testClientProperty(), org::xmlBlaster::test::TestClientProperty::testQosData(), and toXml().
std::vector< unsigned char > org::xmlBlaster::util::qos::ClientProperty::getValue | ( | ) |
Accessor for binary data (BLOB).
Definition at line 152 of file ClientProperty.cpp.
References org::xmlBlaster::util::Constants::ENCODING_BASE64.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty().
void org::xmlBlaster::util::qos::ClientProperty::getValue | ( | T_VALUE & | value | ) |
Access with for supported data type.
value | OUT parameter: The value in the desired data type. It is decoded (readable) in case it was base64 encoded |
Definition at line 294 of file ClientProperty.h.
References getStringValue(), isBase64(), org::xmlBlaster::util::lexical_cast(), and org::xmlBlaster::util::Constants::TYPE_BLOB.
void org::xmlBlaster::util::qos::ClientProperty::setValue | ( | std::string & | value | ) |
Set the value, it will be encoded with the encoding specified in the constructor.
void org::xmlBlaster::util::qos::ClientProperty::setValueRaw | ( | std::string & | value | ) |
Set the already correctly encoded value, used internally by SAX parser.
std::string org::xmlBlaster::util::qos::ClientProperty::toXml | ( | std::string | extraOffset = "" , |
|
bool | clearText = false , |
|||
std::string | tagName = "clientProperty" | |||
) |
Dump state of this object into a XML ASCII string.
extraOffset | indenting of tags for nice output | |
clearText | if true the base64 for properties are dumped decoded in plain text |
Definition at line 177 of file ClientProperty.cpp.
References getCharset(), getEncoding(), getName(), getStringValue(), getType(), getValueRaw(), and org::xmlBlaster::util::Constants::OFFSET.
Referenced by org::xmlBlaster::test::TestClientProperty::testClientProperty(), and org::xmlBlaster::test::TestClientProperty::testQosData().