|
Teuchos - Trilinos Tools Package Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 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_RCP.hpp" 00039 00040 namespace Teuchos 00041 { 00042 00043 class XMLObject; 00044 00049 class XMLObjectImplem 00050 { 00051 typedef Teuchos::map<std::string, std::string> Map; 00052 00053 public: 00055 XMLObjectImplem(const std::string& tag); 00056 00058 XMLObjectImplem* deepCopy() const ; 00059 00061 void addAttribute(const std::string& name, const std::string& value); 00062 00064 void addChild(const XMLObject& child); 00065 00067 void addContent(const std::string& contentLine); 00068 00070 const std::string& getTag() const {return tag_;} 00071 00073 bool hasAttribute(const std::string& name) const 00074 {return attributes_.find(name) != attributes_.end();} 00075 00077 const std::string& getAttribute(const std::string& name) const 00078 {return (*(attributes_.find(name))).second;} 00079 00081 int numChildren() const ; 00082 00084 const XMLObject& getChild(int i) const ; 00085 00087 int numContentLines() const {return content_.length();} 00088 00090 const std::string& getContentLine(int i) const {return content_[i];} 00091 00093 void print(std::ostream& os, int indent) const ; 00094 00096 std::string toString() const ; 00097 00099 std::string header(bool strictXML = false) const ; 00100 00102 std::string terminatedHeader(bool strictXML = false) const ; 00103 00105 std::string footer() const {return "</" + getTag() + ">";} 00106 00107 private: 00108 00110 void printContent(std::ostream& os, int indent) const ; 00111 00113 static std::string XMLifyAttVal(const std::string &attval); 00114 00115 std::string tag_; 00116 Map attributes_; 00117 Array<XMLObject> children_; 00118 Array<std::string> content_; 00119 00120 }; 00121 00122 } 00123 00124 #endif 00125
1.7.4