Mp7Jrs  2.7.1
Mp7JrsUtil Class Reference

Utility class. More...

Static Public Member Functions

static XMLCh * allocate (long length)
 Use this function to avoid troubles with Xerces heap management.
static void deallocate (XMLCh **src)
 Releases strings which are allocated with allocate() (counterpart).
static XMLCh * CatString (const XMLCh *const target, const XMLCh *const src)
 Note, you have to free the allocated memory with deallocate()
static void CatString (XMLCh **target, const XMLCh *const src)
static XMLCh * ConvertToXMLCh (XMLSSize_t val)
 Note, you have to free the allocated memory with deallocate()
static XMLCh * PadLeft (const XMLCh *const target, const XMLCh *const fill, const unsigned int maxlen)
 Note, you have to free the allocated memory with deallocate()
static XMLCh * PadRight (const XMLCh *const target, const XMLCh *const fill, const unsigned int maxlen)
 Note, you have to free the allocated memory with deallocate()
static DOMElement * GetNextAkin (DOMElement *currentnode)
 Previously GetNextSibling, but unfortunately there is a MS macro!!! with the same name.
static DOMElement * GetNextChild (DOMElement *currentnode)
static XMLCh * GetElementText (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *currentnode)
 Note, you have to free the allocated memory with deallocate()
static int GetNextEndPos (Match &m, int i)
static const XMLCh * LookupNamespacePrefix (XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const XMLCh *ns)
 Find prefix for given namespace.
static const XMLCh * LookupNamespaceUri (XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const XMLCh *prefix)
 Find namespace URI for given prefix.
static bool HandleXsiType (DOMElement *element, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const bool usexsitype, const XMLCh *ns, const XMLCh *elementtype)
 Adds an xsi:type if needed.
static bool SerializeTextNode (DOMElement *element, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const XMLCh *data, const XMLCh *ns, const XMLCh *name, bool isoptional=false)
 Adds a textnode if not empty.
static bool HasNodeName (DOMNode *node, const XMLCh *name, const XMLCh *ns)
 Adds a textnode if not empty.
static bool GetXsiType (DOMElement *node, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, NamespaceHelper *xsitype)
 Extracts the xsi:type if set.
static const XMLCh * LocalName (const XMLCh *name)
 Returns a static string of the name without the prefix (if any).
static XMLCh * Prefix (const XMLCh *name)
 Returns an allocated string of the prefix (if any) without the name.
static XMLCh * QualifiedName (const NamespaceHelper *val)
 Generates a qualified name in the format "namespaceURI : name".
static XMLCh * QualifiedName (const XMLCh *nsuri, const XMLCh *name)
 Generates a qualified name in the format "namespaceURI : name".

Detailed Description

Utility class.

Member Function Documentation

XMLCh * Mp7JrsUtil::allocate ( long  length)
static

Use this function to avoid troubles with Xerces heap management.

Since Xerces uses its own heap, you should not create a XML string like XMLCh * tmp = new XMLCh[123]; // our heap and release it with XMLString::release(tmp) // the other heap More worse, Xerces 2.2.0 does not provide XMLString::allocate(), so our wrapper uses XMLString::replicate to create it on the correct heap.

void Mp7JrsUtil::deallocate ( XMLCh **  src)
static

Releases strings which are allocated with allocate() (counterpart).

Parameters
srcthe address of the XMLCh pointer. This method sets the pointer to NULL as well.
DOMElement * Mp7JrsUtil::GetNextAkin ( DOMElement *  currentnode)
static

Previously GetNextSibling, but unfortunately there is a MS macro!!! with the same name.

bool Mp7JrsUtil::GetXsiType ( DOMElement *  node,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
NamespaceHelper *  xsitype 
)
static

Extracts the xsi:type if set.

Parameters
nodethe DOM node possibly containing an xsi:type.
docthe DOM document used for namespace resolving.
xsitypeif xsi:type is valid, the container is filled with URI, prefix and name of the xsi:type, if existing, otherwise not. You mustnot delete the contents of this result.
Returns
true, if the xsi:type has been found, false otherwise.
bool Mp7JrsUtil::HandleXsiType ( DOMElement *  element,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const bool  usexsitype,
const XMLCh *  ns,
const XMLCh *  elementtype 
)
static

Adds an xsi:type if needed.

Parameters
elementthe DOM element candidate for the xsi attribute.
docthe XML document the element is added to.
usexsitypeif true, xsi type will be set if not already done.
nsthe namespace of the type. Used to figure out the prefix.
elementtypethe name of the element type.
Returns
true, if xsi type has been added, false otherwise.
bool Mp7JrsUtil::HasNodeName ( DOMNode *  node,
const XMLCh *  name,
const XMLCh *  ns 
)
static

Adds a textnode if not empty.

Parameters
nodethe DOM node containing a text node.
namethe name of the element type.
nsthe namespace of the content.
Returns
true, if the node name is correct.
const XMLCh * Mp7JrsUtil::LocalName ( const XMLCh *  name)
static

Returns a static string of the name without the prefix (if any).

Parameters
namethe DOM nodename with or without prefix.
Returns
a string, which is just a pointer inside the name param pointing to the sucessor of a ":".
Warning
Don't use the X() macro for name since its lifetime ends after the call and hence result is pointing to nowhere.
const XMLCh * Mp7JrsUtil::LookupNamespacePrefix ( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const XMLCh *  ns 
)
static

Find prefix for given namespace.

Returns
the prefix string or NULL if not found or no prefix set.
const XMLCh * Mp7JrsUtil::LookupNamespaceUri ( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const XMLCh *  prefix 
)
static

Find namespace URI for given prefix.

Returns
the URI or NULL if not found.
XMLCh * Mp7JrsUtil::Prefix ( const XMLCh *  name)
static

Returns an allocated string of the prefix (if any) without the name.

You have to deallocate the string with XMLString::release().

Parameters
namethe DOM nodename with or without prefix.
Returns
an allocated string with a copy of the local name without the ":" separator.
XMLCh * Mp7JrsUtil::QualifiedName ( const NamespaceHelper *  val)
static

Generates a qualified name in the format "namespaceURI : name".

Parameters
theNamespaceHelper containing namespace and name.
Returns
the combined output, which must be deallocated afterwards.
XMLCh * Mp7JrsUtil::QualifiedName ( const XMLCh *  nsuri,
const XMLCh *  name 
)
static

Generates a qualified name in the format "namespaceURI : name".

Parameters
nsurithe namespaceURI
namethe local name
Returns
the combined output, which must be deallocated afterwards.
bool Mp7JrsUtil::SerializeTextNode ( DOMElement *  element,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *  doc,
const XMLCh *  data,
const XMLCh *  ns,
const XMLCh *  name,
bool  isoptional = false 
)
static

Adds a textnode if not empty.

Parameters
elementthe parent DOM element for the text node.
docthe XML document, needed for namespace handling.
datathe textnode content.
nsthe namespace of the content. Used to figure out the prefix.
namethe name of the element type.
isoptionalif true, the node is not written in case of empty (null) data.
Returns
true, if a textnode has been added, false otherwise.