BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balxml::PrefixStack Class Reference

#include <balxml_prefixstack.h>

Public Member Functions

 PrefixStack (NamespaceRegistry *namespaceRegistry, bslma::Allocator *basicAllocator=0)
 
 PrefixStack (const PrefixStack &original, bslma::Allocator *basicAllocator=0)
 
 ~PrefixStack ()
 Destroy this object.
 
int pushPrefix (const bsl::string_view &prefix, const bsl::string_view &namespaceUri)
 
int popPrefixes (int count)
 
void reset ()
 Removes all prefixes from the internal collection.
 
void restoreToSize (int size)
 
int numPrefixes () const
 Return the current number of prefixes in the stack.
 
NamespaceRegistrynamespaceRegistry () const
 
const char * lookupNamespacePrefix (const bsl::string_view &prefix) const
 
int lookupNamespaceId (const bsl::string_view &prefix) const
 
const char * lookupNamespaceUri (const bsl::string_view &prefix) const
 
const char * lookupNamespaceUri (int nsId) const
 
const char * namespacePrefixByIndex (int index) const
 
int namespaceIdByIndex (int index) const
 
const char * namespaceUriByIndex (int index) const
 
void print (bsl::ostream &stream, bool fullNames=false) const
 

Detailed Description

PrefixStack allows associating a unique integer (namespace ID) with prefix.

See balxml_prefixstack

Constructor & Destructor Documentation

◆ PrefixStack() [1/2]

balxml::PrefixStack::PrefixStack ( NamespaceRegistry namespaceRegistry,
bslma::Allocator basicAllocator = 0 
)

Create an empty registry. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ PrefixStack() [2/2]

balxml::PrefixStack::PrefixStack ( const PrefixStack original,
bslma::Allocator basicAllocator = 0 
)

Create a registry object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~PrefixStack()

balxml::PrefixStack::~PrefixStack ( )
inline

Member Function Documentation

◆ lookupNamespaceId()

int balxml::PrefixStack::lookupNamespaceId ( const bsl::string_view prefix) const

Return ID of the namespace registered for the specified prefix or -1 if not registered.

◆ lookupNamespacePrefix()

const char * balxml::PrefixStack::lookupNamespacePrefix ( const bsl::string_view prefix) const

Return a copy of the specified prefix if prefix is registered or an empty string if prefix is not registered.

◆ lookupNamespaceUri() [1/2]

const char * balxml::PrefixStack::lookupNamespaceUri ( const bsl::string_view prefix) const

Return the URI of the namespace registered for the specified prefix or empty string if not registered.

◆ lookupNamespaceUri() [2/2]

const char * balxml::PrefixStack::lookupNamespaceUri ( int  nsId) const

Return the URI of the namespace of the specified nsId or empty string if not registered.

◆ namespaceIdByIndex()

int balxml::PrefixStack::namespaceIdByIndex ( int  index) const
inline

Return the namespace ID at the specified index in the prefix stack, where an index of 0 is the oldest ID on the stack. If index is negative, return the ID at position 'numPrefixes() - index'. Thus, an index of -1 will return the most recent ID on the stack (i.e., the top of the stack). The behavior is undefined if index > numPrefixes() or index < -numPrefixes().

◆ namespacePrefixByIndex()

const char * balxml::PrefixStack::namespacePrefixByIndex ( int  index) const
inline

Return the namespace prefix at the specified index in the prefix stack, where an index of 0 is the oldest prefix on the stack. If index is negative, return the prefix at position 'numPrefixes() - index'. Thus, an index of -1 will return the most recent prefix on the stack (i.e., the top of the stack). The behavior is undefined if index > numPrefixes() or index < -numPrefixes().

◆ namespaceRegistry()

NamespaceRegistry * balxml::PrefixStack::namespaceRegistry ( ) const
inline

Return the pointer of NamespaceRegistry associated with this PrefixStack.

◆ namespaceUriByIndex()

const char * balxml::PrefixStack::namespaceUriByIndex ( int  index) const

Return the namespace URI at the specified index in the prefix stack, where an index of 0 is the oldest URI on the stack. If index is negative, return the URI at position 'numPrefixes() - index'. Thus, an index of -1 will return the most recent URI on the stack (i.e., the top of the stack). The behavior is undefined if index > numPrefixes() or index < -numPrefixes().

◆ numPrefixes()

int balxml::PrefixStack::numPrefixes ( ) const
inline

◆ popPrefixes()

int balxml::PrefixStack::popPrefixes ( int  count)

Remove the specified last count number prefixes. Return the number of actually removed prefixes.

◆ print()

void balxml::PrefixStack::print ( bsl::ostream &  stream,
bool  fullNames = false 
) const

Print the content of this object to the specified stream. The optionally specified fullNames specifies how namespaces should be printed: true for the full names and false only for IDs.

◆ pushPrefix()

int balxml::PrefixStack::pushPrefix ( const bsl::string_view prefix,
const bsl::string_view namespaceUri 
)

Map the specified namespaceUri to the specified prefix and return the namespace Id. New mapping eclipses previous mapping.

◆ reset()

void balxml::PrefixStack::reset ( )
inline

◆ restoreToSize()

void balxml::PrefixStack::restoreToSize ( int  size)
inline

Restore stack to the specified size. The behavior is undefined if PrefixStack contains fewer prefixes than requested size.


The documentation for this class was generated from the following file: