Changeset 42:6f97b6d207aa in rrlib_xml for tDocument.cpp


Ignore:
Timestamp:
16.06.2012 19:08:32 (11 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Renamed to rrlib_xml and stripped XML from class names

File:
1 moved

Legend:

Unmodified
Added
Removed
  • tDocument.cpp

    r40 r42  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    tXMLDocument.cpp 
     22/*!\file    tDocument.cpp 
    2323 * 
    2424 * \author  Tobias Foehst 
     
    2828 */ 
    2929//---------------------------------------------------------------------- 
    30 #include "rrlib/xml2_wrapper/tXMLDocument.h" 
     30#include "rrlib/xml/tDocument.h" 
    3131 
    3232//---------------------------------------------------------------------- 
     
    3838// Internal includes with "" 
    3939//---------------------------------------------------------------------- 
    40 #include "rrlib/xml2_wrapper/tXML2WrapperException.h" 
    41 #include "rrlib/xml2_wrapper/tCleanupHandler.h" 
     40#include "rrlib/xml/tException.h" 
     41#include "rrlib/xml/tCleanupHandler.h" 
    4242 
    4343//---------------------------------------------------------------------- 
     
    5555namespace rrlib 
    5656{ 
    57 namespace xml2 
     57namespace xml 
    5858{ 
    5959 
     
    7171 
    7272//---------------------------------------------------------------------- 
    73 // tXMLDocument constructors 
     73// tDocument constructors 
    7474//---------------------------------------------------------------------- 
    75 tXMLDocument::tXMLDocument() 
     75tDocument::tDocument() 
    7676  : document(xmlNewDoc(reinterpret_cast<const xmlChar *>("1.0"))), 
    7777    root_node(0) 
     
    8181} 
    8282 
    83 tXMLDocument::tXMLDocument(const std::string &file_name, bool validate) 
     83tDocument::tDocument(const std::string &file_name, bool validate) 
    8484  : document(xmlReadFile(file_name.c_str(), 0, validate ? XML_PARSE_DTDVALID : 0)), 
    85     root_node(reinterpret_cast<tXMLNode *>(xmlDocGetRootElement(this->document))) 
     85    root_node(reinterpret_cast<tNode *>(xmlDocGetRootElement(this->document))) 
    8686{ 
    8787  assert(this->document); 
    8888  if (!this->document) 
    8989  { 
    90     throw tXML2WrapperException("Could not parse XML file `" + file_name + "'!"); 
     90    throw tException("Could not parse XML file `" + file_name + "'!"); 
    9191  } 
    9292  tCleanupHandler::Instance(); 
    9393} 
    9494 
    95 tXMLDocument::tXMLDocument(const void *buffer, size_t size, bool validate) 
     95tDocument::tDocument(const void *buffer, size_t size, bool validate) 
    9696  : document(xmlReadMemory(reinterpret_cast<const char *>(buffer), size, "noname.xml", 0, validate ? XML_PARSE_DTDVALID : 0)), 
    97     root_node(reinterpret_cast<tXMLNode *>(xmlDocGetRootElement(this->document))) 
     97    root_node(reinterpret_cast<tNode *>(xmlDocGetRootElement(this->document))) 
    9898{ 
    9999  if (!this->document) 
    100100  { 
    101     throw tXML2WrapperException("Could not parse XML from memory buffer `" + std::string(reinterpret_cast<const char *>(buffer)) + "'!"); 
     101    throw tException("Could not parse XML from memory buffer `" + std::string(reinterpret_cast<const char *>(buffer)) + "'!"); 
    102102  } 
    103103  tCleanupHandler::Instance(); 
    104104} 
    105105 
    106 tXMLDocument::tXMLDocument(tXMLDocument && other) 
     106tDocument::tDocument(tDocument && other) 
    107107  : document(0), 
    108108    root_node(0) 
     
    113113 
    114114//---------------------------------------------------------------------- 
    115 // tXMLDocument destructor 
     115// tDocument destructor 
    116116//---------------------------------------------------------------------- 
    117 tXMLDocument::~tXMLDocument() 
     117tDocument::~tDocument() 
    118118{ 
    119119  if (this->document) 
     
    124124 
    125125//---------------------------------------------------------------------- 
    126 // tXMLDocument operator = 
     126// tDocument operator = 
    127127//---------------------------------------------------------------------- 
    128 tXMLDocument &tXMLDocument::operator = (const tXMLDocument & other) 
     128tDocument &tDocument::operator = (const tDocument & other) 
    129129{ 
    130130  if (this == &other) 
     
    134134  xmlFreeDoc(this->document); 
    135135  this->document = xmlCopyDoc(other.document, true); 
    136   this->root_node = reinterpret_cast<tXMLNode *>(xmlDocGetRootElement(this->document)); 
     136  this->root_node = reinterpret_cast<tNode *>(xmlDocGetRootElement(this->document)); 
    137137  return *this; 
    138138} 
    139139 
    140140//---------------------------------------------------------------------- 
    141 // tXMLDocument RootNode 
     141// tDocument RootNode 
    142142//---------------------------------------------------------------------- 
    143 tXMLNode &tXMLDocument::RootNode() 
     143tNode &tDocument::RootNode() 
    144144{ 
    145145  if (!this->root_node) 
    146146  { 
    147     throw tXML2WrapperException("No root node defined for this document!"); 
     147    throw tException("No root node defined for this document!"); 
    148148  } 
    149149  return *this->root_node; 
     
    151151 
    152152//---------------------------------------------------------------------- 
    153 // tXMLDocument AddRootNode 
     153// tDocument AddRootNode 
    154154//---------------------------------------------------------------------- 
    155 tXMLNode &tXMLDocument::AddRootNode(const std::string &name) 
     155tNode &tDocument::AddRootNode(const std::string &name) 
    156156{ 
    157157  if (this->root_node) 
    158158  { 
    159     throw tXML2WrapperException("Root node already exists with name `" + name + "'!"); 
     159    throw tException("Root node already exists with name `" + name + "'!"); 
    160160  } 
    161   this->root_node = reinterpret_cast<tXMLNode *>(xmlNewNode(0, reinterpret_cast<const xmlChar *>(name.c_str()))); 
     161  this->root_node = reinterpret_cast<tNode *>(xmlNewNode(0, reinterpret_cast<const xmlChar *>(name.c_str()))); 
    162162  xmlDocSetRootElement(this->document, this->root_node); 
    163163  return *this->root_node; 
     
    165165 
    166166//---------------------------------------------------------------------- 
    167 // tXMLDocument WriteToFile 
     167// tDocument WriteToFile 
    168168//---------------------------------------------------------------------- 
    169 void tXMLDocument::WriteToFile(const std::string &file_name, int compression) const 
     169void tDocument::WriteToFile(const std::string &file_name, int compression) const 
    170170{ 
    171171  if (compression) 
Note: See TracChangeset for help on using the changeset viewer.