Class to represent the properties of an attribute in an XML element tag. Note that this class is not value semantic and does not own any of its pointer values. The owner of the arguments used to set the value of a ElementAttribute
is responsible for ensuring that the values remain valid or else must document the conditions that will make the values invalid. Some facets are computed the first time that they are needed. To avoid extra processing, the caller may supply otherwise-computed facets at construction or by calling reset
. Facets provided by the caller are not checked to ensure that they are consistent with one another.
See balxml_elementattribute
balxml::ElementAttribute::ElementAttribute |
( |
const PrefixStack * |
prefixStack, |
|
|
const char * |
qualifiedName, |
|
|
const char * |
value, |
|
|
const char * |
prefix = 0 , |
|
|
const char * |
localName = 0 , |
|
|
int |
namespaceId = INT_MIN , |
|
|
const char * |
namespaceUri = 0 , |
|
|
unsigned |
flags = 0 |
|
) |
| |
Construct an attribute object with the specified, prefixStack
, qualifiedName
, and value
, with optionally specified prefix
, localName
, namespaceId
, namespaceUri
, and flags
. Except for flags
, if any of the optional arguments are null (for pointers) or INT_MIN
(for integer arguments), then the corresponding facet will computed from the other arguments on an as-needed basis. If all of the optional arguments are given non-null, non-INT_MIN
values, then prefixStack
is unused and may be null. Arguments are permitted to be inconsistent with one another (e.g., prefix
may not match the beginning of qualifiedName
) and will produce an object for with facets that are inconsistent with one another. The constructed object will become invalid if any of the supplied pointers is invalidated during its lifetime (or before it is reset). An invalid object may be destroyed or reset, but any other access yields undefined behavior.
int balxml::ElementAttribute::namespaceId |
( |
| ) |
const |
Return the value of localName
specified at the last call to reset
or the constructor, if not INT_MIN
, else return the ID returned by the prefix stack for the current value of prefix()
. Return -1 if prefix()
is an empty string, prefixStack()
is zero, or prefix()
is not active in the prefix stack. Note that, as per the XML namespace standard, an empty prefix does NOT refer to the default namespace, but rather refers to NO namespace.
const char * balxml::ElementAttribute::namespaceUri |
( |
| ) |
const |
Return the value of namespaceUri
specified at the last call to reset
or the constructor, if non-zero, else return the URI returned by the prefix stack for the current value of prefix()
. Return an empty string if prefix()
is an empty string, prefixStack()
is zero, or prefix()
is not active in the prefix stack. Note that, as per the XML namespace standard, an empty prefix does NOT refer to the default namespace, but rather refers to NO namespace.
bsl::ostream & balxml::ElementAttribute::print |
( |
bsl::ostream & |
stream, |
|
|
int |
level = 0 , |
|
|
int |
spacesPerLevel = 4 |
|
) |
| const |
Format this object to the specified output stream
at the (absolute value of) the optionally specified indentation level
and return a reference to stream
. If level
is specified, optionally specify spacesPerLevel
, the number of spaces per indentation level for this and all of its nested objects. If level
is negative, suppress indentation of the first line. If spacesPerLevel
is negative, format the entire output on one line. If stream
is not valid on entry, this operation has no effect. Facet values that have not yet been computed are represented by "<null>" in the resulting stream.
void balxml::ElementAttribute::reset |
( |
const PrefixStack * |
prefixStack, |
|
|
const char * |
qualifiedName, |
|
|
const char * |
value, |
|
|
const char * |
prefix = 0 , |
|
|
const char * |
localName = 0 , |
|
|
int |
namespaceId = INT_MIN , |
|
|
const char * |
namespaceUri = 0 , |
|
|
unsigned |
flags = 0 |
|
) |
| |
Reset this attribute object with the specified, prefixStack
, qualifiedName
, and value
, with optionally specified prefix
, localName
, namespaceId
, namespaceUri
, and flags
. Except for flags
, if any of the optional arguments are null (for pointers) or INT_MIN
(for integer arguments), then the corresponding facet will computed from the other arguments on an as-needed basis. If all of the optional arguments are given non-null, non-INT_MIN
values, then prefixStack
is unused and may be null. Arguments are permitted to be inconsistent with one another (e.g., prefix
may not match the beginning of qualifiedName
) and will produce an object for with facets that are inconsistent with one another. This object will become invalid if any of the supplied pointers is invalidated during its lifetime (or before it is reset). An invalid object may be destroyed or reset, but any other access yields undefined behavior.