Files
yugioh-legacy-engine/server/irrlicht/source/Irrlicht/CXMLWriter.h
T
donnyandClaude Fable 5.1 da27435cdb server: import the duel server (nanahira/ygopro server at 52c868ce)
The server tree of https://code.moenext.com/nanahira/ygopro.git, branch
server, commit 52c868ce071ea0f2fcb0cf39bf2fb4151d12b90c, stock: gframe/,
premake5.lua, .ci/, LICENSE, and gframe/ygopro.rc + .ico (upstream keeps
them in resource/ and copies them in before building). No game assets, no
scripts, no ocgcore submodule: the core is ../core.

The third-party sources upstream's Windows CI downloads are vendored here
at the positions its premake expects, each with its premake fragment from
upstream's premake/ folder inside it: lua 5.4.8, sqlite 3.53.3, libevent
2.1.13-stable (tests, samples and autotools helpers left out; the files
its Windows prebuild copies into include/ left out), zlib 1.3.2 (contrib
and examples left out), xz 5.8.3 (src/liblzma + src/common only), and
irrlicht 1.9 from mycard at 20f86d25: include/ plus the source/Irrlicht
headers and the 11 .cpp files the server's zip reader project compiles.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-14 20:58:21 -07:00

156 lines
4.6 KiB
C++

// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef IRR_C_XML_WRITER_H_INCLUDED
#define IRR_C_XML_WRITER_H_INCLUDED
#include "IXMLWriter.h"
#ifdef _IRR_COMPILE_WITH_XML_
#include <wchar.h>
#include "IWriteFile.h"
namespace irr
{
namespace io
{
//! creates an IXMLReader
IXMLWriter* createIXMLWriter(IWriteFile* file);
//! creates an IXMLReader
IXMLWriterUTF8* createIXMLWriterUTF8(IWriteFile* file);
// Stuff needed by implementations for all character types
// TODO: With some more work it could maybe become a pure template based thing like CXMLReaderImpl
// and replace the type based writer implementations. Sorry, too lazy for now :-/
template<class char_type>
class CXMLWriterCommon
{
public:
//! Constructor
CXMLWriterCommon(IWriteFile* file): File(file), Tabs(0), TextWrittenLast(false)
{
if (File)
File->grab();
}
//! Destructor
virtual ~CXMLWriterCommon()
{
if (File)
File->drop();
}
struct XMLSpecialCharacters
{
char_type Character;
const char_type* Symbol;
};
protected:
IWriteFile* File;
s32 Tabs;
bool TextWrittenLast;
};
//! Implementation providing methods for making it easier to write XML files.
class CXMLWriter : public IXMLWriter, public CXMLWriterCommon<wchar_t>
{
public:
//! Constructor
CXMLWriter(IWriteFile* file);
//! Destructor
virtual ~CXMLWriter() {}
//! Writes a xml 1.0 header like <?xml version="1.0"?>
virtual void writeXMLHeader() IRR_OVERRIDE;
//! Writes an xml element with maximal 5 attributes
virtual void writeElement(const wchar_t* name, bool empty=false,
const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0,
const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0,
const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0,
const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0,
const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) IRR_OVERRIDE;
//! Writes an xml element with any number of attributes
virtual void writeElement(const wchar_t* name, bool empty,
core::array<core::stringw> &names, core::array<core::stringw> &values) IRR_OVERRIDE;
//! Writes a comment into the xml file
virtual void writeComment(const wchar_t* comment) IRR_OVERRIDE;
//! Writes the closing tag for an element. Like </foo>
virtual void writeClosingTag(const wchar_t* name) IRR_OVERRIDE;
//! Writes a text into the file. All occurrences of special characters like
//! & (&amp;), < (&lt;), > (&gt;), and " (&quot;) are automatically replaced.
virtual void writeText(const wchar_t* text) IRR_OVERRIDE;
//! Writes a line break
virtual void writeLineBreak() IRR_OVERRIDE;
private:
void writeAttribute(const wchar_t* att, const wchar_t* name);
};
//! Implementation providing methods for making it easier to write XML files.
class CXMLWriterUTF8 : public IXMLWriterUTF8, public CXMLWriterCommon<c8>
{
public:
//! Constructor
CXMLWriterUTF8(IWriteFile* file);
//! Destructor
virtual ~CXMLWriterUTF8() {}
//! Writes a xml 1.0 header like <?xml version="1.0"?>
virtual void writeXMLHeader() IRR_OVERRIDE;
//! Writes an xml element with maximal 5 attributes
virtual void writeElement(const c8* name, bool empty=false,
const c8* attr1Name = 0, const c8* attr1Value = 0,
const c8* attr2Name = 0, const c8* attr2Value = 0,
const c8* attr3Name = 0, const c8* attr3Value = 0,
const c8* attr4Name = 0, const c8* attr4Value = 0,
const c8* attr5Name = 0, const c8* attr5Value = 0) IRR_OVERRIDE;
//! Writes an xml element with any number of attributes
virtual void writeElement(const c8* name, bool empty,
core::array<core::stringc> &names, core::array<core::stringc> &values) IRR_OVERRIDE;
//! Writes a comment into the xml file
virtual void writeComment(const c8* comment) IRR_OVERRIDE;
//! Writes the closing tag for an element. Like </foo>
virtual void writeClosingTag(const c8* name) IRR_OVERRIDE;
//! Writes a text into the file. All occurrences of special characters like
//! & (&amp;), < (&lt;), > (&gt;), and " (&quot;) are automatically replaced.
virtual void writeText(const c8* text) IRR_OVERRIDE;
//! Writes a line break
virtual void writeLineBreak() IRR_OVERRIDE;
private:
void writeAttribute(const c8* att, const c8* name);
};
} // end namespace irr
} // end namespace io
#endif // _IRR_COMPILE_WITH_XML_
#endif