Line | |
---|
1 | |
---|
2 | #include "BBCXmlSerializer.h" |
---|
3 | |
---|
4 | namespace BBC { |
---|
5 | |
---|
6 | XmlSerializer::XmlSerializer() { |
---|
7 | mLoaded = false; |
---|
8 | } |
---|
9 | |
---|
10 | XmlSerializer::~XmlSerializer() { |
---|
11 | if (mLoaded) |
---|
12 | { |
---|
13 | if (mFile) |
---|
14 | { |
---|
15 | delete mFile; |
---|
16 | } |
---|
17 | mLoaded = false; |
---|
18 | } |
---|
19 | } |
---|
20 | |
---|
21 | TiXmlDocument* XmlSerializer::load(Ogre::String filename) |
---|
22 | { |
---|
23 | mFilename = filename; |
---|
24 | if (!mLoaded) |
---|
25 | { |
---|
26 | mFile = new TiXmlDocument(filename.c_str()); |
---|
27 | mLoaded = true; |
---|
28 | } |
---|
29 | else |
---|
30 | { |
---|
31 | if (mFile) |
---|
32 | { |
---|
33 | delete mFile; |
---|
34 | } |
---|
35 | mFile = new TiXmlDocument(filename.c_str()); |
---|
36 | } |
---|
37 | mFilename = filename; |
---|
38 | mFile->LoadFile(); |
---|
39 | return mFile; |
---|
40 | } |
---|
41 | |
---|
42 | void XmlSerializer::save() { |
---|
43 | if (mLoaded && (mFilename != ""))
|
---|
44 | {
|
---|
45 | Ogre::LogManager::getSingleton().logMessage("Filename:" + mFilename);
|
---|
46 | mFile->SaveFile(mFilename.c_str()); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | TiXmlDocument* XmlSerializer::create(Ogre::String filename) |
---|
51 | { |
---|
52 | if (!mLoaded) |
---|
53 | { |
---|
54 | mFile = new TiXmlDocument(filename.c_str()); |
---|
55 | mLoaded = true; |
---|
56 | } |
---|
57 | else |
---|
58 | { |
---|
59 | if (mFile) |
---|
60 | { |
---|
61 | delete mFile; |
---|
62 | } |
---|
63 | mFile = new TiXmlDocument(filename.c_str()); |
---|
64 | } |
---|
65 | mFilename = filename; |
---|
66 | return mFile; |
---|
67 | } |
---|
68 | |
---|
69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.