Mp7Jrs  2.7.1
Mp7JrsArchive Class Reference

Mp7Jrs archive. More...

Public Member Functions

Constructors and Destructors
 Mp7JrsArchive (void)
 ~Mp7JrsArchive (void)
Get and Set Options
void SetEncoding (const char *encoding)
 Set the encoding (UTF-8, UTF-16 ...) of XML document to be (de)serialized.
void SetEncoding (const XMLCh *encoding)
 Set the encoding (UTF-8, UTF-16 ...) of XML document to be (de)serialized.
char * GetEncoding ()
 Get current encoding setting (UTF-8, UTF-16 ...)
void SetSchemaLocation (const char *namespaceURI, const char *prefix, const char *schemaLocation)
 Set a schema location.
void SetSchemaLocation (const XMLCh *namespaceURI, const XMLCh *prefix, const XMLCh *schemaLocation)
 Set a schema location.
char * GetSchemaLocation (const char *namespaceURI)
 Get location of given schema.
void SetDefaultNamespace (const XMLCh *namespaceURI, const XMLCh *prefix)
 Sets the default namespace.
bool GetDefaultNamespace (const XMLCh **namespaceURI, const XMLCh **prefix)
 Gets the namespace's name and prefix of the default namespace.
void SetDoValidation (bool validate)
 Set if validation shall be done.
bool GetDoValidation ()
 Get validation setting.
void SetFullSchemaChecking (bool fullSchema)
 Set if full schema checking shall be done.
bool GetFullSchemaChecking ()
 Get full schema checking setting.
void SetPrettyFormatting (bool flag)
 Set if pretty formatted (with line breaks) output is desired.
bool GetPrettyFormatting ()
 Get if pretty formatted output flag (using line breaks) is set.
void SetWriteXMLDecl (bool decl)
 Set whether the XMLDecl header (version, encoding, standalone) shall be written.
bool GetWriteXMLDecl ()
 Get XMLDecl setting.
void SetForceNamespaceDeclaration (bool flag)
 Set whether the namespace declarations should be written to the XML root node or not (default: true).
bool GetForceNamespaceDeclaration ()
 Get ForceNamespaceDeclaration setting.
void SetUsePrefixForDefaultNS (bool flag)
 Set whether or not you want your elements of the default namespace be prefixed (Initially: false).
bool GetUsePrefixForDefaultNS ()
 Get whether or not you want your elements of the default namespace be prefixed with mpeg7 (Initially: false).

Friends

class XercesWrapper

Serializing and Deserializing

enum  HowToAdd { APPEND, INSERT, REPLACE }
 Constants that describe how to add something to a collection. More...
void ToFile (const XMLCh *path, Mp7JrsNodePtr &node, XMLCh *nodeName=(XMLCh *) NULL, bool useTypeAttr=false)
 Serializes to a file.
void ToFile (const char *path, Mp7JrsNodePtr &node, XMLCh *nodeName=(XMLCh *) NULL, bool useTypeAttr=false)
 Serializes to a file.
Mp7JrsNodePtr FromFile (const XMLCh *path, Mp7JrsNodePtr &node)
 Deserializes from file.
Mp7JrsNodePtr FromFile (const XMLCh *path)
 Deserializes from file.
Mp7JrsNodePtr FromFile (const char *path, Mp7JrsNodePtr &node)
 Deserializes from file.
Mp7JrsNodePtr FromFile (const char *path)
 Deserializes from file.
int AddToCollectionFromFile (const XMLCh *path, Mp7JrsNodeCollectionPtr &collection, HowToAdd howtoadd, int where=-1)
 Inserts a fragment from file into a collection.
int AddToCollectionFromBuffer (const XMLCh *buffer, Mp7JrsNodeCollectionPtr &collection, HowToAdd howtoadd, int where=-1)
 Inserts a fragment from a buffer into a collection.
int AddToCollectionFromFile (const char *path, Mp7JrsNodeCollectionPtr &collection, HowToAdd howtoadd, int where=-1)
 Inserts a fragment from file into a collection.
