XMLObject.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _OASYS_XML_OBJECT_H_
00018 #define _OASYS_XML_OBJECT_H_
00019 
00020 #include <string>
00021 #include <vector>
00022 #include "../debug/DebugUtils.h"
00023 
00024 namespace oasys {
00025 
00026 class StringBuffer;
00027 
00035 class XMLObject {
00036 public:
00041     typedef std::vector<std::string> Attrs;
00042 
00047     typedef std::vector<std::string> ProcInsts;
00048 
00052     typedef std::vector<XMLObject*> Elements;
00053     
00057     XMLObject(const std::string& tag);
00058 
00062     ~XMLObject();
00063 
00065     const std::string& tag()      const { return tag_; }
00066     const Attrs& attrs()          const { return attrs_; }
00067     const ProcInsts& proc_insts() const { return proc_insts_; }
00068     const Elements& elements()    const { return elements_; }
00069     const std::string& text()     const { return text_; }
00070     XMLObject* parent()           const { return parent_; }
00072 
00076     void add_attr(const std::string& attr, const std::string& val);
00077     
00081     void add_proc_inst(const std::string& target,
00082                        const std::string& data);
00083     
00088     void add_element(XMLObject* child);
00089 
00093     void add_text(const char* text, size_t len = 0);
00094 
00106     void to_string(StringBuffer* buf, int indent, int cur_indent = 0) const;
00107     
00108 protected:
00109     std::string tag_;
00110     Attrs       attrs_;
00111     ProcInsts   proc_insts_;
00112     Elements    elements_;
00113     std::string text_;
00114     XMLObject*  parent_;
00115 
00119     NO_ASSIGN_COPY(XMLObject);
00120 };
00121 
00122 } // namespace oasys
00123 
00124 #endif /* _OASYS_XML_OBJECT_H_ */

Generated on Thu Jun 7 12:54:30 2007 for DTN Reference Implementation by  doxygen 1.5.1