stlab.adobe.com Adobe Systems Incorporated

An associated array based on adobe::token_range_t. A utility class for the xml_parser_t. More...

#include <adobe/xml_parser.hpp>

List of all members.

Classes

struct  less_key_only_t
struct  less_t

Public Types

typedef set_type::const_iterator const_iterator
typedef const_iterator iterator
typedef token_range_t key_type
typedef token_range_t mapped_type
typedef std::vector< value_typeset_type
typedef set_type::size_type size_type
typedef std::pair< key_type,
mapped_type
value_type

Public Member Functions

const_iterator begin () const
void clear ()
std::size_t count_collisions (const attribute_set_t &other_set) const
std::size_t count_same (const attribute_set_t &other_set, bool mapped_matters=true) const
bool empty () const
const_iterator end () const
bool has_collisions (const attribute_set_t &other_set) const
template<typename I >
void insert (I first, I last)
void insert (const key_type &key, const mapped_type &value)
void insert (const value_type &attribute)
bool lower_bound (const key_type &key, set_type::iterator &result)
bool lower_bound (const key_type &key, set_type::const_iterator &result) const
bool lower_bound (const value_type &attribute, set_type::iterator &result)
bool lower_bound (const value_type &attribute, set_type::const_iterator &result) const
attribute_set_t merge (const attribute_set_t &other_set) const
mapped_type operator[] (const key_type &key) const
size_type size () const

Friends

std::ostream & operator<< (std::ostream &s, const attribute_set_t &attribute_set)
bool operator== (const attribute_set_t &x, const attribute_set_t &y)

Detailed Description

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 49 of file xml_parser.hpp.


Member Typedef Documentation

typedef set_type::const_iterator const_iterator

Definition at line 56 of file xml_parser.hpp.

Definition at line 57 of file xml_parser.hpp.

Definition at line 51 of file xml_parser.hpp.

Definition at line 52 of file xml_parser.hpp.

typedef std::vector<value_type> set_type

Definition at line 54 of file xml_parser.hpp.

typedef set_type::size_type size_type

Definition at line 55 of file xml_parser.hpp.

typedef std::pair<key_type, mapped_type> value_type

Definition at line 53 of file xml_parser.hpp.


Member Function Documentation

const_iterator begin (  ) const
Returns:
An unmodifiable (but dereferenceable) iterator to the first key-value pair in the attribute set

Definition at line 282 of file xml_parser.hpp.

void clear (  )

Erases the entire contents of the attribute set.

Postcondition:
empty() == true

Definition at line 296 of file xml_parser.hpp.

std::size_t count_collisions ( const attribute_set_t other_set ) const

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_setthe other attribute set used for comparison
Returns:
The number of collisions that exist between two sets.

Definition at line 409 of file xml_parser.hpp.

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_setthe other attribute set used for comparison
mapped_matterstoggles 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 364 of file xml_parser.hpp.

bool empty (  ) const
Returns:
Specifies whether or not this attribute set is empty

Definition at line 268 of file xml_parser.hpp.

const_iterator end (  ) const
Returns:
An iterator to one-past-the last key-value pair in the attribute set

Definition at line 288 of file xml_parser.hpp.

bool has_collisions ( const attribute_set_t other_set ) const

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_setthe other attribute set used for comparison
Returns:
Whether or not there is at least one collision between the two attribute sets.

Definition at line 391 of file xml_parser.hpp.

void insert ( first,
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:
firstA pointer to the first key-value pair in the range.
lastA pointer to one-past the last key-value pair in the range.

Definition at line 213 of file xml_parser.hpp.

void insert ( const key_type key,
const mapped_type value 
)

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:
keythe key under which the value is to be inserted
valuethe value to be inserted into the attribute set

Definition at line 224 of file xml_parser.hpp.

void insert ( const value_type attribute )

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:
attributethe key-value pair to be inserted.

Definition at line 192 of file xml_parser.hpp.

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:
keythe key that is to be searched for in the attribute_set_t
resultthe 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 118 of file xml_parser.hpp.

bool lower_bound ( const key_type key,
set_type::const_iterator &  result 
) const

const-equivalent of lower_bound for attribute_set_t.

Definition at line 135 of file xml_parser.hpp.

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:
attributethe attribute whose key is to be searched for in the attribute_set_t
resultthe 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 99 of file xml_parser.hpp.

bool lower_bound ( const value_type attribute,
set_type::const_iterator &  result 
) const

const-equivalent of lower_bound for attribute_set_t.

Definition at line 124 of file xml_parser.hpp.

attribute_set_t merge ( const attribute_set_t other_set ) const

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:
other_setthe second attribute_set_t with which this one will be merged.
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 171 of file xml_parser.hpp.

mapped_type operator[] ( const key_type key ) const

Fetches an unmodifiable value from an attribute_set_t stored under a given key.

Parameters:
keythe 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 147 of file xml_parser.hpp.

size_type size (  ) const
Returns:
Specifies the number of key-value pairs stored in this attribute set

Definition at line 275 of file xml_parser.hpp.


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  s,
const attribute_set_t attribute_set 
) [friend]

Defines serialization functionality for an attribute set. Output format is similar to the format required for attribute sets in xml documents.

Parameters:
sthe stream to receive the output
attribute_setthe attribute set to be serialized to the stream
Returns:
the output stream

Definition at line 337 of file xml_parser.hpp.

bool operator== ( const attribute_set_t x,
const attribute_set_t y 
) [friend]

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:
xthe first attribute set
ythe second attribute set
Returns:
true if the two attribute sets are equal. false otherwise.

Definition at line 319 of file xml_parser.hpp.

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google