int AddToCollectionFromBuffer (const char *buffer, Mp7JrsNodeCollectionPtr &collection, HowToAdd howtoadd, int where=-1)
 Inserts a fragment from a buffer into a collection.
XMLCh * ToWBuffer (Mp7JrsNodePtr &node, XMLCh *nodeName=(XMLCh *) NULL, bool useTypeAttr=false)
 Serializes to a 16 bit Unicode (Xerces) buffer.
char * ToBuffer (Mp7JrsNodePtr &node, XMLCh *nodeName=(XMLCh *) NULL, bool useTypeAttr=false)
 Serializes to a 8 bit (Xerces) buffer.
Mp7JrsNodePtr FromBuffer (const XMLCh *buf, Mp7JrsNodePtr &node)
 Deserializes from a 16 bit Unicode buffer.
Mp7JrsNodePtr FromBuffer (const XMLCh *buf)
 Deserializes from a 16 bit Unicode buffer.
Mp7JrsNodePtr FromBuffer (const char *buf, Mp7JrsNodePtr &node)
 Deserializes from a 8 bit buffer.
Mp7JrsNodePtr FromBuffer (const char *buf)
 Deserializes from a 8 bit buffer.
void ToStdOut (Mp7JrsNodePtr &node, XMLCh *nodeName=(XMLCh *) NULL, bool useTypeAttr=false)
 Serializes to a console (stdout).
void DeleteBuffer (char **buffer)
 Deletes a buffer created when serializing (on the Xerces heap).
void DeleteBuffer (XMLCh **buffer)
 Deletes a buffer created when serializing (on the Xerces heap).

Detailed Description

Mp7Jrs archive.

A class which handles (de)serializing of Mp7Jrs XML documents.

Member Enumeration Documentation

Constants that describe how to add something to a collection.

  • APPEND: append to the end of the collection.
  • INSERT: insert at given index.
  • REPLACE: replace element at given index.

Member Function Documentation

int Mp7JrsArchive::AddToCollectionFromBuffer ( const XMLCh *  buffer,
Mp7JrsNodeCollectionPtr &  collection,
HowToAdd  howtoadd,
int  where = -1 
)

Inserts a fragment from a buffer into a collection.

Parameters
bufferBuffer containing the MPEG-7 XML.
collectionCollection where the fragment is to be added.
howtoaddhow to add the fragment.
wherethe index where the fragment is to be added.
Returns
The index of the added node, or -1 on failure.
int Mp7JrsArchive::AddToCollectionFromBuffer ( const char *  buffer,
Mp7JrsNodeCollectionPtr &  collection,
HowToAdd  howtoadd,
int  where = -1 
)

Inserts a fragment from a buffer into a collection.

Parameters
bufferBuffer containing the MPEG-7 XML.
collectionCollection where the fragment is to be added.
howtoaddhow to add the fragment.
wherethe index where the fragment is to be added.
Returns
The index of the added node, or -1 on failure.
int Mp7JrsArchive::AddToCollectionFromFile ( const XMLCh *  path,
Mp7JrsNodeCollectionPtr &  collection,
HowToAdd  howtoadd,
int  where = -1 
)

Inserts a fragment from file into a collection.

Parameters
pathPath and file name of the source file.
collectionCollection where the fragment is to be added.
howtoaddhow to add the fragment.
wherethe index where the fragment is to be added.
Returns
The index of the added node, or -1 on failure.
int Mp7JrsArchive::AddToCollectionFromFile ( const char *  path,
Mp7JrsNodeCollectionPtr &  collection,
HowToAdd  howtoadd,
int  where = -1 
)

Inserts a fragment from file into a collection.

Parameters
pathPath and file name of the source file.
collectionCollection where the fragment is to be added.
howtoaddhow to add the fragment.
wherethe index where the fragment is to be added.
Returns
The index of the added node, or -1 on failure.
void Mp7JrsArchive::DeleteBuffer ( char **  buffer)

Deletes a buffer created when serializing (on the Xerces heap).

