mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 18:31:37 +00:00
HPL1: replace files with generic streams in tinyxml
This commit is contained in:
parent
2bf971bef9
commit
a41b8d026c
@ -580,7 +580,7 @@ void TiXmlElement::SetAttribute(const std::string &name, const std::string &_val
|
||||
}
|
||||
#endif
|
||||
|
||||
void TiXmlElement::Print(Common::DumpFile &file, int depth) const {
|
||||
void TiXmlElement::Print(Common::WriteStream &file, int depth) const {
|
||||
int i;
|
||||
for (i = 0; i < depth; i++) {
|
||||
file.writeString(" ");
|
||||
@ -731,22 +731,22 @@ bool TiXmlDocument::LoadFile(const char *filename, TiXmlEncoding encoding) {
|
||||
value = filename;
|
||||
|
||||
// reading in binary mode so that tinyxml can normalize the EOL
|
||||
Common::File file;
|
||||
file.open(value);
|
||||
|
||||
Common::File file;
|
||||
file.open(value);
|
||||
|
||||
if (file.isOpen()) {
|
||||
bool result = LoadFile(file, encoding);
|
||||
return result;
|
||||
} else {
|
||||
debugC(Hpl1::kDebugFilePath, "file %s not found", value.c_str());
|
||||
debugC(Hpl1::kDebugFilePath, "file %s not found", value.c_str());
|
||||
SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool TiXmlDocument::LoadFile(Common::File &file, TiXmlEncoding encoding) {
|
||||
bool TiXmlDocument::LoadFile(Common::SeekableReadStream &file, TiXmlEncoding encoding) {
|
||||
if (file.err()) {
|
||||
debugC(Hpl1::kDebugResourceLoading, "file %s could not be read", file.getName());
|
||||
Hpl1::logError(Hpl1::kDebugResourceLoading, "xml file could not be read%c", '\n');
|
||||
SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
@ -792,9 +792,9 @@ bool TiXmlDocument::LoadFile(Common::File &file, TiXmlEncoding encoding) {
|
||||
char *buf = new char[length + 1];
|
||||
buf[0] = 0;
|
||||
|
||||
file.read(buf, length);
|
||||
file.read(buf, length);
|
||||
if (file.err()) {
|
||||
debugC(Hpl1::kDebugResourceLoading, "file read for %s failed", file.getName());
|
||||
Hpl1::logError(Hpl1::kDebugResourceLoading, "xml file read for failed%c", '\n');
|
||||
delete[] buf;
|
||||
SetError(TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN);
|
||||
return false;
|
||||
@ -863,7 +863,7 @@ bool TiXmlDocument::SaveFile(const char *filename) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TiXmlDocument::SaveFile(Common::DumpFile &fp) const {
|
||||
bool TiXmlDocument::SaveFile(Common::WriteStream &fp) const {
|
||||
if (useMicrosoftBOM) {
|
||||
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
||||
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
||||
@ -897,7 +897,7 @@ TiXmlNode *TiXmlDocument::Clone() const {
|
||||
return clone;
|
||||
}
|
||||
|
||||
void TiXmlDocument::Print(Common::DumpFile &cfile, int depth) const {
|
||||
void TiXmlDocument::Print(Common::WriteStream &cfile, int depth) const {
|
||||
for (const TiXmlNode *node = FirstChild(); node; node = node->NextSibling()) {
|
||||
node->Print(cfile, depth);
|
||||
cfile.writeString("\n");
|
||||
@ -952,7 +952,7 @@ TiXmlAttribute* TiXmlAttribute::Previous()
|
||||
}
|
||||
*/
|
||||
|
||||
void TiXmlAttribute::Print(Common::DumpFile *cfile, int /*depth*/, TIXML_STRING *str) const {
|
||||
void TiXmlAttribute::Print(Common::WriteStream *cfile, int /*depth*/, TIXML_STRING *str) const {
|
||||
TIXML_STRING n, v;
|
||||
|
||||
PutString(name, &n);
|
||||
@ -1020,7 +1020,7 @@ void TiXmlComment::operator=(const TiXmlComment &base) {
|
||||
base.CopyTo(this);
|
||||
}
|
||||
|
||||
void TiXmlComment::Print(Common::DumpFile &cfile, int depth) const {
|
||||
void TiXmlComment::Print(Common::WriteStream &cfile, int depth) const {
|
||||
for (int i = 0; i < depth; i++) {
|
||||
cfile.writeString(" ");
|
||||
}
|
||||
@ -1045,7 +1045,7 @@ TiXmlNode *TiXmlComment::Clone() const {
|
||||
return clone;
|
||||
}
|
||||
|
||||
void TiXmlText::Print(Common::DumpFile &cfile, int depth) const {
|
||||
void TiXmlText::Print(Common::WriteStream &cfile, int depth) const {
|
||||
if (cdata) {
|
||||
int i;
|
||||
cfile.writeString("\n");
|
||||
@ -1110,7 +1110,7 @@ void TiXmlDeclaration::operator=(const TiXmlDeclaration ©) {
|
||||
copy.CopyTo(this);
|
||||
}
|
||||
|
||||
void TiXmlDeclaration::Print(Common::DumpFile *cfile, int /*depth*/, TIXML_STRING *str) const {
|
||||
void TiXmlDeclaration::Print(Common::WriteStream *cfile, int /*depth*/, TIXML_STRING *str) const {
|
||||
if (cfile)
|
||||
cfile->writeString("<?xml ");
|
||||
if (str)
|
||||
@ -1171,7 +1171,7 @@ TiXmlNode *TiXmlDeclaration::Clone() const {
|
||||
return clone;
|
||||
}
|
||||
|
||||
void TiXmlUnknown::Print(Common::DumpFile &cfile, int depth) const {
|
||||
void TiXmlUnknown::Print(Common::WriteStream &cfile, int depth) const {
|
||||
for (int i = 0; i < depth; i++)
|
||||
cfile.writeString(" ");
|
||||
cfile.writeString("<" + value + ">");
|
||||
|
@ -165,7 +165,7 @@ public:
|
||||
|
||||
(For an unformatted stream, use the << operator.)
|
||||
*/
|
||||
virtual void Print(Common::DumpFile &file, int depth) const = 0;
|
||||
virtual void Print(Common::WriteStream &file, int depth) const = 0;
|
||||
|
||||
/** The world does not agree on whether white space should be kept or
|
||||
not. In order to make everyone happy, these global, static functions
|
||||
@ -792,10 +792,10 @@ public:
|
||||
virtual const char *Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding);
|
||||
|
||||
// Prints this Attribute to a FILE stream.
|
||||
virtual void Print(Common::DumpFile &file, int depth) const {
|
||||
virtual void Print(Common::WriteStream &file, int depth) const {
|
||||
Print(&file, depth, 0);
|
||||
}
|
||||
void Print(Common::DumpFile *cfile, int depth, TIXML_STRING *str) const;
|
||||
void Print(Common::WriteStream *cfile, int depth, TIXML_STRING *str) const;
|
||||
|
||||
// [internal use]
|
||||
// Set the document pointer so the attribute can report errors.
|
||||
@ -1016,7 +1016,7 @@ public:
|
||||
/// Creates a new Element and returns it - the returned element is a copy.
|
||||
virtual TiXmlNode *Clone() const;
|
||||
// Print the Element to a FILE stream.
|
||||
virtual void Print(Common::DumpFile &cfile, int depth) const;
|
||||
virtual void Print(Common::WriteStream &cfile, int depth) const;
|
||||
|
||||
/* Attribtue parsing starts: next char past '<'
|
||||
returns: next char past '>'
|
||||
@ -1066,7 +1066,7 @@ public:
|
||||
/// Returns a copy of this Comment.
|
||||
virtual TiXmlNode *Clone() const;
|
||||
// Write this Comment to a FILE stream.
|
||||
virtual void Print(Common::DumpFile &cfile, int depth) const;
|
||||
virtual void Print(Common::WriteStream &cfile, int depth) const;
|
||||
|
||||
/* Attribtue parsing starts: at the ! of the !--
|
||||
returns: next char past '>'
|
||||
@ -1123,7 +1123,7 @@ public:
|
||||
void operator=(const TiXmlText &base) { base.CopyTo(this); }
|
||||
|
||||
// Write this text object to a FILE stream.
|
||||
virtual void Print(Common::DumpFile &cfile, int depth) const;
|
||||
virtual void Print(Common::WriteStream &cfile, int depth) const;
|
||||
|
||||
/// Queries whether this represents text using a CDATA section.
|
||||
bool CDATA() const { return cdata; }
|
||||
@ -1199,8 +1199,8 @@ public:
|
||||
/// Creates a copy of this Declaration and returns it.
|
||||
virtual TiXmlNode *Clone() const;
|
||||
// Print this declaration to a FILE stream.
|
||||
virtual void Print(Common::DumpFile *cfile, int depth, TIXML_STRING *str) const;
|
||||
virtual void Print(Common::DumpFile &cfile, int depth) const {
|
||||
virtual void Print(Common::WriteStream *cfile, int depth, TIXML_STRING *str) const;
|
||||
virtual void Print(Common::WriteStream &cfile, int depth) const {
|
||||
Print(&cfile, depth, 0);
|
||||
}
|
||||
|
||||
@ -1244,7 +1244,7 @@ public:
|
||||
/// Creates a copy of this Unknown and returns it.
|
||||
virtual TiXmlNode *Clone() const;
|
||||
// Print this Unknown to a FILE stream.
|
||||
virtual void Print(Common::DumpFile &cfile, int depth) const;
|
||||
virtual void Print(Common::WriteStream &cfile, int depth) const;
|
||||
|
||||
virtual const char *Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding);
|
||||
|
||||
@ -1302,9 +1302,9 @@ public:
|
||||
will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
|
||||
file location. Streaming may be added in the future.
|
||||
*/
|
||||
bool LoadFile(Common::File &file, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING);
|
||||
bool LoadFile(Common::SeekableReadStream &file, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING);
|
||||
/// Save a file using the given FILE*. Returns true if successful.
|
||||
bool SaveFile(Common::DumpFile &) const;
|
||||
bool SaveFile(Common::WriteStream &) const;
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
bool LoadFile(const std::string &filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING) ///< STL std::string version.
|
||||
@ -1408,7 +1408,7 @@ public:
|
||||
// char* PrintToMemory() const;
|
||||
|
||||
/// Print this Document to file
|
||||
virtual void Print(Common::DumpFile &file, int depth = 0) const;
|
||||
virtual void Print(Common::WriteStream &file, int depth = 0) const;
|
||||
// [internal use]
|
||||
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user