A class for storage of attribute values. More...
#include <MessageAttributes.h>
Public Member Functions | |
MessageAttributes () | |
void | set (const std::string &key, const std::string &value) |
void | add (const std::string &key, const std::string &value) |
void | removeAll (const std::string &key) |
void | remove (const std::string &key, const std::string &value) |
int | count (const std::string &key) const |
const std::string & | get (const std::string &key) const |
AttributeIterator | getAll (const std::string &key) const |
AttributeIterator | getAll (void) const |
Protected Attributes | |
AttrMap | attributes_ |
A class for storage of attribute values.
This class is used to store attributes of messages. All attribute keys and their corresponding values are stored as strings. Any key or value that is not a string must thus be represented as a string during storage. Furthermore, an attribute is usually a key-value pair with a unique key, but there may also be multiple such pairs with equal keys.
The key of an attribute is composed by the name of the Message Chain Component (MCC) which produce it and the name of the attribute itself with a colon (:) in between, i.e. MCC_Name:Attribute_Name. For example, the key of the "Content-Length" attribute of the HTTP MCC is thus "HTTP:Content-Length".
There are also "global attributes", which may be produced by different MCCs depending on the configuration. The keys of such attributes are NOT prefixed by the name of the producing MCC. Before any new global attribute is introduced, it must be agreed upon by the core development team and added below. The global attributes decided so far are:
Request-URI
Identifies the service to which the message shall be sent. This attribute is produced by e.g. the HTTP MCC and used by the plexer for routing the message to the appropriate service. Arc::MessageAttributes::MessageAttributes | ( | ) |
The default constructor.
This is the default constructor of the MessageAttributes class. It constructs an empty object that initially contains no attributes.
void Arc::MessageAttributes::add | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Adds a value to an attribute.
This method adds a new value to an attribute. Any previous value will be preserved, i.e. the attribute may become multiple valued.
key | The key of the attribute. | |
value | The (new) value of the attribute. |
int Arc::MessageAttributes::count | ( | const std::string & | key | ) | const |
Returns the number of values of an attribute.
Returns the number of values of an attribute that matches a certain key.
key | The key of the attribute for which to count values. |
const std::string& Arc::MessageAttributes::get | ( | const std::string & | key | ) | const |
Returns the value of a single-valued attribute.
This method returns the value of a single-valued attribute. If the attribute is not single valued (i.e. there is no such attribute or it is a multiple-valued attribute) an empty string is returned.
key | The key of the attribute for which to return the value. |
AttributeIterator Arc::MessageAttributes::getAll | ( | const std::string & | key | ) | const |
Access the value(s) of an attribute.
This method returns an AttributeIterator that can be used to access the values of an attribute.
key | The key of the attribute for which to return the values. |
void Arc::MessageAttributes::remove | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Removes one value of an attribute.
This method removes a certain value from the attribute that matches a certain key.
key | The key of the attribute from which the value shall be removed. | |
value | The value to remove. |
void Arc::MessageAttributes::removeAll | ( | const std::string & | key | ) |
Removes all attributes with a certain key.
This method removes all attributes that match a certain key.
key | The key of the attributes to remove. |
void Arc::MessageAttributes::set | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Sets a unique value of an attribute.
This method removes any previous value of an attribute and sets the new value as the only value.
key | The key of the attribute. | |
value | The (new) value of the attribute. |
AttrMap Arc::MessageAttributes::attributes_ [protected] |
Internal storage of attributes.
An AttrMap (multimap) in which all attributes (key-value pairs) are stored.