00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_XMLOBJECTIMPLEM_H
00030 #define TEUCHOS_XMLOBJECTIMPLEM_H
00031
00036 #include "Teuchos_map.hpp"
00037 #include "Teuchos_Array.hpp"
00038 #include "Teuchos_RefCountPtr.hpp"
00039
00040 namespace Teuchos
00041 {
00042
00043 class XMLObject;
00044
00049 class XMLObjectImplem
00050 {
00051 typedef Teuchos::map<string, string> Map;
00052
00053 public:
00055 XMLObjectImplem(const string& string);
00056
00058 XMLObjectImplem* deepCopy() const ;
00059
00061 void addAttribute(const string& name, const string& value);
00062
00064 void addChild(const XMLObject& child);
00065
00067 void addContent(const string& contentLine);
00068
00070 string toString() const ;
00071
00073 const string& getTag() const {return tag_;}
00074
00076 string header() const ;
00077
00079 string terminatedHeader() const ;
00080
00082 string footer() const {return "</" + getTag() + ">";}
00083
00085 bool hasAttribute(const string& name) const
00086 {return attributes_.find(name) != attributes_.end();}
00087
00089 const string& getAttribute(const string& name) const
00090 {return (*(attributes_.find(name))).second;}
00091
00093 int numChildren() const ;
00094
00096 const XMLObject& getChild(int i) const ;
00097
00099 int numContentLines() const {return content_.length();}
00100
00102 const string& getContentLine(int i) const {return content_[i];}
00103
00105 void print(ostream& os, int indent) const ;
00106
00107 private:
00108
00110 void printContent(ostream& os, int indent) const ;
00111
00112 string tag_;
00113 Map attributes_;
00114 Array<XMLObject> children_;
00115 Array<string> content_;
00116 };
00117
00118 }
00119
00120 #endif
00121