- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Io::Xml::Stream::XmlStreamObjectFactory Class Reference

`#include <XmlStreamObjectFactory.h>`

Inheritance diagram for Mers::Utils::Io::Xml::Stream::XmlStreamObjectFactory:

[legend]
Collaboration diagram for Mers::Utils::Io::Xml::Stream::XmlStreamObjectFactory:

[legend]
List of all members.

## Public Member Functions
| XmlStreamObjectFactory (XmlStreamReader &reader)
## Protected Member Functions
bool | checkStart (const std::string &tag)
void | checkEnd (bool advance=false)
void | checkNotNull (void *object, const char *message=NULL)
## Protected Attributes
XmlStreamReader & | reader

## Detailed Description

Base class for factories that create objects using the XmlStreamReader interface. The factories consist of a number of creator functions, each of which constructs one kind (class) of objects in our framework. For example, the CommonXmlFactory in Models/Common/Io/Xml has functions for constructing variables, domains, values, algebraic expressions, and constraints. By the convention, the XML stream should be positioned at the start tag (StartElement) for the created object when a creator function is called, and it should be position at the corresponding end tag (EndElement) when the creator function returns. At the beginning, the creator function should check that the start tag has the correct name (using checkStart, for example) and return NULL if it does not. In this manner, each function only processes the portion of the XML file, which it is responsible for, and several creator functions can be called by the parent, in order to process the element.

See also:
  CommonXmlFactory

Definition at line 46 of file XmlStreamObjectFactory.h.

## Constructor & Destructor Documentation

XmlStreamObjectFactory::XmlStreamObjectFactory | ( | XmlStreamReader & | reader | ) |

Creates a factory with the given reader.

Definition at line 22 of file XmlStreamObjectFactory.cpp.

## Member Function Documentation

bool Mers::Utils::Io::Xml::Stream::XmlStreamObjectFactory::checkStart | ( | const std::string & | tag | ) | `[protected]`

Checks that the current event is a StartElement with a given local name.

Exceptions:

  | XmlStreamException | if the current event is not a StartElement.

Returns:
  true if the local name is equal to <tag>.

void XmlStreamObjectFactory::checkEnd | ( | bool | advance = `false` | ) | `[protected]`

Checks that the current event is an EndElement.

Parameters:

  | advance | Advance the stream to the next tag before checking.

Exceptions:

  | XmlStreamException | if the current event is not an EndElement.

Definition at line 40 of file XmlStreamObjectFactory.cpp.

References Mers::Utils::Io::Xml::Stream::XmlStreamReader::getLocation(), Mers::Utils::Io::Xml::Stream::XmlStreamReader::isEndElement(), Mers::Utils::Io::Xml::Stream::XmlStreamReader::nextTag(), and reader.

Here is the call graph for this function:

void XmlStreamObjectFactory::checkNotNull | ( | void * | object,
|  | const char * | message = `NULL` |
| ) |  |  | `[protected]`

Checks that the given object pointer is not null. This method is typically used to verify that a creator function(s) was able to construct an object, based on the current element.

Parameters:

  | object | The object pointer to verify.
  | message | The message to throw in the exception if the object pointer is null.

Definition at line 50 of file XmlStreamObjectFactory.cpp.

References Mers::Utils::Io::Xml::Stream::XmlStreamReader::getLocalName(), Mers::Utils::Io::Xml::Stream::XmlStreamReader::getLocation(), and reader.

Here is the call graph for this function:

## Member Data Documentation

XmlStreamReader& Mers::Utils::Io::Xml::Stream::XmlStreamObjectFactory::reader`[protected]`

The reader, used by the factory to parse the data.

Definition at line 93 of file XmlStreamObjectFactory.h.

Referenced by checkEnd(), and checkNotNull().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Stream/XmlStreamObjectFactory.h
- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Stream/XmlStreamObjectFactory.cpp