Note: if you call this method with a pointer to your heap, the system becomes inconsitent.

Parameters
bufferBuffer to be deleted.
void Mp7JrsArchive::DeleteBuffer ( XMLCh **  buffer)

Deletes a buffer created when serializing (on the Xerces heap).

Note: if you call this method with a pointer to your heap, the system becomes inconsitent.

Parameters
bufferBuffer to be deleted.
Mp7JrsNodePtr Mp7JrsArchive::FromBuffer ( const XMLCh *  buf,
Mp7JrsNodePtr &  node 
)

Deserializes from a 16 bit Unicode buffer.

Parameters
bufSource buffer.
nodeNode to be used as parent of the fragement to be deserialized.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromBuffer ( const XMLCh *  buf)

Deserializes from a 16 bit Unicode buffer.

The root node of the fragment in the buffer will become the root node of the document.

Parameters
bufSource buffer.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromBuffer ( const char *  buf,
Mp7JrsNodePtr &  node 
)

Deserializes from a 8 bit buffer.

Parameters
bufSource buffer.
nodeNode to be used as parent of the fragement to be deserialized.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromBuffer ( const char *  buf)

Deserializes from a 8 bit buffer.

The root node of the fragment in the buffer will become the root node of the document.

Parameters
bufSource buffer.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromFile ( const XMLCh *  path,
Mp7JrsNodePtr &  node 
)

Deserializes from file.

Parameters
pathPath and file name of the source file.
nodeNode to be used as parent of the fragement to be deserialized.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromFile ( const XMLCh *  path)

Deserializes from file.

The root node of the fragment in the file will become the root node of the document.

Parameters
pathPath and file name of the source file.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromFile ( const char *  path,
Mp7JrsNodePtr &  node 
)

Deserializes from file.

Parameters
pathPath and file name of the source file.
nodeNode to be used as parent of the fragement to be deserialized.
Returns
The root node of the deserialized fragment.
Mp7JrsNodePtr Mp7JrsArchive::FromFile ( const char *  path)

Deserializes from file.

The root node of the fragment in the file will become the root node of the document.

Parameters
pathPath and file name of the source file.
Returns
The root node of the deserialized fragment.
bool Mp7JrsArchive::GetDefaultNamespace ( const XMLCh **  namespaceURI,
const XMLCh **  prefix 
)

Gets the namespace's name and prefix of the default namespace.

Parameters
namespaceURIDefault namespace name
prefixDefault namespace prefix, if used, otherwise maybe null
Returns
true if values set in the arguments, false if no namespace has been found. The prefix can be null.
bool Mp7JrsArchive::GetDoValidation ( )
inline

Get validation setting.

void Mp7JrsArchive::SetDefaultNamespace ( const XMLCh *  namespaceURI,
const XMLCh *  prefix 
)

Sets the default namespace.

If there is an existing entry it will be overwritten.

Parameters
namespaceURINamespace name
prefixdefault namespace prefix, if used, otherwise maybe 0
void Mp7JrsArchive::SetDoValidation ( bool  validate)
inline

Set if validation shall be done.

Parameters
validateIf true, validation will be done.
void Mp7JrsArchive::SetEncoding ( const char *  encoding)
inline

Set the encoding (UTF-8, UTF-16 ...) of XML document to be (de)serialized.

void Mp7JrsArchive::SetEncoding ( const XMLCh *  encoding)

Set the encoding (UTF-8, UTF-16 ...) of XML document to be (de)serialized.

void Mp7JrsArchive::SetForceNamespaceDeclaration ( bool  flag)
inline

Set whether the namespace declarations should be written to the XML root node or not (default: true).

This is necessary to avoid xsi namespace declarations in case of an xsi:type all over the place.

Parameters
flagIf true, all namespaces are declared in the XML root node.
void Mp7JrsArchive::SetFullSchemaChecking ( bool  fullSchema)
inline

Set if full schema checking shall be done.

