XMLDocument.cc

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 
00018 #include "XMLDocument.h"
00019 #include "XMLObject.h"
00020 #include "util/StringBuffer.h"
00021 
00022 namespace oasys {
00023 
00024 //----------------------------------------------------------------------
00025 XMLDocument::XMLDocument()
00026     : root_(NULL)
00027 {
00028 }
00029 
00030 //----------------------------------------------------------------------
00031 XMLDocument::~XMLDocument()
00032 {
00033     delete root_;
00034 }
00035 
00036 //----------------------------------------------------------------------
00037 void
00038 XMLDocument::add_header(const char* header, size_t len)
00039 {
00040     if (len == 0) {
00041         len = strlen(header);
00042     }
00043     
00044     header_.append(header, len);
00045 }
00046 
00047 //----------------------------------------------------------------------
00048 void
00049 XMLDocument::set_root(XMLObject* root)
00050 {
00051     ASSERT(root_ == NULL);
00052     root_ = root;
00053 }
00054 
00055 //----------------------------------------------------------------------
00056 void
00057 XMLDocument::to_string(StringBuffer* buf, int indent) const
00058 {
00059     if (header_.length() != 0) {
00060         buf->append(header_.c_str(), header_.length());
00061         buf->append("\n");
00062     }
00063     
00064     root_->to_string(buf, indent);
00065 }
00066 
00067 } // namespace oasys

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