summaryrefslogtreecommitdiff
path: root/cpp/include/IceXML/Parser.h
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2003-09-11 21:12:38 +0000
committerMark Spruiell <mes@zeroc.com>2003-09-11 21:12:38 +0000
commitcbd7000724b0474b622ce8c7b47819630f2ab818 (patch)
tree6b6897c8cb85ce9b6f260df4d261d1b0341fa402 /cpp/include/IceXML/Parser.h
parentanother minor fix (diff)
downloadice-cbd7000724b0474b622ce8c7b47819630f2ab818.tar.bz2
ice-cbd7000724b0474b622ce8c7b47819630f2ab818.tar.xz
ice-cbd7000724b0474b622ce8c7b47819630f2ab818.zip
- Removed dependency on Xerces.
- Removed generic stream interface Ice::Stream and ice_marshal functions. - Removed XML stream implementation and related test. - Removed XML transformer and related test. - Removed slice2xsd. - Added C++ wrapper for the expat XML parser in IceXML::Parser. - Removed XML encoding from Freeze.
Diffstat (limited to 'cpp/include/IceXML/Parser.h')
-rw-r--r--cpp/include/IceXML/Parser.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/cpp/include/IceXML/Parser.h b/cpp/include/IceXML/Parser.h
new file mode 100644
index 00000000000..26a71fc73d7
--- /dev/null
+++ b/cpp/include/IceXML/Parser.h
@@ -0,0 +1,142 @@
+// **********************************************************************
+//
+// Copyright (c) 2003
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+#ifndef ICE_XML_PARSER_H
+#define ICE_XML_PARSER_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Handle.h>
+#include <IceUtil/Exception.h>
+
+#include <vector>
+#include <map>
+
+namespace IceXML
+{
+
+class ParserException : public IceUtil::Exception
+{
+public:
+ ParserException(const std::string&);
+ ParserException(const char*, int, const std::string&);
+
+ virtual std::string ice_name() const;
+ virtual void ice_print(std::ostream&) const;
+ virtual Exception* ice_clone() const;
+ virtual void ice_throw() const;
+
+private:
+ std::string _reason;
+};
+
+class Node;
+typedef IceUtil::Handle< Node > NodePtr;
+
+typedef std::vector<NodePtr> NodeList;
+
+class Element;
+typedef IceUtil::Handle< Element > ElementPtr;
+
+class Text;
+typedef IceUtil::Handle< Text > TextPtr;
+
+class Document;
+typedef IceUtil::Handle< Document > DocumentPtr;
+
+typedef std::map<std::string, std::string> Attributes;
+
+class Node : public IceUtil::Shared
+{
+public:
+ virtual ~Node();
+
+ virtual NodePtr getParent() const;
+ virtual std::string getName() const;
+ virtual std::string getValue() const;
+ virtual NodeList getChildren() const;
+ virtual Attributes getAttributes() const;
+ virtual std::string getAttribute(const std::string&) const;
+
+ virtual bool addChild(const NodePtr&);
+
+protected:
+ Node(const NodePtr&, const std::string&, const std::string&);
+
+ NodePtr _parent;
+ std::string _name;
+ std::string _value;
+};
+
+class Element : public Node
+{
+public:
+ Element(const NodePtr&, const std::string&, const Attributes&);
+ virtual ~Element();
+
+ virtual NodeList getChildren() const;
+ virtual Attributes getAttributes() const;
+ virtual std::string getAttribute(const std::string&) const;
+
+ virtual bool addChild(const NodePtr&);
+
+private:
+ NodeList _children;
+ Attributes _attributes;
+};
+
+class Text : public Node
+{
+public:
+ Text(const NodePtr&, const std::string&);
+ virtual ~Text();
+};
+
+class Document : public Node
+{
+public:
+ Document();
+ virtual ~Document();
+
+ virtual NodeList getChildren() const;
+
+ virtual bool addChild(const NodePtr&);
+
+private:
+ NodeList _children;
+};
+
+class Handler
+{
+public:
+ virtual ~Handler();
+
+ virtual void startElement(const std::string&, const Attributes&) = 0;
+ virtual void endElement(const std::string&) = 0;
+ virtual void characters(const std::string&) = 0;
+ virtual void error(const std::string&, int, int);
+};
+
+class Parser
+{
+public:
+ static DocumentPtr parse(const std::string&);
+ static DocumentPtr parse(std::istream&);
+
+ static void parse(const std::string&, Handler&);
+ static void parse(std::istream&, Handler&);
+};
+
+}
+
+#endif