libSBML C++ API  5.18.0
XMLTriple Class Reference

Detailed Description

A qualified XML name.

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.

A "triple" in the libSBML XML layer encapsulates the notion of qualified name, meaning an element name or an attribute name with an optional namespace qualifier. Triples by themselves are not entities in an XML stream—they are not, for example, elements or attributes; rather, XMLTriple is used in libSBML to construct these other kinds of objects.

An XMLTriple instance carries up to three data items:

  1. The name of the attribute or element; that is, the attribute name as it appears in an XML document or data stream;
  2. The XML namespace prefix (if any) of the attribute. For example, in the following fragment of XML, the namespace prefix is the string mysim and it appears on both the element someelement and the attribute attribA. When both the element and the attribute are stored as XMLTriple objects, their prefix is mysim.
    <mysim:someelement mysim:attribA="value" />
    
  3. The XML namespace URI with which the prefix is associated. In XML, every namespace used must be declared and mapped to a URI.

XMLTriple objects are the lowest-level data item in the XML layer of libSBML. Other objects such as XMLToken make use of XMLTriple objects.

See also
XMLToken
XMLNode
XMLAttributes
XMLNamespaces
Examples:
addingEvidenceCodes_2.cpp, and createExampleSBML.cpp.

Public Member Functions

XMLTripleclone () const
 Creates and returns a deep copy of this XMLTriple object. More...
 
const std::string & getName () const
 Returns the name portion of this XMLTriple object. More...
 
const std::string & getPrefix () const
 Returns the prefix portion of this XMLTriple object. More...
 
const std::string getPrefixedName () const
 Returns the prefixed name from this XMLTriple. More...
 
const std::string & getURI () const
 Returns the URI portion of this XMLTriple object. More...
 
bool isEmpty () const
 Returns true if this XMLTriple object is empty. More...
 
XMLTripleoperator= (const XMLTriple &rhs)
 Assignment operator for XMLTriple. More...
 
 XMLTriple ()
 Creates a new, empty XMLTriple object. More...
 
 XMLTriple (const std::string &name, const std::string &uri, const std::string &prefix)
 Creates a new XMLTriple object with a given name, uri and and prefix. More...
 
 XMLTriple (const std::string &triplet, const char sepchar= ' ')
 Creates an XMLTriple object by splitting a given string at a given separator character. More...
 
 XMLTriple (const XMLTriple &orig)
 Copy constructor; creates a copy of this XMLTriple object. More...
 

Constructor & Destructor Documentation

XMLTriple::XMLTriple ( )

Creates a new, empty XMLTriple object.

XMLTriple::XMLTriple ( const std::string &  name,
const std::string &  uri,
const std::string &  prefix 
)

Creates a new XMLTriple object with a given name, uri and and prefix.

Parameters
namea string, the name for the entity represented by this object.
uria string, the XML namespace URI associated with the prefix.
prefixa string, the XML namespace prefix for this triple.
XMLTriple::XMLTriple ( const std::string &  triplet,
const char  sepchar = ' ' 
)

Creates an XMLTriple object by splitting a given string at a given separator character.

The "triplet" in this case is a string that may be in one of the following three possible formats:

  1. name
  2. URIxname
  3. URIxnamexprefix

where x represents the separator character, sepchar.

Parameters
tripleta string representing the triplet as shown above.
sepchara character, the sepchar used in the triplet.
XMLTriple::XMLTriple ( const XMLTriple orig)

Copy constructor; creates a copy of this XMLTriple object.

Parameters
origthe XMLTriple object to copy.

Member Function Documentation

XMLTriple * XMLTriple::clone ( ) const

Creates and returns a deep copy of this XMLTriple object.

Returns
the (deep) copy of this XMLTriple object.
const std::string & XMLTriple::getName ( ) const

Returns the name portion of this XMLTriple object.

Returns
a string, the name portion of this XMLTriple object.
const std::string & XMLTriple::getPrefix ( ) const

Returns the prefix portion of this XMLTriple object.

Returns
a string, the prefix portion of this XMLTriple object.
const std::string XMLTriple::getPrefixedName ( ) const

Returns the prefixed name from this XMLTriple.

Returns
a string, the prefixed name from this XMLTriple. This is constructed by concatenating the prefix stored in this XMLTriple object, followed by a colon character ":", followed by the name stored in this XMLTriple object.
const std::string & XMLTriple::getURI ( ) const

Returns the URI portion of this XMLTriple object.

Returns
URI a string, the URI portion of this XMLTriple object.
bool XMLTriple::isEmpty ( ) const

Returns true if this XMLTriple object is empty.

Returns
true if this XMLTriple is empty, false otherwise.
XMLTriple & XMLTriple::operator= ( const XMLTriple rhs)

Assignment operator for XMLTriple.

Parameters
rhsthe XMLTriple object whose values are used as the basis of the assignment.