libSBML C++ API
libSBML 5.8.0 C++ API
|
Representation of attributes on an XML node.
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
Public Member Functions | |
int | add (const std::string &name, const std::string &value, const std::string &namespaceURI="", const std::string &prefix="") |
Adds an attribute (a name/value pair) to this XMLAttributes object, optionally with a prefix and URI defining a namespace. More... | |
int | add (const XMLTriple &triple, const std::string &value) |
Adds an attribute with the given XMLTriple/value pair to this XMLAttributes set. More... | |
int | clear () |
Clears (deletes) all attributes in this XMLAttributes object. More... | |
XMLAttributes * | clone () const |
Creates and returns a deep copy of this XMLAttributes set. More... | |
int | getIndex (const std::string &name) const |
Return the index of an attribute with the given name. More... | |
int | getIndex (const std::string &name, const std::string &uri) const |
Return the index of an attribute with the given local name and namespace URI. More... | |
int | getIndex (const XMLTriple &triple) const |
Return the index of an attribute with the given XMLTriple. More... | |
int | getLength () const |
Return the number of attributes in the set. More... | |
std::string | getName (int index) const |
Return the local name of an attribute in this XMLAttributes set (by position). More... | |
int | getNumAttributes () const |
Return the number of attributes in the set. More... | |
std::string | getPrefix (int index) const |
Return the prefix of an attribute in this XMLAttributes set (by position). More... | |
std::string | getPrefixedName (int index) const |
Return the prefixed name of an attribute in this XMLAttributes set (by position). More... | |
std::string | getURI (int index) const |
Return the namespace URI of an attribute in this XMLAttributes set (by position). More... | |
std::string | getValue (int index) const |
Return the value of an attribute in this XMLAttributes set (by position). More... | |
std::string | getValue (const std::string name) const |
Return an attribute's value by name. More... | |
std::string | getValue (const std::string name, const std::string uri) const |
Return a value of an attribute with the given local name and namespace URI. More... | |
std::string | getValue (const XMLTriple &triple) const |
Return a value of an attribute with the given XMLTriple. More... | |
bool | hasAttribute (int index) const |
Predicate returning true or false depending on whether an attribute with the given index exists in this XMLAttributes. More... | |
bool | hasAttribute (const std::string name, const std::string uri="") const |
Predicate returning true or false depending on whether an attribute with the given local name and namespace URI exists in this XMLAttributes. More... | |
bool | hasAttribute (const XMLTriple &triple) const |
Predicate returning true or false depending on whether an attribute with the given XML triple exists in this XMLAttributes. More... | |
bool | isEmpty () const |
Predicate returning true or false depending on whether this XMLAttributes set is empty. More... | |
XMLAttributes & | operator= (const XMLAttributes &rhs) |
Assignment operator for XMLAttributes. More... | |
bool | readInto (const std::string &name, bool &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, bool &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute with the given XMLTriple into value. More... | |
bool | readInto (const std::string &name, double &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, double &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute with the given XMLTriple into value. More... | |
bool | readInto (const std::string &name, long &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, long &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute XMLTriple into value. More... | |
bool | readInto (const std::string &name, int &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, int &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute with the given XMLTriple into value. More... | |
bool | readInto (const std::string &name, unsigned int &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, unsigned int &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute with the given XMLTriple into value. More... | |
bool | readInto (const std::string &name, std::string &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute name into value. More... | |
bool | readInto (const XMLTriple &triple, std::string &value, XMLErrorLog *log=NULL, bool required=false, const unsigned int line=0, const unsigned int column=0) const |
Reads the value for the attribute with the given XMLTriple into value. More... | |
int | remove (int n) |
Removes an attribute with the given index from this XMLAttributes set. More... | |
int | remove (const std::string &name, const std::string &uri="") |
Removes an attribute with the given local name and namespace URI from this XMLAttributes set. More... | |
int | remove (const XMLTriple &triple) |
Removes an attribute with the given XMLTriple from this XMLAttributes set. More... | |
int | removeResource (int n) |
Removes an attribute with the given index from this XMLAttributes set. More... | |
XMLAttributes () | |
Creates a new empty XMLAttributes set. More... | |
XMLAttributes (const XMLAttributes &orig) | |
Copy constructor; creates a copy of this XMLAttributes set. More... | |
virtual | ~XMLAttributes () |
Destroys this XMLAttributes set. More... | |
XMLAttributes::XMLAttributes | ( | ) |
Creates a new empty XMLAttributes set.
|
virtual |
Destroys this XMLAttributes set.
XMLAttributes::XMLAttributes | ( | const XMLAttributes & | orig | ) |
Copy constructor; creates a copy of this XMLAttributes set.
orig
the XMLAttributes object to copy.
XMLConstructorException | Thrown if the argument orig is NULL . |
int XMLAttributes::add | ( | const std::string & | name, |
const std::string & | value, | ||
const std::string & | namespaceURI = "" , |
||
const std::string & | prefix = "" |
||
) |
Adds an attribute (a name/value pair) to this XMLAttributes object, optionally with a prefix and URI defining a namespace.
name | a string, the local name of the attribute. |
value | a string, the value of the attribute. |
namespaceURI | a string, the namespace URI of the attribute. |
prefix | a string, the prefix of the namespace |
int XMLAttributes::add | ( | const XMLTriple & | triple, |
const std::string & | value | ||
) |
Adds an attribute with the given XMLTriple/value pair to this XMLAttributes set.
triple | an XMLTriple, the XML triple of the attribute. |
value | a string, the value of the attribute. |
int XMLAttributes::clear | ( | ) |
Clears (deletes) all attributes in this XMLAttributes object.
XMLAttributes * XMLAttributes::clone | ( | ) | const |
Creates and returns a deep copy of this XMLAttributes set.
int XMLAttributes::getIndex | ( | const std::string & | name | ) | const |
Return the index of an attribute with the given name.
name | a string, the local name of the attribute for which the index is required. |
int XMLAttributes::getIndex | ( | const std::string & | name, |
const std::string & | uri | ||
) | const |
Return the index of an attribute with the given local name and namespace URI.
name | a string, the local name of the attribute. |
uri | a string, the namespace URI of the attribute. |
int XMLAttributes::getIndex | ( | const XMLTriple & | triple | ) | const |
int XMLAttributes::getLength | ( | ) | const |
Return the number of attributes in the set.
std::string XMLAttributes::getName | ( | int | index | ) | const |
Return the local name of an attribute in this XMLAttributes set (by position).
index | an integer, the position of the attribute whose local name is required. |
int XMLAttributes::getNumAttributes | ( | ) | const |
Return the number of attributes in the set.
This function is an alias for getLength introduced for consistency with other XML classes.
std::string XMLAttributes::getPrefix | ( | int | index | ) | const |
Return the prefix of an attribute in this XMLAttributes set (by position).
index | an integer, the position of the attribute whose prefix is required. |
std::string XMLAttributes::getPrefixedName | ( | int | index | ) | const |
Return the prefixed name of an attribute in this XMLAttributes set (by position).
index | an integer, the position of the attribute whose prefixed name is required. |
std::string XMLAttributes::getURI | ( | int | index | ) | const |
Return the namespace URI of an attribute in this XMLAttributes set (by position).
index | an integer, the position of the attribute whose namespace URI is required. |
std::string XMLAttributes::getValue | ( | int | index | ) | const |
Return the value of an attribute in this XMLAttributes set (by position).
index | an integer, the position of the attribute whose value is required. |
std::string XMLAttributes::getValue | ( | const std::string | name | ) | const |
Return an attribute's value by name.
name | a string, the local name of the attribute whose value is required. |
std::string XMLAttributes::getValue | ( | const std::string | name, |
const std::string | uri | ||
) | const |
Return a value of an attribute with the given local name and namespace URI.
name | a string, the local name of the attribute whose value is required. |
uri | a string, the namespace URI of the attribute. |
std::string XMLAttributes::getValue | ( | const XMLTriple & | triple | ) | const |
Return a value of an attribute with the given XMLTriple.
triple | an XMLTriple, the XML triple of the attribute whose value is required. |
bool XMLAttributes::hasAttribute | ( | int | index | ) | const |
Predicate returning true
or false
depending on whether an attribute with the given index exists in this XMLAttributes.
index | an integer, the position of the attribute. |
true
if an attribute with the given index exists in this XMLAttributes, false
otherwise. bool XMLAttributes::hasAttribute | ( | const std::string | name, |
const std::string | uri = "" |
||
) | const |
Predicate returning true
or false
depending on whether an attribute with the given local name and namespace URI exists in this XMLAttributes.
name | a string, the local name of the attribute. |
uri | a string, the namespace URI of the attribute. |
true
if an attribute with the given local name and namespace URI exists in this XMLAttributes, false
otherwise. bool XMLAttributes::hasAttribute | ( | const XMLTriple & | triple | ) | const |
Predicate returning true
or false
depending on whether an attribute with the given XML triple exists in this XMLAttributes.
triple | an XMLTriple, the XML triple of the attribute |
true
if an attribute with the given XML triple exists in this XMLAttributes, false
otherwise. bool XMLAttributes::isEmpty | ( | ) | const |
Predicate returning true
or false
depending on whether this XMLAttributes set is empty.
true
if this XMLAttributes set is empty, false
otherwise. XMLAttributes & XMLAttributes::operator= | ( | const XMLAttributes & | rhs | ) |
Assignment operator for XMLAttributes.
rhs | The XMLAttributes object whose values are used as the basis of the assignment. |
XMLConstructorException | Thrown if the argument rhs is NULL . |
bool XMLAttributes::readInto | ( | const std::string & | name, |
bool & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found or value could be interpreted as a boolean, value is not modified.
According to the W3C XML Schema, valid boolean values are: "true", "false", "1", and "0" (case-insensitive). For more information, see: http://www.w3.org/TR/xmlschema-2/#boolean
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
name | a string, the local name of the attribute. |
value | a boolean, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
bool & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute with the given XMLTriple into value.
If the XMLTriple was not found or value could be interpreted as a boolean, value is not modified.
According to the W3C XML Schema, valid boolean values are: "true", "false", "1", and "0" (case-insensitive). For more information, see: http://www.w3.org/TR/xmlschema-2/#boolean
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | a boolean, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. bool XMLAttributes::readInto | ( | const std::string & | name, |
double & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found or value could be interpreted as a double, value is not modified.
According to the W3C XML Schema, valid doubles are the same as valid doubles for C and the special values "INF", "-INF", and "NaN" (case-sensitive). For more information, see: http://www.w3.org/TR/xmlschema-2/#double
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
name | a string, the local name of the attribute. |
value | a double, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
double & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute with the given XMLTriple into value.
If the triple was not found or value could be interpreted as a double, value is not modified.
According to the W3C XML Schema, valid doubles are the same as valid doubles for C and the special values "INF", "-INF", and "NaN" (case-sensitive). For more information, see: http://www.w3.org/TR/xmlschema-2/#double
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | a double, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. bool XMLAttributes::readInto | ( | const std::string & | name, |
long & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found or value could be interpreted as an long, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a long. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
name | a string, the local name of the attribute. |
value | a long, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
long & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute XMLTriple into value.
If the XMLTriple was not found or value could be interpreted as a long, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a long. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | a long, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. bool XMLAttributes::readInto | ( | const std::string & | name, |
int & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found or value could be interpreted as an int, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a int. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
name | a string, the local name of the attribute. |
value | an integer, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
int & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute with the given XMLTriple into value.
If the XMLTriple was not found or value could be interpreted as an int, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a int. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | an integer, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. bool XMLAttributes::readInto | ( | const std::string & | name, |
unsigned int & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found or value could be interpreted as an unsigned int, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a unsigned int. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
name | a string, the local name of the attribute. |
value | an unsigned integer, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
unsigned int & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute with the given XMLTriple into value.
If the XMLTriple was not found or value could be interpreted as an unsigned int, value is not modified.
According to the W3C XML Schema valid integers include zero, *all* positive and *all* negative whole numbers. For practical purposes, we limit values to what can be stored in a unsigned int. For more information, see: http://www.w3.org/TR/xmlschema-2/#integer
If an XMLErrorLog is passed in datatype format errors are logged. If required is true, missing attributes are also logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | an unsigned integer, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. bool XMLAttributes::readInto | ( | const std::string & | name, |
std::string & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute name into value.
If the given local name was not found, value is not modified.
If an XMLErrorLog is passed in and required is true, missing attributes are logged.
name | a string, the local name of the attribute. |
value | a string, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise.bool XMLAttributes::readInto | ( | const XMLTriple & | triple, |
std::string & | value, | ||
XMLErrorLog * | log = NULL , |
||
bool | required = false , |
||
const unsigned int | line = 0 , |
||
const unsigned int | column = 0 |
||
) | const |
Reads the value for the attribute with the given XMLTriple into value.
If the XMLTriple was not found, value is not modified.
If an XMLErrorLog is passed in and required is true, missing attributes are logged.
triple | an XMLTriple, the XML triple of the attribute. |
value | a string, the value of the attribute. |
log | an XMLErrorLog, the error log. |
required | a boolean, indicating whether the attribute is required. |
line | an unsigned int, the line number at which the error occured. |
column | an unsigned int, the column number at which the error occured. |
true
if the attribute was read into value, false
otherwise. int XMLAttributes::remove | ( | int | n | ) |
Removes an attribute with the given index from this XMLAttributes set.
(This function is an alias of XMLAttributes::removeResource() ).
n | an integer the index of the resource to be deleted |
int XMLAttributes::remove | ( | const std::string & | name, |
const std::string & | uri = "" |
||
) |
Removes an attribute with the given local name and namespace URI from this XMLAttributes set.
name | a string, the local name of the attribute. |
uri | a string, the namespace URI of the attribute. |
int XMLAttributes::remove | ( | const XMLTriple & | triple | ) |
Removes an attribute with the given XMLTriple from this XMLAttributes set.
triple | an XMLTriple, the XML triple of the attribute. |
int XMLAttributes::removeResource | ( | int | n | ) |
Removes an attribute with the given index from this XMLAttributes set.
n | an integer the index of the resource to be deleted |