mirror of
https://github.com/edubart/otclient.git
synced 2025-12-20 23:47:12 +01:00
merge total remake
This commit is contained in:
41
src/framework/otml/otmldocument.cpp
Normal file
41
src/framework/otml/otmldocument.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "otmldocument.h"
|
||||
#include "otmlparser.h"
|
||||
#include "otmlemitter.h"
|
||||
|
||||
#include <core/resourcemanager.h>
|
||||
|
||||
OTMLDocumentPtr OTMLDocument::create()
|
||||
{
|
||||
OTMLDocumentPtr doc(new OTMLDocument);
|
||||
doc->setTag("doc");
|
||||
return doc;
|
||||
}
|
||||
|
||||
OTMLDocumentPtr OTMLDocument::parse(const std::string& fileName)
|
||||
{
|
||||
std::stringstream fin;
|
||||
g_resources.loadFile(fileName, fin);
|
||||
return parse(fin, fileName);
|
||||
}
|
||||
|
||||
OTMLDocumentPtr OTMLDocument::parse(std::istream& in, const std::string& source)
|
||||
{
|
||||
OTMLDocumentPtr doc(new OTMLDocument);
|
||||
doc->setSource(source);
|
||||
OTMLParser parser(doc, in);
|
||||
parser.parse();
|
||||
return doc;
|
||||
}
|
||||
|
||||
std::string OTMLDocument::emit()
|
||||
{
|
||||
return OTMLEmitter::emitNode(shared_from_this());
|
||||
}
|
||||
|
||||
bool OTMLDocument::save(const std::string& fileName)
|
||||
{
|
||||
setSource(fileName);
|
||||
|
||||
return g_resources.saveFile(fileName, emit());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user