also rename .h to .hpp in miniswig dir
authorMatthias Braun <matze@braunis.de>
Sun, 26 Jun 2005 13:41:26 +0000 (13:41 +0000)
committerMatthias Braun <matze@braunis.de>
Sun, 26 Jun 2005 13:41:26 +0000 (13:41 +0000)
SVN-Revision: 2643

17 files changed:
tools/miniswig/create_docu.cpp
tools/miniswig/create_docu.h [deleted file]
tools/miniswig/create_docu.hpp [new file with mode: 0644]
tools/miniswig/create_wrapper.cpp
tools/miniswig/create_wrapper.h [deleted file]
tools/miniswig/create_wrapper.hpp [new file with mode: 0644]
tools/miniswig/globals.h [deleted file]
tools/miniswig/globals.hpp [new file with mode: 0644]
tools/miniswig/lexer.ll
tools/miniswig/main.cpp
tools/miniswig/parser.yy
tools/miniswig/tree.cpp
tools/miniswig/tree.h [deleted file]
tools/miniswig/tree.hpp [new file with mode: 0644]
tools/miniswig/xmlwriter.cpp
tools/miniswig/xmlwriter.h [deleted file]
tools/miniswig/xmlwriter.hpp [new file with mode: 0644]

index b1e1722..3310e48 100644 (file)
@@ -1,9 +1,9 @@
-#include "tree.h"
+#include "tree.hpp"
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
-#include "create_docu.h"
-#include "globals.h"
+#include "create_docu.hpp"
+#include "globals.hpp"
 
 void
 DocuCreator::create_docu(Namespace* ns)
diff --git a/tools/miniswig/create_docu.h b/tools/miniswig/create_docu.h
deleted file mode 100644 (file)
index 1f679b5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __CREATE_DOCU_H__
-#define __CREATE_DOCU_H__
-
-#include "tree.h"
-#include "xmlwriter.h"
-
-class DocuCreator
-{
-public:
-    const char* ind;
-    std::ostream& out;
-    XmlWriter writer;
-
-    DocuCreator(std::ostream& _out = std::cout)
-        : out(_out), writer(out)
-    {
-        ind = "  ";
-    }
-
-    void create_docu(Namespace* ns);
-    void create_class_docu(Class* _class);
-    void create_function_docu(Class* _class, Function* function);
-    std::string get_type(const Type& type);
-};
-
-#endif
diff --git a/tools/miniswig/create_docu.hpp b/tools/miniswig/create_docu.hpp
new file mode 100644 (file)
index 0000000..0345de4
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __CREATE_DOCU_H__
+#define __CREATE_DOCU_H__
+
+#include "tree.hpp"
+#include "xmlwriter.hpp"
+
+class DocuCreator
+{
+public:
+    const char* ind;
+    std::ostream& out;
+    XmlWriter writer;
+
+    DocuCreator(std::ostream& _out = std::cout)
+        : out(_out), writer(out)
+    {
+        ind = "  ";
+    }
+
+    void create_docu(Namespace* ns);
+    void create_class_docu(Class* _class);
+    void create_function_docu(Class* _class, Function* function);
+    std::string get_type(const Type& type);
+};
+
+#endif
index 330792d..7eae391 100644 (file)
@@ -1,9 +1,9 @@
-#include "tree.h"
+#include "tree.hpp"
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
-#include "create_wrapper.h"
-#include "globals.h"
+#include "create_wrapper.hpp"
+#include "globals.hpp"
 
 void
 WrapperCreator::create_wrapper(Namespace* ns)
