|
@@ -40,34 +40,19 @@ public:
|
|
|
VfsXMLPrinter(FileStream& stream, bool compact = false, int depth = 0);
|
|
|
~VfsXMLPrinter() override;
|
|
|
|
|
|
- // Re-implement private functionality in TinyXML2 library, this is just a copy-paste job
|
|
|
+ // Re-implement protected functionality in TinyXML2 library, and make it public
|
|
|
+ // (This is a bit dirty, but it's necessary for the PrettyXMLPrinter)
|
|
|
bool CompactMode(const tinyxml2::XMLElement& element) override { return tinyxml2::XMLPrinter::CompactMode(element); }
|
|
|
+ void PrintSpace(int depth) override { tinyxml2::XMLPrinter::PrintSpace(depth); }
|
|
|
+ inline void Write(const char* data) { Write(data, strlen(data)); }
|
|
|
|
|
|
// Add VFS friendly implementations of output functions
|
|
|
void Print(const char* format, ...) override;
|
|
|
void Write(const char* data, size_t size) override;
|
|
|
- inline void Write(const char* data) { Write(data, strlen(data)); }
|
|
|
void Putc(char ch) override;
|
|
|
- void PrintSpace(int depth) override { tinyxml2::XMLPrinter::PrintSpace(depth); }
|
|
|
-
|
|
|
- // Overwrite Visitation of elements to add newlines before attributes
|
|
|
- void PushAttribute(const char* name, const char* value, bool compactMode);
|
|
|
|
|
|
// Accept a virtual FileStream instead of a FILE pointer
|
|
|
FileStream& m_Stream;
|
|
|
-
|
|
|
- // Track private fields that are necessary for private functionality in TinyXML2
|
|
|
- int _depth;
|
|
|
- bool _processEntities;
|
|
|
-
|
|
|
- enum
|
|
|
- {
|
|
|
- ENTITY_RANGE = 64,
|
|
|
- BUF_SIZE = 200
|
|
|
- };
|
|
|
-
|
|
|
- bool _entityFlag[ENTITY_RANGE];
|
|
|
- bool _restrictedEntityFlag[ENTITY_RANGE];
|
|
|
};
|
|
|
|
|
|
class VfsXMLDocument : public tinyxml2::XMLDocument
|
|
@@ -182,7 +167,7 @@ public:
|
|
|
/// Visit a document.
|
|
|
virtual bool VisitEnter(const tinyxml2::XMLDocument& doc)
|
|
|
{
|
|
|
- _processEntities = doc.ProcessEntities();
|
|
|
+ mProcessEntities = doc.ProcessEntities();
|
|
|
return mInnerPrinter.VisitEnter(doc);
|
|
|
}
|
|
|
|
|
@@ -197,7 +182,7 @@ public:
|
|
|
/// Visit an element.
|
|
|
virtual bool VisitExit(const tinyxml2::XMLElement& element)
|
|
|
{
|
|
|
- _depth--;
|
|
|
+ mDepth--;
|
|
|
return mInnerPrinter.VisitExit(element);
|
|
|
}
|
|
|
|
|
@@ -224,17 +209,20 @@ public:
|
|
|
{
|
|
|
return mInnerPrinter.Visit(unknown);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
void PushAttribute(const char* name, const char* value, bool compactMode);
|
|
|
|
|
|
// Re-implement private functionality in TinyXML2 library, this is just a copy-paste job
|
|
|
void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities.
|
|
|
+
|
|
|
+ // The inner printer we are wrapping, we only support VfsXMLPrinter based classes because
|
|
|
+ // stock tinyxml printer is very closed
|
|
|
VfsXMLPrinter& mInnerPrinter;
|
|
|
|
|
|
// Track private fields that are necessary for private functionality in TinyXML2
|
|
|
- int _depth;
|
|
|
- bool _processEntities;
|
|
|
- bool _compactMode;
|
|
|
+ int mDepth;
|
|
|
+ bool mProcessEntities;
|
|
|
+ bool mCompactMode;
|
|
|
|
|
|
enum
|
|
|
{
|
|
@@ -242,8 +230,8 @@ public:
|
|
|
BUF_SIZE = 200
|
|
|
};
|
|
|
|
|
|
- bool _entityFlag[ENTITY_RANGE];
|
|
|
- bool _restrictedEntityFlag[ENTITY_RANGE];
|
|
|
+ bool mEntityFlag[ENTITY_RANGE];
|
|
|
+ bool mRestrictedEntityFlag[ENTITY_RANGE];
|
|
|
};
|
|
|
|
|
|
|