osgEarth 2.1.1
Public Member Functions | Static Public Member Functions | Protected Attributes

osgEarth::XmlDocument Class Reference

Inheritance diagram for osgEarth::XmlDocument:
Collaboration diagram for osgEarth::XmlDocument:

List of all members.

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 XmlDocumentload (const std::string &location)
static XmlDocumentload (const URI &uri)
static XmlDocumentload (std::istream &in, const URIContext &context=URIContext())

Protected Attributes

URI _sourceURI
std::string _name
osg::ref_ptr< XmlElement_root

Detailed Description

Definition at line 129 of file XmlUtils.


Constructor & Destructor Documentation

XmlDocument::XmlDocument ( )

Definition at line 260 of file XmlUtils.cpp.

                         :
XmlElement( "Document" )
{
    //nop
}

Here is the caller graph for this function:

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
}

Member Function Documentation

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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Here is the call graph for this function:

XmlDocument * XmlDocument::load ( const std::string &  location) [static]

Definition at line 377 of file XmlUtils.cpp.

{
    return load( URI(location) );
}

Here is the caller graph for this function:

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;    
}

Here is the call graph for this function:

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 );
    }*/
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::string osgEarth::XmlDocument::_name [protected]

Definition at line 152 of file XmlUtils.

osg::ref_ptr<XmlElement> osgEarth::XmlDocument::_root [protected]

Definition at line 153 of file XmlUtils.

Definition at line 151 of file XmlUtils.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines