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

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

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include "XmlStreamObjectFactory.h"
    00015 #include "XmlStreamException.h"
    00016
    00017 using namespace Mers::Utils::Io::Xml::Stream;
    00018 using std::string;
    00019
    00021
    00022 XmlStreamObjectFactory::XmlStreamObjectFactory(XmlStreamReader& myReader)
    00023   : reader(myReader)
    00024 {
    00025 }
    00026
    00028
    00029 bool XmlStreamObjectFactory::checkStart(const string& tag)
    00030 {
    00031   if(!reader.isStartElement()) {
    00032     throw XmlStreamException("Expected start element with tag name: " +tag,
    00033                              reader.getLocation());
    00034   }
    00035   return reader.getLocalName() == tag;
    00036 }
    00037
    00039
    00040 void XmlStreamObjectFactory::checkEnd(bool advance)
    00041 {
    00042   if(advance) reader.nextTag();
    00043   if(!reader.isEndElement()) {
    00044     throw XmlStreamException("Expected end element", reader.getLocation());
    00045   }
    00046 }
    00047
    00049
    00050 void XmlStreamObjectFactory::checkNotNull(void* object, const char* message)
    00051 {
    00052   if(NULL == object) {
    00053     if(message) throw XmlStreamException(message, reader.getLocation());
    00054     else throw XmlStreamException("Invalid tag " + reader.getLocalName(),
    00055                                   reader.getLocation());
    00056   }
    00057 }
    00058
    00060