osgEarth 2.1.1
|
Public Member Functions | |
XmlDocument () | |
XmlDocument (const Config &conf) | |
virtual | ~XmlDocument () |
void | store (std::ostream &out) const |
const std::string & | getName () const |
virtual Config | getConfig () const |
Static Public Member Functions | |
static XmlDocument * | load (const std::string &location) |
static XmlDocument * | load (const URI &uri) |
static XmlDocument * | load (std::istream &in, const URIContext &context=URIContext()) |
Protected Attributes | |
URI | _sourceURI |
std::string | _name |
osg::ref_ptr< XmlElement > | _root |
XmlDocument::XmlDocument | ( | ) |
Definition at line 260 of file XmlUtils.cpp.
: XmlElement( "Document" ) { //nop }
XmlDocument::XmlDocument | ( | const Config & | conf | ) |
Definition at line 266 of file XmlUtils.cpp.
: XmlElement( conf ) { //NOP }
XmlDocument::~XmlDocument | ( | ) | [virtual] |
Definition at line 272 of file XmlUtils.cpp.
{
//NOP
}
Config XmlDocument::getConfig | ( | ) | const [virtual] |
Reimplemented from osgEarth::XmlElement.
Definition at line 437 of file XmlUtils.cpp.
{ Config conf = XmlElement::getConfig(); conf.setURIContext( _sourceURI.full() ); return conf; }
const std::string& osgEarth::XmlDocument::getName | ( | ) | const |
Reimplemented from osgEarth::XmlElement.
XmlDocument * XmlDocument::load | ( | const URI & | uri | ) | [static] |
Definition at line 383 of file XmlUtils.cpp.
{ std::string buffer; if ( HTTPClient::readString( uri.full(), buffer ) != HTTPClient::RESULT_OK ) { return 0L; } std::stringstream buf(buffer); XmlDocument* result = load(buf); if ( result ) result->_sourceURI = uri; return result; }
XmlDocument * XmlDocument::load | ( | const std::string & | location | ) | [static] |
XmlDocument * XmlDocument::load | ( | std::istream & | in, |
const URIContext & | context = URIContext() |
||
) | [static] |
Definition at line 402 of file XmlUtils.cpp.
{ TiXmlDocument xmlDoc; //Read the entire document into a string std::stringstream buffer; buffer << in.rdbuf(); std::string xmlStr(buffer.str()); removeDocType( xmlStr ); //OE_NOTICE << xmlStr; XmlDocument* doc = NULL; xmlDoc.Parse(xmlStr.c_str()); if ( xmlDoc.Error() ) { std::stringstream buf; buf << xmlDoc.ErrorDesc() << " (row " << xmlDoc.ErrorRow() << ", col " << xmlDoc.ErrorCol() << ")"; std::string str = buf.str(); OE_WARN << "Error in XML document: " << str << std::endl; if ( !uriContext.referrer().empty() ) OE_WARN << uriContext.referrer() << std::endl; } if ( !xmlDoc.Error() && xmlDoc.RootElement() ) { doc = new XmlDocument(); processNode( doc, xmlDoc.RootElement() ); doc->_sourceURI = URI("", uriContext); } return doc; }
void XmlDocument::store | ( | std::ostream & | out | ) | const |
Definition at line 481 of file XmlUtils.cpp.
{ out << "<?xml version=\"1.0\"?>" << std::endl; storeNode( this, 0, out); /*for( XmlNodeList::const_iterator i = getChildren().begin(); i != getChildren().end(); i++ ) { storeNode( i->get(), 0, out ); }*/ }
std::string osgEarth::XmlDocument::_name [protected] |
osg::ref_ptr<XmlElement> osgEarth::XmlDocument::_root [protected] |
URI osgEarth::XmlDocument::_sourceURI [protected] |