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

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Stream/XmlStreamReader.h

    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 #ifndef XML_STREAM_READER_H
    00015 #define XML_STREAM_READER_H
    00016
    00017 #include <string>
    00018
    00019 #include "XmlStreamLocation.h"
    00020
    00021 namespace Mers {
    00022         namespace Utils {
    00023                 namespace Io {
    00024                         namespace Xml {
    00025                                 namespace Stream {
    00026
    00037                                         class XmlStreamReader {
    00038                                         public:
    00043                                                 enum EventType {ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD,
    00044                                                         END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION,
    00045                                                         ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION,
    00046                                                         PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT,
    00047                                                         START_ELEMENT};
    00048
    00049                                                 XmlStreamReader() {};
    00050
    00051                                                 virtual ~XmlStreamReader() {};
    00052
    00053                                                 //-----------------------------------------
    00054                                                 // Get functions
    00055                                                 //-----------------------------------------
    00056                                                 virtual int getAttributeCount() const = 0;
    00057
    00058                                                 virtual const std::string&
    00059                                                 getAttributeValue(const std::string& name) const = 0;
    00060
    00061                                                 virtual const std::string&
    00062                                                 getAttributeValue(const std::string& namespaceURI,
    00063                                                         const std::string& localName) const = 0;
    00064
    00069                                                 virtual const std::string& getElementText();
    00070
    00071                                                 virtual double getElementTextAsDouble();
    00072
    00073                                                 virtual int getElementTextAsInt();
    00074
    00075                                                 virtual const std::string& getLocalName() const = 0;
    00076
    00077                                                 virtual const XmlStreamLocation& getLocation() const = 0;
    00078
    00079                                                 virtual const std::string& getText() const = 0;
    00080
    00081
    00082                                                 //-----------------------------------------
    00083                                                 // Event type functions
    00084                                                 //-----------------------------------------
    00085                                                 virtual EventType getEventType() const = 0;
    00086
    00091                                                 virtual bool isCharacters() const;
    00092
    00097                                                 virtual bool isStartElement() const;
    00098
    00103                                                 virtual bool isEndElement() const;
    00104
    00110                                                 virtual bool isWhiteSpace() const;
    00111
    00112
    00113                                                 //-----------------------------------------
    00114                                                 // Stream navigation functions
    00115                                                 //-----------------------------------------
    00119                                                 virtual bool hasNext() const = 0;
    00120
    00127                                                 virtual EventType next() = 0;
    00128
    00137                                                 virtual EventType nextTag();
    00138
    00145                                                 virtual EventType nextSibling() = 0;
    00146
    00154                                                 virtual EventType nextSiblingTag();
    00155
    00156                                                 //-----------------------------------------
    00157                                                 // Helper functions
    00158                                                 //-----------------------------------------
    00159                                         protected:
    00163                                                 void checkHasNext() const;
    00164
    00165                                         private:
    00169                                                 std::string elementText;
    00170
    00171                                                 // disallow copy constructor and assignment operator
    00172                                                 XmlStreamReader(const XmlStreamReader& other);
    00173                                                 XmlStreamReader& operator=(const XmlStreamReader& other);
    00174
    00175                                         };
    00176                                 }
    00177                         }
    00178                 }
    00179         }
    00180 }
    00181
    00182 #endif // XML_STREAM_READER_H