Parameters
fullSchemaIf true, full schema checking will be done. IMPORTANT NOTE: This will cause Xerces 2.2 to crash at large maxOccurs values. Do not use!
void Mp7JrsArchive::SetSchemaLocation ( const char *  namespaceURI,
const char *  prefix,
const char *  schemaLocation 
)
inline

Set a schema location.

Parameters
namespaceURIURI of the schema namespace.
prefixNamespace prefix of the schema.
schemaLocationLocal path and file name of the schema.
void Mp7JrsArchive::SetSchemaLocation ( const XMLCh *  namespaceURI,
const XMLCh *  prefix,
const XMLCh *  schemaLocation 
)

Set a schema location.

Parameters
namespaceURIURI of the schema namespace.
prefixNamespace prefix of the schema.
schemaLocationLocal path and file name of the schema.
void Mp7JrsArchive::SetUsePrefixForDefaultNS ( bool  flag)
inline

Set whether or not you want your elements of the default namespace be prefixed (Initially: false).

Parameters
flagIf true, xmlns:mpeg7=urn:mpeg:mpeg7:schema:2004 is used instead of xmlns=urn:mpeg:mpeg7:schema:2004
void Mp7JrsArchive::SetWriteXMLDecl ( bool  decl)
inline

Set whether the XMLDecl header (version, encoding, standalone) shall be written.

Parameters
declIf true, the XMLDecl header will be written when serializing.
char * Mp7JrsArchive::ToBuffer ( Mp7JrsNodePtr &  node,
XMLCh *  nodeName = (XMLCh*)NULL,
bool  useTypeAttr = false 
)

Serializes to a 8 bit (Xerces) buffer.

Parameters
nodeRoot node of the subtree to be serialized.
nodeNameName of the root node (only necessary if a node of this type may have different names when used in different places of the schema).
useTypeAttrWrite the xsi:type attribute for all nodes in the subtree.
Returns
a 8 bit buffer (on the Xerces heap), which MUST be released via DeleteBuffer()
void Mp7JrsArchive::ToFile ( const XMLCh *  path,
Mp7JrsNodePtr &  node,
XMLCh *  nodeName = (XMLCh*)NULL,
bool  useTypeAttr = false 
)

Serializes to a file.

Parameters
pathPath and file name of the destination file.
nodeRoot node of the subtree to be serialized.
nodeNameName of the root node (only necessary if a node of this type may have different names when used in different places of the schema).
useTypeAttrWrite the xsi:type attribute for all nodes in the subtree.
void Mp7JrsArchive::ToFile ( const char *  path,
Mp7JrsNodePtr &  node,
XMLCh *  nodeName = (XMLCh*)NULL,
bool  useTypeAttr = false 
)

Serializes to a file.

Parameters
pathPath and file name of the destination file.
nodeRoot node of the subtree to be serialized.
nodeNameName of the root node (only necessary if a node of this type may have different names when used in different places of the schema).
useTypeAttrWrite the xsi:type attribute for all nodes in the subtree.
void Mp7JrsArchive::ToStdOut ( Mp7JrsNodePtr &  node,
XMLCh *  nodeName = (XMLCh*)NULL,
bool  useTypeAttr = false 
)

Serializes to a console (stdout).

Parameters
nodeRoot node of the subtree to be serialized.
nodeNameName of the root node (only necessary if a node of this type may have different names when used in different places of the schema).
useTypeAttrWrite the xsi:type attribute for all nodes in the subtree.
XMLCh * Mp7JrsArchive::ToWBuffer ( Mp7JrsNodePtr &  node,
XMLCh *  nodeName = (XMLCh*)NULL,
bool  useTypeAttr = false 
)

Serializes to a 16 bit Unicode (Xerces) buffer.

Parameters
nodeRoot node of the subtree to be serialized.
nodeNameName of the root node (only necessary if a node of this type may have different names when used in different places of the schema).
useTypeAttrWrite the xsi:type attribute for all nodes in the subtree.
Returns
a 16 bit Unicode buffer (on the Xerces heap), which MUST be released via DeleteBuffer()