diff --git a/tools/miniswig/create_wrapper.h b/tools/miniswig/create_wrapper.h
deleted file mode 100644 (file)
index 359c1ed..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __CREATE_WRAPPER_H__
-#define __CREATE_WRAPPER_H__
-
-#include "tree.h"
-
-class WrapperCreator
-{
-public:
-    /// this is used for indentation
-    const char* ind;
-    // output stream
-    std::ostream& out;
-    std::ostream& hppout;
-
-    WrapperCreator(std::ostream& _out = std::cout, std::ostream& _hppout = std::cout)
-        : out(_out), hppout(_hppout)
-    {
-        ind = "  ";
-    }
-
-    void create_wrapper(Namespace* ns);
-    void create_class_wrapper(Class* _class);
-    void create_class_release_hook(Class* _class);
-    void create_function_wrapper(Class* _class, Function* function);
-    void prepare_argument(const Type& type, size_t idx, const std::string& var);
-    void push_to_stack(const Type& type, const std::string& var);
-};
-
-#endif
-
diff --git a/tools/miniswig/create_wrapper.hpp b/tools/miniswig/create_wrapper.hpp
new file mode 100644 (file)
index 0000000..97c14df
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __CREATE_WRAPPER_H__
+#define __CREATE_WRAPPER_H__
+
+#include "tree.hpp"
+
+class WrapperCreator
+{
+public:
+    /// this is used for indentation
+    const char* ind;
+    // output stream
+    std::ostream& out;
+    std::ostream& hppout;
+
+    WrapperCreator(std::ostream& _out = std::cout, std::ostream& _hppout = std::cout)
+        : out(_out), hppout(_hppout)
+    {
+        ind = "  ";
+    }
+
+    void create_wrapper(Namespace* ns);
+    void create_class_wrapper(Class* _class);
+    void create_class_release_hook(Class* _class);
+    void create_function_wrapper(Class* _class, Function* function);
+    void prepare_argument(const Type& type, size_t idx, const std::string& var);
+    void push_to_stack(const Type& type, const std::string& var);
+};
+
+#endif
+
diff --git a/tools/miniswig/globals.h b/tools/miniswig/globals.h
deleted file mode 100644 (file)
index 51cef65..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __GLOBALS_H__
-#define __GLOBALS_H__
-
-#include "tree.h"
-#include <iostream>
-
-// parsing
-extern CompilationUnit* unit;
-extern bool search_down;
-extern Namespace* search_namespace;
-extern Namespace* current_namespace;
-extern std::string last_docucomment;
-// the first file indicated by # 1 "..."
-// (this is what the C preprocessor outputs so that you know which was the
-// original file before preprocessing
-extern std::string original_file;
-// the filename where the current fragment came from (before it was included by
-// the preprocessor)
-extern std::string current_file;
-// get line number inside the current_file
-int getCurrentLine();
-
-// config/output
-extern std::istream* input;
-extern std::string inputfile;
-extern std::string modulename;
-extern std::string selected_namespace;
-
-#endif
-
diff --git a/tools/miniswig/globals.hpp b/tools/miniswig/globals.hpp
new file mode 100644 (file)
index 0000000..9f6f65d
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __GLOBALS_H__
+#define __GLOBALS_H__
+
+#include "tree.hpp"
+#include <iostream>
+
+// parsing
+extern CompilationUnit* unit;
+extern bool search_down;
+extern Namespace* search_namespace;
+extern Namespace* current_namespace;
+extern std::string last_docucomment;
+// the first file indicated by # 1 "..."
+// (this is what the C preprocessor outputs so that you know which was the
+// original file before preprocessing
+extern std::string original_file;
+// the filename where the current fragment came from (before it was included by
+// the preprocessor)
+extern std::string current_file;
+// get line number inside the current_file
+int getCurrentLine();
+
+// config/output
+extern std::istream* input;
+extern std::string inputfile;
+extern std::string modulename;
+extern std::string selected_namespace;
+
+#endif
+
index 21b13f4..ccaf067 100644 (file)
@@ -3,9 +3,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <iostream>
-#include "tree.h"
+#include "tree.hpp"
 #include "parser.hpp"
-#include "globals.h"
+#include "globals.hpp"
 
 #define YY_DECL int yylex(YYSTYPE* yylval)
 
index 0140a85..2655a64 100644 (file)
@@ -2,10 +2,10 @@
 #include <fstream>
 #include <vector>
 #include <string>
-#include "tree.h"
-#include "globals.h"
-#include "create_wrapper.h"
-#include "create_docu.h"
+#include "tree.hpp"
+#include "globals.hpp"
+#include "create_wrapper.hpp"
+#include "create_docu.hpp"
 
 extern int yyparse();
 extern int yylex();
index 4875401..1aae8ce 100644 (file)
@@ -3,8 +3,8 @@
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
-#include "tree.h"
-#include "globals.h"
+#include "tree.hpp"
+#include "globals.hpp"
 
 %}
 
