Commit 15bd9597 authored by cutealien's avatar cutealien

Add _IRR_COMPILE_WITH_XML_ define to allow compiling Irrlicht without xml (patch written by curaga)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4423 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 5457c5e5
--------------------------
Changes in 1.9 (not yet released)
- Add _IRR_COMPILE_WITH_XML_ define to allow compiling Irrlicht without xml (patch written by curaga)
- Add functions to set/get cursor character and blinktime to IGUIEditBox
- Collada exporter calculates values for orthographic camera now on export
- Collada exporter now exports the camera up-vector correctly.
......
......@@ -116,6 +116,12 @@
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.
#define _IRR_MATERIAL_MAX_TEXTURES_ 4
//! Whether to support XML and XML-based formats (irrmesh, collada...)
#define _IRR_COMPILE_WITH_XML_
#ifdef NO_IRR_COMPILE_WITH_XML_
#undef _IRR_COMPILE_WITH_XML_
#endif
//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to
//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9.
/** If you only want to use the software device or opengl you can disable those defines.
......@@ -792,5 +798,13 @@ precision will be lower but speed higher. currently X86 only
#undef __IRR_HAS_S64
#endif
// These depend on XML
#ifndef _IRR_COMPILE_WITH_XML_
#undef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
#undef _IRR_COMPILE_WITH_IRR_WRITER_
#undef _IRR_COMPILE_WITH_COLLADA_WRITER_
#undef _IRR_COMPILE_WITH_COLLADA_LOADER_
#endif
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__
......@@ -416,6 +416,7 @@ namespace io
See IIrrXMLReader for description on how to use it. */
typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
#ifdef _IRR_COMPILE_WITH_XML_
//! Creates an instance of an UFT-8 or ASCII character xml parser.
/** This means that all character data will be returned in 8 bit ASCII or UTF-8.
......@@ -537,6 +538,7 @@ namespace io
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
bool deleteCallback = false);
#endif // _IRR_COMPILE_WITH_XML_
/*! \file irrXML.h
\brief Header file of the irrXML, the Irrlicht XML parser.
......
......@@ -8,6 +8,10 @@
#include "IXMLWriter.h"
#include "IVideoDriver.h"
#ifndef _IRR_COMPILE_WITH_XML_
#include "CXMLReader.h" // for noXML
#endif
namespace irr
{
namespace io
......@@ -1408,6 +1412,7 @@ void CAttributes::setAttribute(s32 index, void* userPointer)
bool CAttributes::read(io::IXMLReader* reader, bool readCurrentElementOnly,
const wchar_t* nonDefaultElementName)
{
#ifdef _IRR_COMPILE_WITH_XML_
if (!reader)
return false;
......@@ -1440,11 +1445,16 @@ bool CAttributes::read(io::IXMLReader* reader, bool readCurrentElementOnly,
}
return true;
#else
noXML();
return false;
#endif
}
void CAttributes::readAttributeFromXML(io::IXMLReader* reader)
{
#ifdef _IRR_COMPILE_WITH_XML_
core::stringw element = reader->getNodeName();
core::stringc name = reader->getAttributeValue(L"name");
......@@ -1593,12 +1603,16 @@ void CAttributes::readAttributeFromXML(io::IXMLReader* reader)
addDimension2d(name.c_str(), core::dimension2d<u32>());
Attributes.getLast()->setString(reader->getAttributeValue(L"value"));
}
#else
noXML();
#endif
}
//! Write these attributes into a xml file
bool CAttributes::write(io::IXMLWriter* writer, bool writeXMLHeader,
const wchar_t* nonDefaultElementName)
{
#ifdef _IRR_COMPILE_WITH_XML_
if (!writer)
return false;
......@@ -1657,6 +1671,10 @@ bool CAttributes::write(io::IXMLWriter* writer, bool writeXMLHeader,
writer->writeLineBreak();
return true;
#else
noXML();
return false;
#endif
}
......
......@@ -5,6 +5,8 @@
#ifndef __C_ATTRIBUTES_H_INCLUDED__
#define __C_ATTRIBUTES_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IAttributes.h"
#include "IAttribute.h"
......
......@@ -994,6 +994,7 @@ bool CFileSystem::existFile(const io::path& filename) const
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const io::path& filename)
{
#ifdef _IRR_COMPILE_WITH_XML_
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
......@@ -1001,22 +1002,32 @@ IXMLReader* CFileSystem::createXMLReader(const io::path& filename)
IXMLReader* reader = createXMLReader(file);
file->drop();
return reader;
#else
noXML();
return 0;
#endif
}
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(IReadFile* file)
{
#ifdef _IRR_COMPILE_WITH_XML_
if (!file)
return 0;
return createIXMLReader(file);
#else
noXML();
return 0;
#endif
}
//! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const io::path& filename)
{
#ifdef _IRR_COMPILE_WITH_XML_
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
......@@ -1024,22 +1035,32 @@ IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const io::path& filename)
IXMLReaderUTF8* reader = createIXMLReaderUTF8(file);
file->drop();
return reader;
#else
noXML();
return 0;
#endif
}
//! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file)
{
#ifdef _IRR_COMPILE_WITH_XML_
if (!file)
return 0;
return createIXMLReaderUTF8(file);
#else
noXML();
return 0;
#endif
}
//! Creates a XML Writer from a file.
IXMLWriter* CFileSystem::createXMLWriter(const io::path& filename)
{
#ifdef _IRR_COMPILE_WITH_XML_
IWriteFile* file = createAndWriteFile(filename);
IXMLWriter* writer = 0;
if (file)
......@@ -1048,13 +1069,22 @@ IXMLWriter* CFileSystem::createXMLWriter(const io::path& filename)
file->drop();
}
return writer;
#else
noXML();
return 0;
#endif
}
//! Creates a XML Writer from a file.
IXMLWriter* CFileSystem::createXMLWriter(IWriteFile* file)
{
#ifdef _IRR_COMPILE_WITH_XML_
return new CXMLWriter(file);
#else
noXML();
return 0;
#endif
}
......
......@@ -2,8 +2,10 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CXMLReaderImpl.h"
#include "CXMLReader.h"
#ifdef _IRR_COMPILE_WITH_XML_
#include "CXMLReaderImpl.h"
#include "IReadFile.h"
namespace irr
......@@ -48,23 +50,35 @@ namespace io
// now create an implementation for IXMLReader using irrXML.
//! Creates an instance of a wide character xml parser.
//! Creates an instance of a wide character xml parser.
IXMLReader* createIXMLReader(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
} // end namespace
} // end namespace
#else // not _IRR_COMPILE_WITH_XML_
#include "os.h"
namespace irr
{
void noXML()
{
irr::os::Printer::log("XML support disabled in IrrCompileConfig.", irr::ELL_ERROR);
}
} // end namespace
#endif // _IRR_COMPILE_WITH_XML_
......@@ -9,6 +9,7 @@
namespace irr
{
#ifdef _IRR_COMPILE_WITH_XML_
namespace io
{
class IReadFile;
......@@ -18,8 +19,11 @@ namespace io
//! creates an IXMLReader
IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file);
} // end namespace irr
#else // _IRR_COMPILE_WITH_XML_
//! print a message that Irrlicht is compiled without _IRR_COMPILE_WITH_XML_
void noXML();
#endif // _IRR_COMPILE_WITH_XML_
} // end namespace io
#endif
......
......@@ -3,6 +3,9 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CXMLWriter.h"
#ifdef _IRR_COMPILE_WITH_XML_
#include <wchar.h>
#include "irrString.h"
#include "IrrCompileConfig.h"
......@@ -20,7 +23,7 @@ CXMLWriter::CXMLWriter(IWriteFile* file)
#ifdef _DEBUG
setDebugName("CXMLWriter");
#endif
if (File)
File->grab();
}
......@@ -78,7 +81,7 @@ void CXMLWriter::writeElement(const wchar_t* name, bool empty,
for (int i=0; i<Tabs; ++i)
File->write(L"\t", sizeof(wchar_t));
}
// write name
File->write(L"<", sizeof(wchar_t));
......@@ -100,7 +103,7 @@ void CXMLWriter::writeElement(const wchar_t* name, bool empty,
File->write(L">", sizeof(wchar_t));
++Tabs;
}
TextWrittenLast = false;
}
......@@ -117,7 +120,7 @@ void CXMLWriter::writeElement(const wchar_t* name, bool empty,
for (int i=0; i<Tabs; ++i)
File->write(L"\t", sizeof(wchar_t));
}
// write name
File->write(L"<", sizeof(wchar_t));
......@@ -136,7 +139,7 @@ void CXMLWriter::writeElement(const wchar_t* name, bool empty,
File->write(L">", sizeof(wchar_t));
++Tabs;
}
TextWrittenLast = false;
}
......@@ -188,7 +191,7 @@ void CXMLWriter::writeClosingTag(const wchar_t* name)
const CXMLWriter::XMLSpecialCharacters XMLWSChar[] =
const CXMLWriter::XMLSpecialCharacters XMLWSChar[] =
{
{ L'&', L"&amp;" },
{ L'<', L"&lt;" },
......@@ -209,7 +212,7 @@ void CXMLWriter::writeText(const wchar_t* text)
// Making a member-variable would work, but a lot of memory would stay around after writing.
// So the correct solution is probably using fixed block here and always write when that is full.
core::stringw s;
s.reserve(wcslen(text)+1);
s.reserve(wcslen(text)+1);
const wchar_t* p = text;
while(*p)
......@@ -255,3 +258,4 @@ void CXMLWriter::writeLineBreak()
} // end namespace irr
} // end namespace io
#endif // _IRR_COMPILE_WITH_XML_
......@@ -5,8 +5,11 @@
#ifndef __C_XML_WRITER_H_INCLUDED__
#define __C_XML_WRITER_H_INCLUDED__
#include <wchar.h>
#include "IXMLWriter.h"
#ifdef _IRR_COMPILE_WITH_XML_
#include <wchar.h>
#include "IWriteFile.h"
namespace irr
......@@ -72,5 +75,7 @@ namespace io
} // end namespace irr
} // end namespace io
#endif // _IRR_COMPILE_WITH_XML_
#endif
......@@ -3,6 +3,9 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
#include "irrXML.h"
#ifdef _IRR_COMPILE_WITH_XML_
#include "irrString.h"
#include "irrArray.h"
#include "fast_atof.h"
......@@ -80,27 +83,27 @@ private:
// FACTORY FUNCTIONS:
//! Creates an instance of an UFT-8 or ASCII character xml parser.
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename)
{
return createIrrXMLReader(new CFileReadCallBack(filename), true);
return createIrrXMLReader(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file)
{
return createIrrXMLReader(new CFileReadCallBack(file), true);
return createIrrXMLReader(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
{
return new CXMLReaderImpl<char, IXMLBase>(callback, deleteCallback);
return new CXMLReaderImpl<char, IXMLBase>(callback, deleteCallback);
}
else
{
......@@ -112,27 +115,27 @@ IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* cal
}
//! Creates an instance of an UTF-16 xml parser.
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename)
{
return createIrrXMLReaderUTF16(new CFileReadCallBack(filename), true);
return createIrrXMLReaderUTF16(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UTF-16 xml parser.
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file)
{
return createIrrXMLReaderUTF16(new CFileReadCallBack(file), true);
return createIrrXMLReaderUTF16(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UTF-16 xml parser.
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
{
return new CXMLReaderImpl<char16, IXMLBase>(callback, deleteCallback);
return new CXMLReaderImpl<char16, IXMLBase>(callback, deleteCallback);
}
else
{
......@@ -144,27 +147,27 @@ IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCal
}
//! Creates an instance of an UTF-32 xml parser.
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename)
{
return createIrrXMLReaderUTF32(new CFileReadCallBack(filename), true);
return createIrrXMLReaderUTF32(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UTF-32 xml parser.
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file)
{
return createIrrXMLReaderUTF32(new CFileReadCallBack(file), true);
return createIrrXMLReaderUTF32(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UTF-32 xml parser.
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(
IFileReadCallBack* callback, bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
{
return new CXMLReaderImpl<char32, IXMLBase>(callback, deleteCallback);
return new CXMLReaderImpl<char32, IXMLBase>(callback, deleteCallback);
}
else
{
......@@ -178,3 +181,5 @@ IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(
} // end namespace io
} // end namespace irr
#endif // _IRR_COMPILE_WITH_XML_
......@@ -905,6 +905,8 @@ bool twodmaterial()
bool result = true;
TestWithAllDrivers(addBlend2d);
TestWithAllDrivers(moreFilterTests);
#ifdef _IRR_COMPILE_WITH_XML_
TestWithAllDrivers(draw2DImage4c);
#endif
return result;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment