stumpless 2.2.0
|
An element of structured data. More...
#include <Element.hpp>
Public Member Functions | |
Element (const char *name) | |
Creates a new Element with the given name. | |
Element (struct stumpless_element *element) | |
Creates an Element from a stumpless_element struct. | |
Element (const Element &element) | |
Creates an Element as a copy of another Element. | |
~Element (void) | |
Element & | AddParam (Param &new_param) |
Adds a Param to this Element. | |
Element & | AddParam (Param *new_param) |
Adds a Param to this Element. | |
Element & | AddParam (const char *param_name, const char *param_value) |
Creates a new param with the given name and value and adds it to this Element. | |
const char * | GetName (void) |
The name of this Element. | |
Param | GetParam (size_t index) |
Returns the param in the given element at the specified index. | |
Param | GetParam (const char *name) |
Returns the first param in this element with the given name. | |
size_t | GetParamCount (void) |
Returns the number of params in the given element. | |
size_t | GetParamIndex (const char *name) |
Gets the index of the first occurrence of a Param with the given name in this Element. | |
const char * | GetParamName (size_t index) |
Gets the name of the Param with the given index in this Element. | |
size_t | GetParamNameCount (const char *name) |
Gives the number of params with the given name found in this Element. | |
const char * | GetParamValue (size_t index) |
Returns the value of the param at the given index in this Element. | |
const char * | GetParamValue (const char *name) |
Returns the value of the first param with the given name in this Element. | |
bool | HasParam (const char *name) |
True if this Element has a Param with the given name, false otherwise. | |
Element & | SetName (const char *name) |
Set the name of this Element. | |
Element & | SetParam (size_t index, Param *param) |
Puts the param at the given index in this Element. | |
Element & | SetParamValue (size_t index, const char *value) |
Sets the value of the Param at the given index in this Element. | |
Element & | SetParamValue (const char *name, const char *value) |
Sets the value of the first Param with the given name in this element. | |
Public Attributes | |
struct stumpless_element * | equivalent |
An element of structured data.
Elements must have a name, but may not have any parameters. Their components must comply with RFC 5424.
stumpless::Element::Element | ( | const char * | name | ) |
Creates a new Element with the given name.
name | The name of the element. |
stumpless::Element::Element | ( | struct stumpless_element * | element | ) |
stumpless::Element::Element | ( | const Element & | element | ) |
stumpless::Element::~Element | ( | void | ) |
Element & stumpless::Element::AddParam | ( | const char * | param_name, |
const char * | param_value ) |
const char * stumpless::Element::GetName | ( | void | ) |
The name of this Element.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
Param stumpless::Element::GetParam | ( | const char * | name | ) |
Returns the first param in this element with the given name.
Note that an element may contain as many instances of a param as desired according to RFC 5424, and therefore there may be other Params with the same name. If you simply need a count of params with a given name, then you can use GetParamNameCount to find this. If you need a reference to any other params, then you must loop through all params in the element using GetParam with an index, checking each name.
Available since release v1.6.0.
name | The name of the param to get. |
Param stumpless::Element::GetParam | ( | size_t | index | ) |
Returns the param in the given element at the specified index.
Available since release v1.6.0.
index | The index of the param to get. |
size_t stumpless::Element::GetParamCount | ( | void | ) |
Returns the number of params in the given element.
Available since release v1.6.0.
size_t stumpless::Element::GetParamIndex | ( | const char * | name | ) |
Gets the index of the first occurrence of a Param with the given name in this Element.
Note that an element may contain as many instances of a param as desired according to RFC 5424, and therefore there may be other Params that this function does not recognize. If you simply need a count of params with a given name, then you can use GetParamNameCount to find this. If you need a reference to any other params, then you must loop through all params in the element using GetParam with an index, checking each name.
Available since release v1.6.0.
name | The name of the Param to search for. |
const char * stumpless::Element::GetParamName | ( | size_t | index | ) |
Gets the name of the Param with the given index in this Element.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
index | The index of the param to get the name of. |
size_t stumpless::Element::GetParamNameCount | ( | const char * | name | ) |
Gives the number of params with the given name found in this Element.
If you need to get an actual reference to any of these params beyond the first one, then you will need to loop through all params in the element using GetParam with an index, checking each name.
Available since release v1.6.0.
name | The name of the Param to count. |
const char * stumpless::Element::GetParamValue | ( | const char * | name | ) |
Returns the value of the first param with the given name in this Element.
If you need to get the value of a param with the given name beyond the first one, then you will need to loop through all params in the element using GetParam with an index, checking each name. The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
name | The name of the Param to get the value of. |
const char * stumpless::Element::GetParamValue | ( | size_t | index | ) |
Returns the value of the param at the given index in this Element.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. In versions prior to v2.0.0, the returned pointer was to the internal buffer was not to be modified by the caller. This behavior changed in v2.0.0 in order to avoid thread safety issues. Available since release v1.6.0.
index | The index of the Param to get the value of. |
bool stumpless::Element::HasParam | ( | const char * | name | ) |
Element & stumpless::Element::SetName | ( | const char * | name | ) |
Puts the param at the given index in this Element.
The parameter previously at this position will be removed from the element, but it is NOT destroyed by this call. Callers must clean up this param separately.
A param cannot be set at an index position that does not already hold a Param. If this is attempted, then a StumplessIndexOutOfBounds exception is raised.
Available since release v1.6.0.
Element & stumpless::Element::SetParamValue | ( | const char * | name, |
const char * | value ) |
Sets the value of the first Param with the given name in this element.
If a Param of the given name is not found in this Element, one is created with the supplied name and value and added to the end of this Element.
If you need to set the value of a param with this name other than the first one, then you will need to loop through the params using GetParam with an index to find the params you want and then set the value using SetValue on the result.
Available since release v1.6.0.
name | The name of the Param to set the Value of. |
value | The new value of the Param with the given name. |
Element & stumpless::Element::SetParamValue | ( | size_t | index, |
const char * | value ) |
struct stumpless_element* stumpless::Element::equivalent |