An associated array based on adobe::token_range_t. A utility class for the xml_parser_t.
More...
#include <adobe/xml_parser.hpp>
- Model Of
-
- Introduction
- One of the key advantages to the adobe::xml_parser_t class is its performance in parsing documents. It is able to achieve fast parsing speeds by eliminating the copying of the original data during the parse, and only copying information to the output streams as the client of the parser sees fit. This mandates a host of accomodations given that the source data becomes deeply shared during a parse.
- The adobe::attribute_set_t class is a collection point for attributes that are found while parsing elements found within an xml-based document. These attributes are then handed back to the xml_parser_t client via the client callback mechanism. The attribute_set_t storage implementation is copy-on-modify, so it is inexpensive to pass by value.
Definition at line 42 of file xml_parser.hpp.
◆ key_type
◆ mapped_type
◆ value_type
◆ set_type
◆ size_type
◆ const_iterator
◆ iterator
◆ lower_bound() [1/4]
bool lower_bound |
( |
const value_type & | attribute, |
|
|
set_type::iterator & | result ) |
Same logical result as std::lower_bound as it applies to attribute_set_t. Note that the value of the attribute is not used in the search; only the key is looked up.
- Parameters
-
attribute | the attribute whose key is to be searched for in the attribute_set_t |
result | the resultant position to which the attribute key fits |
- Returns
- true if the attribute key exists within the attribute_set_t. false otherwise.
Definition at line 86 of file xml_parser.hpp.
◆ lower_bound() [2/4]
bool lower_bound |
( |
const key_type & | key, |
|
|
set_type::iterator & | result ) |
Same logical result as std::lower_bound as it applies to attribute_set_t. For this particular implementation only the attribute key is necessary as a parameter.
- Parameters
-
key | the key that is to be searched for in the attribute_set_t |
result | the resultant position to which the key fits |
- Returns
- true if an attribute with this key exists within the attribute_set_t. false otherwise.
Definition at line 103 of file xml_parser.hpp.
◆ lower_bound() [3/4]
bool lower_bound |
( |
const value_type & | attribute, |
|
|
set_type::const_iterator & | result ) const |
◆ lower_bound() [4/4]
bool lower_bound |
( |
const key_type & | key, |
|
|
set_type::const_iterator & | result ) const |
◆ operator[]()
Fetches an unmodifiable value from an attribute_set_t stored under a given key.
- Parameters
-
key | the key under which the corresponding value should be found |
- Returns
- the value if one exists; otherwise the NULL-token (See token_range_t).
Definition at line 132 of file xml_parser.hpp.
◆ merge()
This merges two attribute sets together and places the union into dst. In the case where both attribute sets have an element with the same name, the value in the union will be from *this. The values are not compared when performing the union. This means the "override" attribute set should be the first source when you call this function.
- Parameters
-
- Returns
- an attribute_set_t that is the result of merging this attribute_set_t with the one passed in. This attribute_set_t is left unchanged.
Definition at line 155 of file xml_parser.hpp.
◆ insert() [1/3]
Inserts a key-value pair into the current attribute set. If there are more than one references to the internal instance of this attribute set, then a copy will be spun off before the insertion is made.
In the case when a value is already stored under the key specified in the attribute to be inserted, that value is replaced.
- Parameters
-
attribute | the key-value pair to be inserted. |
Definition at line 176 of file xml_parser.hpp.
◆ insert() [2/3]
template<typename I>
void insert |
( |
I | first, |
|
|
I | last ) |
Inserts a range of key-value pairs into the current attribute set. Equivalent to invoking insert() over each element in the range.
- Precondition
last
must be reachable from first
.
- Parameters
-
first | A pointer to the first key-value pair in the range. |
last | A pointer to one-past the last key-value pair in the range. |
Definition at line 196 of file xml_parser.hpp.
◆ insert() [3/3]
Inserts a key-value pair into the current attribute set. This is a helper implementation, allowing the client to specify the key and the value to be inserted as separate parameters.
- Parameters
-
key | the key under which the value is to be inserted |
value | the value to be inserted into the attribute set |
Definition at line 209 of file xml_parser.hpp.
◆ count_same()
std::size_t count_same |
( |
const attribute_set_t & | other_set, |
|
|
bool | mapped_matters = true ) const |
Counts the number of attributes two attribute sets hold in similarity. When making the comparison the value of the attributes can be optionally omitted.
- Parameters
-
other_set | the other attribute set used for comparison |
mapped_matters | toggles whether or not to consider the values found under the respective keys. If false, only the existence of the keys are required for the two sets to be considered 'sharing' that key. |
Definition at line 345 of file xml_parser.hpp.
◆ has_collisions()
A collision is defined as a key existing in both attribute sets but having different values. This routine searches two attribute sets looking to see if any collisions exist between them.
This routine is no slower (and is often faster than) the expression count_collisions() != 0
.
- Parameters
-
other_set | the other attribute set used for comparison |
- Returns
- Whether or not there is at least one collision between the two attribute sets.
Definition at line 370 of file xml_parser.hpp.
◆ count_collisions()
A collision is defined as a key existing in both attribute sets but having different values. This routine searches two attribute sets and counts the number of collisions that exist between them.
- Parameters
-
other_set | the other attribute set used for comparison |
- Returns
- The number of collisions that exist between two sets.
Definition at line 387 of file xml_parser.hpp.
◆ empty()
- Returns
- Specifies whether or not this attribute set is empty
Definition at line 254 of file xml_parser.hpp.
◆ size()
- Returns
- Specifies the number of key-value pairs stored in this attribute set
Definition at line 260 of file xml_parser.hpp.
◆ begin()
- Returns
- An unmodifiable (but dereferenceable) iterator to the first key-value pair in the attribute set
Definition at line 266 of file xml_parser.hpp.
◆ end()
- Returns
- An iterator to one-past-the last key-value pair in the attribute set
Definition at line 272 of file xml_parser.hpp.
◆ clear()
Erases the entire contents of the attribute set.
- Postcondition
empty() == true
Definition at line 280 of file xml_parser.hpp.
◆ operator== [1/2]
◆ operator<< [1/2]
std::ostream & operator<< |
( |
std::ostream & | s, |
|
|
const attribute_set_t & | attribute_set ) |
|
friend |
◆ operator==() [2/2]
Defines equality comparisons between two attribute sets. Equivalent to calling count_same over the attribute sets and arriving at the size of both sets (which, by implication, must be the same.)
- Parameters
-
x | the first attribute set |
y | the second attribute set |
- Returns
true
if the two attribute sets are equal. false
otherwise.
Definition at line 303 of file xml_parser.hpp.
◆ operator<<() [2/2]
std::ostream & operator<< |
( |
std::ostream & | s, |
|
|
const attribute_set_t & | attribute_set ) |
|
related |
Defines serialization functionality for an attribute set. Output format is similar to the format required for attribute sets in xml documents.
- Parameters
-
s | the stream to receive the output |
attribute_set | the attribute set to be serialized to the stream |
- Returns
- the output stream
Definition at line 320 of file xml_parser.hpp.