index e26452d..3d5413e 100644 (file)
@@ -1,4 +1,4 @@
-#include "tree.h"
+#include "tree.hpp"
 
 BasicType BasicType::VOID("void");
 BasicType BasicType::BOOL("bool");
diff --git a/tools/miniswig/tree.h b/tools/miniswig/tree.h
deleted file mode 100644 (file)
index 2e7149c..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-#ifndef __TREE_H__
-#define __TREE_H__
-
-#include <vector>
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-#include <assert.h>
-
-class Namespace;
-
-class AtomicType {
-public:
-    AtomicType()
-        : parent(0)
-    { }
-    virtual ~AtomicType()
-    { }
-
-    virtual void write_c(std::ostream& out)
-    {
-        out << name;
-    }
-
-    std::string name;
-    Namespace* parent;
-};
-
-class BasicType : public AtomicType {
-public:
-    static BasicType VOID;
-    static BasicType BOOL;
-    static BasicType CHAR;
-    static BasicType SHORT;
-    static BasicType INT;
-    static BasicType LONG;
-    static BasicType FLOAT;
-    static BasicType DOUBLE;
-
-private:
-    BasicType(const std::string& name)
-    { 
-        this->name = name;
-    }                                     
-};
-
-class Type {
-public:
-    Type() 
-        : atomic_type(0), _unsigned(false), _const(false), _static(false),
-        pointer(0), ref(0)
-    { }
-
-    void write_c_type(std::ostream& out)
-    {
-        if(_static)
-            out << "static ";        
-        if(_const)
-            out << "const ";
-        atomic_type->write_c(out);
-        for(int i = 0; i < pointer; ++i)
-            out << "*";
-        for(int i = 0; i < ref; ++i)
-            out << "&";
-    }
-
-    bool is_void() const
-    {
-        if(atomic_type == 0)
-            return true;
-        if(atomic_type == &BasicType::VOID && pointer == 0)
-            return true;
-        return false;
-    }
-
-    AtomicType* atomic_type;
-    bool _unsigned;
-    bool _const;
-    bool _static;
-    // number of '*' in the type declaration...
-    int pointer;
-    // number of '&' in the type declaration...
-    int ref;
-};
-
-class HSQUIRRELVMType : public AtomicType {
-public:
-    HSQUIRRELVMType()
-    {
-        this->name = "HSQUIRRELVM";
-        assert(_instance == 0);
-        _instance = this;
-    }
-    virtual ~HSQUIRRELVMType()
-    {
-        assert(_instance == this);
-        _instance = 0;
-    }
-
-    static HSQUIRRELVMType* instance()
-    {
-        return _instance;
-    }
-private:
-    static HSQUIRRELVMType* _instance;
-};
-
-class StringType : public AtomicType {
-public:
-    StringType()
-    {
-        this->name = "string";
-        assert(_instance == 0);
-        _instance = this;
-    }
-    virtual ~StringType()
-    {
-        assert(_instance == this);
-        _instance = 0;
-    }
-
-    static StringType* instance()
-    {
-        return _instance;
-    }
-
-    virtual void write_c(std::ostream& out)
-    {
-        out << "std::string";
-    }
-
-private:
-    static StringType* _instance;   
-};
-
-class Parameter {
-public:
-    std::string name;
-    Type type;
-};
-
-class ClassMember {
-public:
-    virtual ~ClassMember()
-    { }
-
-    enum Visbility {
-        PUBLIC,
-        PROTECTED,
-        PRIVATE
-    };
-    Visbility visibility;
-};
-
-class Function : public ClassMember {
-public:
-    enum FuncType {
-        FUNCTION,
-        CONSTRUCTOR,
-        DESTRUCTOR
-    };
-    FuncType type;
-    std::string docu_comment;
-    std::string name;
-    Type return_type;
-    std::vector<Parameter> parameters;
-};
-
-class Class : public AtomicType {
-public:
-    ~Class() {
-        for(std::vector<ClassMember*>::iterator i = members.begin();
-                i != members.end(); ++i)
-            delete *i;
-    }
-    
-    std::vector<ClassMember*> members;
-    std::string docu_comment;
-};
-
-class Namespace {
-public:
-    Namespace() {
-        parent = 0;
-    }
-    virtual ~Namespace() {
-        for(std::vector<Function*>::iterator i = functions.begin();
-                i != functions.end(); ++i)
-            delete *i;
-        for(std::vector<AtomicType*>::iterator i = types.begin();
-                i != types.end(); ++i)
-            delete *i;
-        for(std::vector<Namespace*>::iterator i = namespaces.begin();
-                i != namespaces.end(); ++i)
-            delete *i;
-    }
-    void add_type(AtomicType* type)
-    {
-        types.push_back(type);
-        type->parent = this;
-    }
-    void add_namespace(Namespace* ns)
-    {
-        namespaces.push_back(ns);
-        ns->parent = this;
-    }
-    AtomicType* _findType(const std::string& name, bool godown = false) {
-        for(std::vector<AtomicType*>::iterator i = types.begin();
-                i != types.end(); ++i) {
-            AtomicType* type = *i;
-            if(type->name == name)
-                return type;
-        }
-        if(godown && parent)
-            return parent->_findType(name, true);
-
-        return 0;
-    }
-
-    Namespace* _findNamespace(const std::string& name, bool godown = false) {
-        for(std::vector<Namespace*>::iterator i = namespaces.begin();
-                i != namespaces.end(); ++i) {
-            Namespace* ns = *i;
-            if(ns->name == name)
-                return ns;
-        }
-        if(godown && parent)
-            return parent->_findNamespace(name, true);
-
-        return 0;
-    }
-
-    Namespace* findNamespace(const std::string& name, bool godown = false) {
-        Namespace* ret = _findNamespace(name, godown);
-        if(!ret) {
-            std::ostringstream msg;
-            msg << "Couldn't find namespace '" << name << "'.";
-            throw std::runtime_error(msg.str());
-        }
-
-        return ret;
-    }
-                                                                             
-    std::vector<Function*> functions;
-    std::vector<AtomicType*> types;
-    std::vector<Namespace*> namespaces;
-
-    Namespace* parent;
-    std::string name;
-};
-
-class CompilationUnit : public Namespace {
-public:
-};
-
-#endif
-
diff --git a/tools/miniswig/tree.hpp b/tools/miniswig/tree.hpp
new file mode 100644 (file)
index 0000000..2e7149c
--- /dev/null
@@ -0,0 +1,258 @@
+#ifndef __TREE_H__
+#define __TREE_H__
+
+#include <vector>
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <stdexcept>
+#include <assert.h>
+
+class Namespace;
+
+class AtomicType {
+public:
+    AtomicType()
+        : parent(0)
+    { }
+    virtual ~AtomicType()
+    { }
+
+    virtual void write_c(std::ostream& out)
+    {
+        out << name;
+    }
+
+    std::string name;
+    Namespace* parent;
+};
+
+class BasicType : public AtomicType {
+public:
+    static BasicType VOID;
+    static BasicType BOOL;
+    static BasicType CHAR;
+    static BasicType SHORT;
+    static BasicType INT;
+    static BasicType LONG;
+    static BasicType FLOAT;
+    static BasicType DOUBLE;
+
+private:
+    BasicType(const std::string& name)
+    { 
+        this->name = name;
+    }                                     
+};
+
+class Type {
+public:
+    Type() 
+        : atomic_type(0), _unsigned(false), _const(false), _static(false),
+        pointer(0), ref(0)
+    { }
+
+    void write_c_type(std::ostream& out)
+    {
+        if(_static)
+            out << "static ";        
+        if(_const)
+            out << "const ";
+        atomic_type->write_c(out);
+        for(int i = 0; i < pointer; ++i)
+            out << "*";
+        for(int i = 0; i < ref; ++i)
+            out << "&";
+    }
+
+    bool is_void() const
+    {
+        if(atomic_type == 0)
+            return true;
+        if(atomic_type == &BasicType::VOID && pointer == 0)
+            return true;
+        return false;
+    }
+
+    AtomicType* atomic_type;
+    bool _unsigned;
+    bool _const;
+    bool _static;
+    // number of '*' in the type declaration...
+    int pointer;
+    // number of '&' in the type declaration...
+    int ref;
+};
+
+class HSQUIRRELVMType : public AtomicType {
+public:
+    HSQUIRRELVMType()
+    {
+        this->name = "HSQUIRRELVM";
+        assert(_instance == 0);
+        _instance = this;
+    }
+    virtual ~HSQUIRRELVMType()
+    {
+        assert(_instance == this);
+        _instance = 0;
+    }
+
+    static HSQUIRRELVMType* instance()
+    {
+        return _instance;
+    }
+private:
+    static HSQUIRRELVMType* _instance;
+};
+
+class StringType : public AtomicType {
+public:
+    StringType()
+    {
+        this->name = "string";
+        assert(_instance == 0);
+        _instance = this;
+    }
+    virtual ~StringType()
+    {
+        assert(_instance == this);
+        _instance = 0;
+    }
+
+    static StringType* instance()
+    {
+        return _instance;
+    }
+
+    virtual void write_c(std::ostream& out)
+    {
+        out << "std::string";
+    }
+
+private:
+    static StringType* _instance;   
+};
+
+class Parameter {
+public:
+    std::string name;
+    Type type;
+};
+
+class ClassMember {
+public:
+    virtual ~ClassMember()
+    { }
+
+    enum Visbility {
+        PUBLIC,
+        PROTECTED,
+        PRIVATE
+    };
+    Visbility visibility;
+};
+
+class Function : public ClassMember {
+public:
+    enum FuncType {
+        FUNCTION,
+        CONSTRUCTOR,
+        DESTRUCTOR
+    };
+    FuncType type;
+    std::string docu_comment;
+    std::string name;
+    Type return_type;
+    std::vector<Parameter> parameters;
+};
+
+class Class : public AtomicType {
+public:
+    ~Class() {
+        for(std::vector<ClassMember*>::iterator i = members.begin();
+                i != members.end(); ++i)
+            delete *i;
+    }
+    
+    std::vector<ClassMember*> members;
+    std::string docu_comment;
+};
+
+class Namespace {
+public:
+    Namespace() {
+        parent = 0;
+    }
+    virtual ~Namespace() {
+        for(std::vector<Function*>::iterator i = functions.begin();
+                i != functions.end(); ++i)
+            delete *i;
+        for(std::vector<AtomicType*>::iterator i = types.begin();
+                i != types.end(); ++i)
+            delete *i;
+        for(std::vector<Namespace*>::iterator i = namespaces.begin();
+                i != namespaces.end(); ++i)
+            delete *i;
+    }
+    void add_type(AtomicType* type)
+    {
+        types.push_back(type);
+        type->parent = this;
+    }
+    void add_namespace(Namespace* ns)
+    {
+        namespaces.push_back(ns);
+        ns->parent = this;
+    }
+    AtomicType* _findType(const std::string& name, bool godown = false) {
+        for(std::vector<AtomicType*>::iterator i = types.begin();
+                i != types.end(); ++i) {
+            AtomicType* type = *i;
+            if(type->name == name)
+                return type;
+        }
+        if(godown && parent)
+            return parent->_findType(name, true);
+
+        return 0;
+    }
+
+    Namespace* _findNamespace(const std::string& name, bool godown = false) {
+        for(std::vector<Namespace*>::iterator i = namespaces.begin();
+                i != namespaces.end(); ++i) {
+            Namespace* ns = *i;
+            if(ns->name == name)
+                return ns;
+        }
+        if(godown && parent)
+            return parent->_findNamespace(name, true);
+
+        return 0;
+    }
+
+    Namespace* findNamespace(const std::string& name, bool godown = false) {
+        Namespace* ret = _findNamespace(name, godown);
+        if(!ret) {
+            std::ostringstream msg;
+            msg << "Couldn't find namespace '" << name << "'.";
+            throw std::runtime_error(msg.str());
+        }
+
+        return ret;
+    }
+                                                                             
+    std::vector<Function*> functions;
+    std::vector<AtomicType*> types;
+    std::vector<Namespace*> namespaces;
+
+    Namespace* parent;
+    std::string name;
+};
+
+class CompilationUnit : public Namespace {
+public:
+};
+
+#endif
+
index 1a85247..b44635f 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <stdexcept>
 #include <sstream>
-#include "xmlwriter.h"
+#include "xmlwriter.hpp"
 
 XmlWriter::XmlWriter(std::ostream& outstream)
     : out(outstream), indent(0)
diff --git a/tools/miniswig/xmlwriter.h b/tools/miniswig/xmlwriter.h
deleted file mode 100644 (file)
index 97e4344..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef __XMLWRITER_H__
-#define __XMLWRITER_H__
-
-#include <iostream>
-#include <vector>
-#include <string>
-
-/** This class is a class which helps printing formated xml output.
- * Example:
- *  This sequence:
- *   xml.openTag("world");
- *   xml.writeAttribute("name", "foo");
- *   xml.writeTag("bar");
- *   xml.writeTag("baz");
- *   xml.writeAttribute("name", "boo");
- *   xml.writeAttribute("style", "old");
- *   xml.write("text");
- *   xml.closeTag("world");
- *  results in this output:
- *   <world name="foo">
- *     <bar/>
- *     <baz name="boo" style="old">text</baz>
- *   </world>
- */
-class XmlWriter {
-public:
-    XmlWriter(std::ostream& out);
-    ~XmlWriter();
-   
-    /** Start a xml tag which contains subtags */
-    void openTag(const char* name);
-    /** Closes an xml tag with subtags */
-    void closeTag(const char* name);
-
-    void writeTag(const char* name);
-
-    template <class T> 
-      void comment(const T& outp)
-      {   // This routine writes just about anything as an XML comment.
-       newLine();
-       out << "<!-- " << outp ;
-       closetag = " -->";
-      }
-
-
-    template<class T>
-    void write(const T& text)
-    {
-        if (closetag[0]=='>') {
-            out << ">";
-            closetag = "";
-        } else if (closetag[0]=='/') {
-           out << ">"; // eventually we should place a \n here
-           closetag = "</";
-           closetag += lasttag;
-           closetag += ">";
-       }
-       out << text;
-    }
-
-    template<class T>
-    void writeAttribute(const char* name, T value)
-    {
-       out << " " << name << "=\"" << value << "\"";
-    }
-
-private:
-    void newLine();
-    void closeTag();
-    
-    std::ostream& out;
-    int indent;
-    std::string closetag;
-    std::string lasttag;
-    std::vector<std::string> sections;
-};
-
-#endif
-
diff --git a/tools/miniswig/xmlwriter.hpp b/tools/miniswig/xmlwriter.hpp
new file mode 100644 (file)
index 0000000..97e4344
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef __XMLWRITER_H__
+#define __XMLWRITER_H__
+
+#include <iostream>
+#include <vector>
+#include <string>
+
+/** This class is a class which helps printing formated xml output.
+ * Example:
+ *  This sequence:
+ *   xml.openTag("world");
+ *   xml.writeAttribute("name", "foo");
+ *   xml.writeTag("bar");
+ *   xml.writeTag("baz");
+ *   xml.writeAttribute("name", "boo");
+ *   xml.writeAttribute("style", "old");
+ *   xml.write("text");
+ *   xml.closeTag("world");
+ *  results in this output:
+ *   <world name="foo">
+ *     <bar/>
+ *     <baz name="boo" style="old">text</baz>
+ *   </world>
+ */
+class XmlWriter {
+public:
+    XmlWriter(std::ostream& out);
+    ~XmlWriter();
+   
+    /** Start a xml tag which contains subtags */
+    void openTag(const char* name);
+    /** Closes an xml tag with subtags */
+    void closeTag(const char* name);
+
+    void writeTag(const char* name);
+
+    template <class T> 
+      void comment(const T& outp)
+      {   // This routine writes just about anything as an XML comment.
+       newLine();
+       out << "<!-- " << outp ;
+       closetag = " -->";
+      }
+
+
+    template<class T>
+    void write(const T& text)
+    {
+        if (closetag[0]=='>') {
+            out << ">";
+            closetag = "";
+        } else if (closetag[0]=='/') {
+           out << ">"; // eventually we should place a \n here
+           closetag = "</";
+           closetag += lasttag;
+           closetag += ">";
+       }
+       out << text;
+    }
+
+    template<class T>
+    void writeAttribute(const char* name, T value)
+    {
+       out << " " << name << "=\"" << value << "\"";
+    }
+
+private:
+    void newLine();
+    void closeTag();
+    
+    std::ostream& out;
+    int indent;
+    std::string closetag;
+    std::string lasttag;
+    std::vector<std::string> sections;
+};
+
+#endif
+