Removed aiProcess_FindDegenerates from the viewer. The step seems to cause some problems that have not yet been solved.
Added irrmesh (Irrlicht Mesh Format) loader to Assimp. Works quite stable, but no lightmapping support yet. Removed tinyxml, replaced it with irrxml instead. Added an IOStreamToIrrXML wrapper. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@194 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
44ea300651
commit
ce6ce098e9
|
@ -97,5 +97,46 @@ void BaseImporter::SetupProperties(const Importer* pImp)
|
|||
// the default implementation does nothing
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool BaseImporter::SearchFileHeaderForToken(IOSystem* pIOHandler,
|
||||
const std::string& pFile,
|
||||
const char** tokens,
|
||||
unsigned int numTokens,
|
||||
unsigned int searchBytes /* = 200 */)
|
||||
{
|
||||
ai_assert(NULL != tokens && 0 != numTokens && NULL != pIOHandler && 0 != searchBytes);
|
||||
|
||||
boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||
if (pStream.get() )
|
||||
{
|
||||
// read 200 characters from the file
|
||||
boost::scoped_ptr<char> _buffer (new char[searchBytes]);
|
||||
char* buffer = _buffer.get();
|
||||
|
||||
unsigned int read = (unsigned int)pStream->Read(buffer,1,searchBytes);
|
||||
if (!read)return false;
|
||||
|
||||
for (unsigned int i = 0; i < read;++i)
|
||||
buffer[i] = ::tolower(buffer[i]);
|
||||
|
||||
// It is not a proper handling of unicode files here ...
|
||||
// ehm ... but it works in most cases.
|
||||
char* cur = buffer,*cur2 = buffer,*end = &buffer[read];
|
||||
while (cur != end)
|
||||
{
|
||||
if (*cur)*cur2++ = *cur;
|
||||
++cur;
|
||||
}
|
||||
*cur2 = '\0';
|
||||
|
||||
for (unsigned int i = 0; i < numTokens;++i)
|
||||
{
|
||||
ai_assert(NULL != tokens[i]);
|
||||
if (::strstr(buffer,tokens[i]))return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -194,6 +194,27 @@ protected:
|
|||
virtual void InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler) = 0;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** A utility for CanRead().
|
||||
*
|
||||
* The function searches the header of a file for a specific token
|
||||
* and returns true if this token is found. This works for text
|
||||
* files only. There is a rudimentary handling if UNICODE files.
|
||||
* The comparison is case independent.
|
||||
*
|
||||
* @param pIOSystem IO System to work with
|
||||
* @param file File name of the file
|
||||
* @param tokens List of tokens to search for
|
||||
* @param numTokens Size of the token array
|
||||
* @param searchBytes Number of bytes to be searched for the tokens.
|
||||
*/
|
||||
static bool SearchFileHeaderForToken(IOSystem* pIOSystem,
|
||||
const std::string& file,
|
||||
const char** tokens,
|
||||
unsigned int numTokens,
|
||||
unsigned int searchBytes = 200);
|
||||
|
||||
protected:
|
||||
|
||||
/** Error description in case there was one. */
|
||||
|
|
|
@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "DXFLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
@ -246,7 +245,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
|||
{
|
||||
aiFace& face = pMesh->mFaces[i];
|
||||
|
||||
// check whether we need four,three or two indices here
|
||||
// check whether we need four, three or two indices here
|
||||
if (vp[1] == vp[2])
|
||||
{
|
||||
face.mNumIndices = 2;
|
||||
|
@ -263,7 +262,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
|||
*vpOut++ = vp[a];
|
||||
if (clr)
|
||||
{
|
||||
if (std::numeric_limits<float>::quiet_NaN() != clr[a].r)
|
||||
if (is_not_qnan( clr[a].r ))
|
||||
*clrOut = clr[a];
|
||||
|
||||
++clrOut;
|
||||
|
@ -437,7 +436,7 @@ bool DXFImporter::ParsePolyLine()
|
|||
// optional number of faces
|
||||
case 72:
|
||||
{
|
||||
indices.reserve(strtol10(cursor) * 4u);
|
||||
indices.reserve(strtol10(cursor));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,743 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Implementation of the IrrMesh importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
|
||||
#include "IRRMeshLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
IRRMeshImporter::IRRMeshImporter()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
IRRMeshImporter::~IRRMeshImporter()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool IRRMeshImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
||||
{
|
||||
/* NOTE: A simple check for the file extension is not enough
|
||||
* here. Irrmesh and irr are easy, but xml is too generic
|
||||
* and could be collada, too. So we need to open the file and
|
||||
* search for typical tokens.
|
||||
*/
|
||||
|
||||
std::string::size_type pos = pFile.find_last_of('.');
|
||||
|
||||
// no file extension - can't read
|
||||
if( pos == std::string::npos)
|
||||
return false;
|
||||
|
||||
std::string extension = pFile.substr( pos);
|
||||
for (std::string::iterator i = extension.begin(); i != extension.end();++i)
|
||||
*i = ::tolower(*i);
|
||||
|
||||
if (extension == ".irrmesh")return true;
|
||||
else if (extension == ".xml")
|
||||
{
|
||||
/* If CanRead() is called to check whether the loader
|
||||
* supports a specific file extension in general we
|
||||
* must return true here.
|
||||
*/
|
||||
if (!pIOHandler)return true;
|
||||
const char* tokens[] = {"irrlicht","irrmesh"};
|
||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a property in hexadecimal format (i.e. ffffffff)
|
||||
void IRRMeshImporter::ReadHexProperty (HexProperty& out)
|
||||
{
|
||||
for (int i = 0; i < reader->getAttributeCount();++i)
|
||||
{
|
||||
if (!ASSIMP_stricmp(reader->getAttributeName(i),"name"))
|
||||
{
|
||||
out.name = std::string( reader->getAttributeValue(i) );
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getAttributeName(i),"value"))
|
||||
{
|
||||
// parse the hexadecimal value
|
||||
out.value = strtol16(reader->getAttributeValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a string property
|
||||
void IRRMeshImporter::ReadStringProperty (StringProperty& out)
|
||||
{
|
||||
for (int i = 0; i < reader->getAttributeCount();++i)
|
||||
{
|
||||
if (!ASSIMP_stricmp(reader->getAttributeName(i),"name"))
|
||||
{
|
||||
out.name = std::string( reader->getAttributeValue(i) );
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getAttributeName(i),"value"))
|
||||
{
|
||||
// simple copy the string
|
||||
out.value = std::string (reader->getAttributeValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a boolean property
|
||||
void IRRMeshImporter::ReadBoolProperty (BoolProperty& out)
|
||||
{
|
||||
for (int i = 0; i < reader->getAttributeCount();++i)
|
||||
{
|
||||
if (!ASSIMP_stricmp(reader->getAttributeName(i),"name"))
|
||||
{
|
||||
out.name = std::string( reader->getAttributeValue(i) );
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getAttributeName(i),"value"))
|
||||
{
|
||||
// true or false, case insensitive
|
||||
out.value = (ASSIMP_stricmp( reader->getAttributeValue(i),
|
||||
"true") ? false : true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a float property
|
||||
void IRRMeshImporter::ReadFloatProperty (FloatProperty& out)
|
||||
{
|
||||
for (int i = 0; i < reader->getAttributeCount();++i)
|
||||
{
|
||||
if (!ASSIMP_stricmp(reader->getAttributeName(i),"name"))
|
||||
{
|
||||
out.name = std::string( reader->getAttributeValue(i) );
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getAttributeName(i),"value"))
|
||||
{
|
||||
// true or false, case insensitive
|
||||
out.value = fast_atof( reader->getAttributeValue(i) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ColorFromARGBPacked(uint32_t in, aiColor4D& clr)
|
||||
{
|
||||
clr.a = ((in >> 24) & 0xff) / 255.f;
|
||||
clr.r = ((in >> 16) & 0xff) / 255.f;
|
||||
clr.g = ((in >> 8) & 0xff) / 255.f;
|
||||
clr.b = ((in ) & 0xff) / 255.f;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int ConvertMappingMode(const std::string& mode)
|
||||
{
|
||||
if (mode == "texture_clamp_repeat")
|
||||
return aiTextureMapMode_Wrap;
|
||||
else if (mode == "texture_clamp_mirror")
|
||||
return aiTextureMapMode_Mirror;
|
||||
|
||||
return aiTextureMapMode_Clamp;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse a material from the XML file
|
||||
aiMaterial* IRRMeshImporter::ParseMaterial(unsigned int& matFlags)
|
||||
{
|
||||
MaterialHelper* mat = new MaterialHelper();
|
||||
aiColor4D clr;
|
||||
aiString s;
|
||||
|
||||
matFlags = 0;
|
||||
|
||||
// Continue reading from the file
|
||||
while (reader->read())
|
||||
{
|
||||
switch (reader->getNodeType())
|
||||
{
|
||||
case EXN_ELEMENT:
|
||||
|
||||
// Hex properties
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"color"))
|
||||
{
|
||||
HexProperty prop;
|
||||
ReadHexProperty(prop);
|
||||
if (prop.name == "Diffuse")
|
||||
{
|
||||
ColorFromARGBPacked(prop.value,clr);
|
||||
mat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
}
|
||||
else if (prop.name == "Ambient")
|
||||
{
|
||||
ColorFromARGBPacked(prop.value,clr);
|
||||
mat->AddProperty(&clr,1,AI_MATKEY_COLOR_AMBIENT);
|
||||
}
|
||||
else if (prop.name == "Specular")
|
||||
{
|
||||
ColorFromARGBPacked(prop.value,clr);
|
||||
mat->AddProperty(&clr,1,AI_MATKEY_COLOR_SPECULAR);
|
||||
}
|
||||
else if (prop.name == "Emissive")
|
||||
{
|
||||
ColorFromARGBPacked(prop.value,clr);
|
||||
mat->AddProperty(&clr,1,AI_MATKEY_COLOR_EMISSIVE);
|
||||
}
|
||||
}
|
||||
// Float properties
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"float"))
|
||||
{
|
||||
FloatProperty prop;
|
||||
ReadFloatProperty(prop);
|
||||
if (prop.name == "Shininess")
|
||||
{
|
||||
mat->AddProperty(&prop.value,1,AI_MATKEY_SHININESS);
|
||||
}
|
||||
}
|
||||
// Bool properties
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"bool"))
|
||||
{
|
||||
BoolProperty prop;
|
||||
ReadBoolProperty(prop);
|
||||
if (prop.name == "Wireframe")
|
||||
{
|
||||
int val = (prop.value ? true : false);
|
||||
mat->AddProperty(&val,1,AI_MATKEY_ENABLE_WIREFRAME);
|
||||
}
|
||||
else if (prop.name == "GouraudShading")
|
||||
{
|
||||
int val = (prop.value ? aiShadingMode_Gouraud
|
||||
: aiShadingMode_NoShading);
|
||||
mat->AddProperty(&val,1,AI_MATKEY_SHADING_MODEL);
|
||||
}
|
||||
}
|
||||
// String properties - textures and texture related properties
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"texture") ||
|
||||
!ASSIMP_stricmp(reader->getNodeName(),"enum"))
|
||||
{
|
||||
StringProperty prop;
|
||||
ReadStringProperty(prop);
|
||||
int cnt = 0;
|
||||
|
||||
if (prop.value.length())
|
||||
{
|
||||
// material type (shader)
|
||||
if (prop.name == "Type")
|
||||
{
|
||||
if (prop.value == "trans_vertex_alpha")
|
||||
{
|
||||
matFlags = AI_IRRMESH_MAT_trans_vertex_alpha;
|
||||
}
|
||||
else if (prop.value == "lightmap")
|
||||
{
|
||||
matFlags = AI_IRRMESH_MAT_lightmap;
|
||||
}
|
||||
else if (prop.value == "lightmap_m2")
|
||||
{
|
||||
matFlags = AI_IRRMESH_MAT_lightmap_m2;
|
||||
}
|
||||
else if (prop.value == "lightmap_m4")
|
||||
{
|
||||
matFlags = AI_IRRMESH_MAT_lightmap_m4;
|
||||
}
|
||||
}
|
||||
|
||||
// Up to 4 texture channels are supported
|
||||
else if (prop.name == "Texture1")
|
||||
{
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
else if (prop.name == "Texture2")
|
||||
{
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(1));
|
||||
}
|
||||
else if (prop.name == "Texture3")
|
||||
{
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(2));
|
||||
}
|
||||
else if (prop.name == "Texture4" )
|
||||
{
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(3));
|
||||
}
|
||||
|
||||
// Texture mapping options
|
||||
if (prop.name == "TextureWrap1" && cnt >= 1)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(0));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0));
|
||||
}
|
||||
else if (prop.name == "TextureWrap2" && cnt >= 2)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(1));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(1));
|
||||
}
|
||||
else if (prop.name == "TextureWrap3" && cnt >= 3)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(2));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(2));
|
||||
}
|
||||
else if (prop.name == "TextureWrap4" && cnt >= 4)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(3));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EXN_ELEMENT_END:
|
||||
|
||||
/* Assume there are no further nested nodes in <material> elements
|
||||
*/
|
||||
|
||||
return mat;
|
||||
|
||||
default:
|
||||
|
||||
// GCC complains here ...
|
||||
break;
|
||||
}
|
||||
}
|
||||
DefaultLogger::get()->error("IRRMESH: Unexpected end of file. Material is not complete");
|
||||
return mat;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == NULL)
|
||||
throw new ImportErrorException( "Failed to open IRRMESH file " + pFile + "");
|
||||
|
||||
// Construct the irrXML parser
|
||||
CIrrXML_IOStreamReader st(file.get());
|
||||
reader = createIrrXMLReader((IFileReadCallBack*) &st);
|
||||
|
||||
// final data
|
||||
std::vector<aiMaterial*> materials;
|
||||
std::vector<aiMesh*> meshes;
|
||||
materials.reserve (5);
|
||||
meshes.reserve (5);
|
||||
|
||||
// temporary data - current mesh buffer
|
||||
aiMaterial* curMat = NULL;
|
||||
aiMesh* curMesh = NULL;
|
||||
unsigned int curMatFlags;
|
||||
|
||||
std::vector<aiVector3D> curVertices,curNormals,curTangents,curBitangents;
|
||||
std::vector<aiColor4D> curColors;
|
||||
std::vector<aiVector3D> curUVs,curUV2s;
|
||||
|
||||
// some temporary variables
|
||||
int textMeaning = 0;
|
||||
int vertexFormat = 0; // 0 = normal; 1 = 2 tcoords, 2 = tangents
|
||||
bool useColors = false;
|
||||
|
||||
// Parse the XML file
|
||||
while (reader->read())
|
||||
{
|
||||
switch (reader->getNodeType())
|
||||
{
|
||||
case EXN_ELEMENT:
|
||||
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"buffer") && (curMat || curMesh))
|
||||
{
|
||||
// end of previous buffer. A material and a mesh should be there
|
||||
if ( !curMat || !curMesh)
|
||||
{
|
||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||
delete curMat;
|
||||
delete curMesh;
|
||||
}
|
||||
else
|
||||
{
|
||||
materials.push_back(curMat);
|
||||
meshes.push_back(curMesh);
|
||||
}
|
||||
curMat = NULL;
|
||||
curMesh = NULL;
|
||||
|
||||
curVertices.clear();
|
||||
curColors.clear();
|
||||
curNormals.clear();
|
||||
curUV2s.clear();
|
||||
curUVs.clear();
|
||||
}
|
||||
|
||||
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"material"))
|
||||
{
|
||||
if (curMat)
|
||||
{
|
||||
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
||||
delete curMat;
|
||||
}
|
||||
curMat = ParseMaterial(curMatFlags);
|
||||
}
|
||||
/* no else here! */ if (!ASSIMP_stricmp(reader->getNodeName(),"vertices"))
|
||||
{
|
||||
int num = reader->getAttributeValueAsInt("vertexCount");
|
||||
curVertices.reserve (num);
|
||||
curNormals.reserve (num);
|
||||
curColors.reserve (num);
|
||||
curUVs.reserve (num);
|
||||
|
||||
// Determine the file format
|
||||
const char* t = reader->getAttributeValueSafe("type");
|
||||
if (!ASSIMP_stricmp("2tcoords", t))
|
||||
{
|
||||
curUV2s.reserve (num);
|
||||
vertexFormat = 1;
|
||||
}
|
||||
else if (!ASSIMP_stricmp("tangents", t))
|
||||
{
|
||||
curTangents.reserve (num);
|
||||
curBitangents.reserve (num);
|
||||
vertexFormat = 2;
|
||||
}
|
||||
else if (ASSIMP_stricmp("standard", t))
|
||||
{
|
||||
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
||||
}
|
||||
else vertexFormat = 0;
|
||||
textMeaning = 1;
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices"))
|
||||
{
|
||||
if (curVertices.empty())
|
||||
throw new ImportErrorException("IRRMESH: indices must come after vertices");
|
||||
|
||||
textMeaning = 2;
|
||||
|
||||
// start a new mesh
|
||||
curMesh = new aiMesh();
|
||||
|
||||
// allocate storage for all faces
|
||||
curMesh->mNumVertices = reader->getAttributeValueAsInt("indexCount");
|
||||
if (curMesh->mNumVertices % 3)
|
||||
{
|
||||
DefaultLogger::get()->warn("IRRMESH: Number if indices isn't divisible by 3");
|
||||
}
|
||||
|
||||
curMesh->mNumFaces = curMesh->mNumVertices / 3;
|
||||
curMesh->mFaces = new aiFace[curMesh->mNumFaces];
|
||||
|
||||
// setup some members
|
||||
curMesh->mMaterialIndex = (unsigned int)materials.size();
|
||||
curMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||
|
||||
// allocate storage for all vertices
|
||||
curMesh->mVertices = new aiVector3D[curMesh->mNumVertices];
|
||||
|
||||
if (curNormals.size() == curVertices.size())
|
||||
{
|
||||
curMesh->mNormals = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curTangents.size() == curVertices.size())
|
||||
{
|
||||
curMesh->mTangents = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curBitangents.size() == curVertices.size())
|
||||
{
|
||||
curMesh->mBitangents = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curColors.size() == curVertices.size() && useColors)
|
||||
{
|
||||
curMesh->mColors[0] = new aiColor4D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curUVs.size() == curVertices.size())
|
||||
{
|
||||
curMesh->mTextureCoords[0] = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
if (curUV2s.size() == curVertices.size())
|
||||
{
|
||||
curMesh->mTextureCoords[1] = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EXN_TEXT:
|
||||
{
|
||||
const char* sz = reader->getNodeData();
|
||||
if (textMeaning == 1)
|
||||
{
|
||||
textMeaning = 0;
|
||||
|
||||
// read vertices
|
||||
do
|
||||
{
|
||||
SkipSpacesAndLineEnd(&sz);
|
||||
aiVector3D temp;aiColor4D c;
|
||||
|
||||
// Read the vertex position
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curVertices.push_back(temp);
|
||||
|
||||
// Read the vertex normals
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curNormals.push_back(temp);
|
||||
|
||||
// read the vertex colors
|
||||
uint32_t clr = strtol16(sz,&sz);
|
||||
ColorFromARGBPacked(clr,c);
|
||||
|
||||
if (!curColors.empty() && c != *(curColors.end()-1))
|
||||
useColors = true;
|
||||
|
||||
curColors.push_back(c);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
|
||||
// read the first UV coordinate set
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.z = 0.f;
|
||||
temp.y = 1.f - temp.y; // DX to OGL
|
||||
curUVs.push_back(temp);
|
||||
|
||||
// read the (optional) second UV coordinate set
|
||||
if (vertexFormat == 1)
|
||||
{
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
temp.y = 1.f - temp.y; // DX to OGL
|
||||
curUV2s.push_back(temp);
|
||||
}
|
||||
// read optional tangent and bitangent vectors
|
||||
if (vertexFormat == 2)
|
||||
{
|
||||
// tangents
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curTangents.push_back(temp);
|
||||
|
||||
// bitangents
|
||||
sz = fast_atof_move(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curBitangents.push_back(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/* IMPORTANT: We assume that each vertex is specified in one
|
||||
line. So we can skip the rest of the line - unknown vertex
|
||||
elements are ignored.
|
||||
*/
|
||||
|
||||
while (SkipLine(&sz));
|
||||
}
|
||||
else if (textMeaning == 2)
|
||||
{
|
||||
textMeaning = 0;
|
||||
|
||||
// read indices
|
||||
aiFace* curFace = curMesh->mFaces;
|
||||
aiFace* const faceEnd = curMesh->mFaces + curMesh->mNumFaces;
|
||||
|
||||
aiVector3D* pcV = curMesh->mVertices;
|
||||
aiVector3D* pcN = curMesh->mNormals;
|
||||
aiVector3D* pcT = curMesh->mTangents;
|
||||
aiVector3D* pcB = curMesh->mBitangents;
|
||||
aiColor4D* pcC0 = curMesh->mColors[0];
|
||||
aiVector3D* pcT0 = curMesh->mTextureCoords[0];
|
||||
aiVector3D* pcT1 = curMesh->mTextureCoords[1];
|
||||
|
||||
unsigned int curIdx = 0;
|
||||
unsigned int total = 0;
|
||||
while(SkipSpacesAndLineEnd(&sz))
|
||||
{
|
||||
if (curFace >= faceEnd)
|
||||
{
|
||||
DefaultLogger::get()->error("IRRMESH: Too many indices");
|
||||
break;
|
||||
}
|
||||
if (!curIdx)
|
||||
{
|
||||
curFace->mNumIndices = 3;
|
||||
curFace->mIndices = new unsigned int[3];
|
||||
}
|
||||
|
||||
unsigned int idx = strtol10(sz,&sz);
|
||||
if (idx >= curVertices.size())
|
||||
{
|
||||
DefaultLogger::get()->error("IRRMESH: Index out of range");
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
curFace->mIndices[curIdx] = total++;
|
||||
|
||||
*pcV++ = curVertices[idx];
|
||||
if (pcN)*pcN++ = curNormals[idx];
|
||||
if (pcT)*pcT++ = curTangents[idx];
|
||||
if (pcB)*pcB++ = curBitangents[idx];
|
||||
if (pcC0)*pcC0++ = curColors[idx];
|
||||
if (pcT0)*pcT0++ = curUVs[idx];
|
||||
if (pcT1)*pcT1++ = curUV2s[idx];
|
||||
|
||||
if (++curIdx == 3)
|
||||
{
|
||||
++curFace;
|
||||
curIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (curFace != faceEnd)
|
||||
DefaultLogger::get()->error("IRRMESH: Not enough indices");
|
||||
|
||||
// Finish processing the mesh - do some small material workarounds
|
||||
if (curMatFlags == AI_IRRMESH_MAT_trans_vertex_alpha && !useColors)
|
||||
{
|
||||
// Take the opacity value of the current material
|
||||
// from the common vertex color alpha
|
||||
MaterialHelper* mat = (MaterialHelper*)curMat;
|
||||
mat->AddProperty(&curColors[0].a,1,AI_MATKEY_OPACITY);
|
||||
}
|
||||
|
||||
/* TODO: Add lightmapping support here */
|
||||
}}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// GCC complains here ...
|
||||
break;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// end of the last buffer. A material and a mesh should be there
|
||||
if (curMat || curMesh)
|
||||
{
|
||||
if ( !curMat || !curMesh)
|
||||
{
|
||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||
delete curMat;
|
||||
delete curMesh;
|
||||
}
|
||||
else
|
||||
{
|
||||
materials.push_back(curMat);
|
||||
meshes.push_back(curMesh);
|
||||
}
|
||||
}
|
||||
|
||||
// now generate the output scene
|
||||
pScene->mNumMeshes = (unsigned int)meshes.size();
|
||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||
::memcpy(pScene->mMeshes,&meshes[0],sizeof(void*)*pScene->mNumMeshes);
|
||||
|
||||
pScene->mNumMaterials = (unsigned int)materials.size();
|
||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||
::memcpy(pScene->mMaterials,&materials[0],sizeof(void*)*pScene->mNumMaterials);
|
||||
|
||||
pScene->mRootNode = new aiNode();
|
||||
pScene->mRootNode->mName.Set("<IRRMesh>");
|
||||
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
||||
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
|
||||
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
pScene->mRootNode->mMeshes[i] = i;
|
||||
|
||||
delete reader;
|
||||
AI_DEBUG_INVALIDATE_PTR(reader);
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Declaration of the .irrMesh (Irrlight Engine Mesh Format)
|
||||
importer class. */
|
||||
#ifndef AI_IRRMESHLOADER_H_INCLUDED
|
||||
#define AI_IRRMESHLOADER_H_INCLUDED
|
||||
|
||||
#include "./irrXML/irrXMLWrapper.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
#define AI_IRRMESH_MAT_trans_vertex_alpha 0x1
|
||||
#define AI_IRRMESH_MAT_lightmap 0x2
|
||||
#define AI_IRRMESH_MAT_lightmap_m2 (AI_IRRMESH_MAT_lightmap|0x4)
|
||||
#define AI_IRRMESH_MAT_lightmap_m4 (AI_IRRMESH_MAT_lightmap|0x5)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** IrrMesh importer class.
|
||||
*
|
||||
* IrrMesh is the native file format of the Irrlight engine and its editor
|
||||
* irrEdit. As IrrEdit itself is capable of importing quite many file formats,
|
||||
* it might be a good file format for data exchange.
|
||||
*/
|
||||
class IRRMeshImporter : public BaseImporter
|
||||
{
|
||||
friend class Importer;
|
||||
|
||||
protected:
|
||||
/** Constructor to be privately used by Importer */
|
||||
IRRMeshImporter();
|
||||
|
||||
/** Destructor, private as well */
|
||||
~IRRMeshImporter();
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details.
|
||||
*/
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||
* See BaseImporter::GetExtensionList() for details
|
||||
*/
|
||||
void GetExtensionList(std::string& append)
|
||||
{
|
||||
|
||||
/* NOTE: The file extenxsion .xml is too generic. We'll
|
||||
* need to open the file in CanRead() and check whether it is
|
||||
* a real irrlicht file
|
||||
*/
|
||||
|
||||
append.append("*.xml;*.irrmesh");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
*/
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||
IOSystem* pIOHandler);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Property
|
||||
{
|
||||
std::string name;
|
||||
T value;
|
||||
};
|
||||
|
||||
typedef Property<uint32_t> HexProperty;
|
||||
typedef Property<std::string> StringProperty;
|
||||
typedef Property<bool> BoolProperty;
|
||||
typedef Property<float> FloatProperty;
|
||||
|
||||
IrrXMLReader* reader;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parse a material description from the XML
|
||||
* @return The created material
|
||||
* @param matFlags Receives AI_IRRMESH_MAT_XX flags
|
||||
*/
|
||||
aiMaterial* ParseMaterial(unsigned int& matFlags);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Read a property of the specified type from the current XML element.
|
||||
* @param out Recives output data
|
||||
*/
|
||||
void ReadHexProperty (HexProperty& out);
|
||||
void ReadStringProperty (StringProperty& out);
|
||||
void ReadBoolProperty (BoolProperty& out);
|
||||
void ReadFloatProperty (FloatProperty& out);
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_IRRMESHIMPORTER_H_INC
|
|
@ -116,6 +116,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_BUILD_NO_BVH_IMPORTER
|
||||
# include "BVHLoader.h"
|
||||
#endif
|
||||
#ifndef AI_BUILD_NO_IRRMESH_IMPORTER
|
||||
# include "IRRMeshLoader.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// PostProcess-Steps
|
||||
|
@ -263,6 +267,9 @@ Importer::Importer() :
|
|||
#if (!defined AI_BUILD_NO_BVH_IMPORTER)
|
||||
mImporter.push_back( new BVHLoader());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_IRRMESH_IMPORTER)
|
||||
mImporter.push_back( new IRRMeshImporter());
|
||||
#endif
|
||||
|
||||
// add an instance of each post processing step here in the order
|
||||
// of sequence it is executed. steps that are added here are not validated -
|
||||
|
|
|
@ -81,6 +81,13 @@ protected:
|
|||
append.append("*.lws");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
*/
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||
IOSystem* pIOHandler);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace Assimp
|
||||
{
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Add a prefix to a string
|
||||
inline void PrefixString(aiString& string,const char* prefix, unsigned int len)
|
||||
{
|
||||
// Add the prefix
|
||||
::memmove(string.data+len,string.data,string.length+1);
|
||||
::memcpy (string.data, prefix, len);
|
||||
|
||||
// And update the string's length
|
||||
string.length += len;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Add a name prefix to all nodes in a hierarchy
|
||||
void SceneCombiner::AddNodePrefixes(aiNode* node, const char* prefix, unsigned int len)
|
||||
{
|
||||
ai_assert(NULL != prefix);
|
||||
|
||||
PrefixString(node->mName,prefix,len);
|
||||
|
||||
// Process all children recursively
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
AddNodePrefixes(node->mChildren[i],prefix,len);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Merges two scenes. Currently only used by the LWS loader.
|
||||
void SceneCombiner::MergeScenes(aiScene* dest,std::vector<aiScene*>& src,
|
||||
|
@ -88,7 +113,10 @@ void SceneCombiner::MergeScenes(aiScene* dest,std::vector<aiScene*>& src,
|
|||
|
||||
if ((*cur)->mNumAnimations > 0 ||
|
||||
(*cur)->mNumCameras > 0 ||
|
||||
(*cur)->mNumLights > 0)bNeedPrefix = true;
|
||||
(*cur)->mNumLights > 0)
|
||||
{
|
||||
bNeedPrefix = true;
|
||||
}
|
||||
}
|
||||
|
||||
// generate the output texture list + an offset table
|
||||
|
@ -176,6 +204,17 @@ void SceneCombiner::MergeScenes(aiScene* dest,std::vector<aiScene*>& src,
|
|||
|
||||
if (bNeedPrefix)
|
||||
{
|
||||
// Allocate space for light sources, cameras and animations
|
||||
aiLight** ppLights = dest->mLights = (dest->mNumLights
|
||||
? new aiLight*[dest->mNumLights] : NULL);
|
||||
|
||||
aiCamera** ppCameras = dest->mCameras = (dest->mNumCameras
|
||||
? new aiCamera*[dest->mNumCameras] : NULL);
|
||||
|
||||
aiAnimation** ppAnims = dest->mAnimations = (dest->mNumAnimations
|
||||
? new aiAnimation*[dest->mNumAnimations] : NULL);
|
||||
|
||||
|
||||
for (cur = begin, cnt = 0; cur != end; ++cur)
|
||||
{
|
||||
char buffer[10];
|
||||
|
@ -187,13 +226,31 @@ void SceneCombiner::MergeScenes(aiScene* dest,std::vector<aiScene*>& src,
|
|||
*sz++ = '_';
|
||||
*sz++ = '\0';
|
||||
|
||||
// AddNodePrefixes((*cur)->mRootNode,buffer,*cur);
|
||||
/** CONTINUE WORK HERE **/
|
||||
const unsigned int len = (unsigned int)::strlen(buffer);
|
||||
AddNodePrefixes((*cur)->mRootNode,buffer,len);
|
||||
|
||||
// Copy light sources, add the prefix to them, too
|
||||
for (unsigned int i = 0; i < (*cur)->mNumLights;++i,++ppLights)
|
||||
{
|
||||
*ppLights = (*cur)->mLights[i];
|
||||
PrefixString((*ppLights)->mName,buffer,len);
|
||||
}
|
||||
// Copy cameras, add the prefix to them, too
|
||||
for (unsigned int i = 0; i < (*cur)->mNumCameras;++i,++ppCameras)
|
||||
{
|
||||
*ppCameras = (*cur)->mCameras[i];
|
||||
PrefixString((*ppCameras)->mName,buffer,len);
|
||||
}
|
||||
|
||||
// Copy animations, add the prefix to them, too
|
||||
for (unsigned int i = 0; i < (*cur)->mNumAnimations;++i,++ppAnims)
|
||||
{
|
||||
*ppAnims = (*cur)->mAnimations[i];
|
||||
PrefixString((*ppAnims)->mName,buffer,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now copy all cameras
|
||||
|
||||
// now delete all input scenes
|
||||
for (cur = begin; cur != end; ++cur)
|
||||
{
|
||||
|
|
|
@ -86,6 +86,17 @@ public:
|
|||
*/
|
||||
static void MergeMeshes(aiMesh* dest,std::vector<aiMesh*>& src,
|
||||
unsigned int flags);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add a name prefix to all nodes in a scene.
|
||||
*
|
||||
* @param Current node. This function is called recursively.
|
||||
* @param prefix Prefix to be added to all nodes
|
||||
* @param len STring length
|
||||
*/
|
||||
static void AddNodePrefixes(aiNode* node, const char* prefix,
|
||||
unsigned int len);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,801 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
||||
|
||||
#ifndef __ICXML_READER_IMPL_H_INCLUDED__
|
||||
#define __ICXML_READER_IMPL_H_INCLUDED__
|
||||
|
||||
#include "irrXML.h"
|
||||
#include "irrString.h"
|
||||
#include "irrArray.h"
|
||||
#include "./../fast_atof.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define IRR_DEBUGPRINT(x) printf((x));
|
||||
#else // _DEBUG
|
||||
#define IRR_DEBUGPRINT(x)
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
|
||||
//! implementation of the IrrXMLReader
|
||||
template<class char_type, class superclass>
|
||||
class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
|
||||
: TextData(0), P(0), TextSize(0), TextBegin(0), CurrentNodeType(EXN_NONE),
|
||||
SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII)
|
||||
{
|
||||
if (!callback)
|
||||
return;
|
||||
|
||||
storeTargetFormat();
|
||||
|
||||
// read whole xml file
|
||||
|
||||
readFile(callback);
|
||||
|
||||
// clean up
|
||||
|
||||
if (deleteCallBack)
|
||||
delete callback;
|
||||
|
||||
// create list with special characters
|
||||
|
||||
createSpecialCharacterList();
|
||||
|
||||
// set pointer to text begin
|
||||
P = TextBegin;
|
||||
}
|
||||
|
||||
|
||||
//! Destructor
|
||||
virtual ~CXMLReaderImpl()
|
||||
{
|
||||
delete [] TextData;
|
||||
}
|
||||
|
||||
|
||||
//! Reads forward to the next xml node.
|
||||
//! \return Returns false, if there was no further node.
|
||||
virtual bool read()
|
||||
{
|
||||
// if not end reached, parse the node
|
||||
if (P && (unsigned int)(P - TextBegin) < TextSize - 1 && *P != 0)
|
||||
{
|
||||
parseCurrentNode();
|
||||
return true;
|
||||
}
|
||||
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Returns the type of the current XML node.
|
||||
virtual EXML_NODE getNodeType() const
|
||||
{
|
||||
return CurrentNodeType;
|
||||
}
|
||||
|
||||
|
||||
//! Returns attribute count of the current XML node.
|
||||
virtual int getAttributeCount() const
|
||||
{
|
||||
return Attributes.size();
|
||||
}
|
||||
|
||||
|
||||
//! Returns name of an attribute.
|
||||
virtual const char_type* getAttributeName(int idx) const
|
||||
{
|
||||
if (idx < 0 || idx >= (int)Attributes.size())
|
||||
return 0;
|
||||
|
||||
return Attributes[idx].Name.c_str();
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute.
|
||||
virtual const char_type* getAttributeValue(int idx) const
|
||||
{
|
||||
if (idx < 0 || idx >= (int)Attributes.size())
|
||||
return 0;
|
||||
|
||||
return Attributes[idx].Value.c_str();
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute.
|
||||
virtual const char_type* getAttributeValue(const char_type* name) const
|
||||
{
|
||||
const SAttribute* attr = getAttributeByName(name);
|
||||
if (!attr)
|
||||
return 0;
|
||||
|
||||
return attr->Value.c_str();
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute
|
||||
virtual const char_type* getAttributeValueSafe(const char_type* name) const
|
||||
{
|
||||
const SAttribute* attr = getAttributeByName(name);
|
||||
if (!attr)
|
||||
return EmptyString.c_str();
|
||||
|
||||
return attr->Value.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
int getAttributeValueAsInt(const char_type* name) const
|
||||
{
|
||||
return (int)getAttributeValueAsFloat(name);
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
int getAttributeValueAsInt(int idx) const
|
||||
{
|
||||
return (int)getAttributeValueAsFloat(idx);
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
float getAttributeValueAsFloat(const char_type* name) const
|
||||
{
|
||||
const SAttribute* attr = getAttributeByName(name);
|
||||
if (!attr)
|
||||
return 0;
|
||||
|
||||
core::stringc c = attr->Value.c_str();
|
||||
return fast_atof(c.c_str());
|
||||
}
|
||||
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
float getAttributeValueAsFloat(int idx) const
|
||||
{
|
||||
const char_type* attrvalue = getAttributeValue(idx);
|
||||
if (!attrvalue)
|
||||
return 0;
|
||||
|
||||
core::stringc c = attrvalue;
|
||||
return fast_atof(c.c_str());
|
||||
}
|
||||
|
||||
|
||||
//! Returns the name of the current node.
|
||||
virtual const char_type* getNodeName() const
|
||||
{
|
||||
return NodeName.c_str();
|
||||
}
|
||||
|
||||
|
||||
//! Returns data of the current node.
|
||||
virtual const char_type* getNodeData() const
|
||||
{
|
||||
return NodeName.c_str();
|
||||
}
|
||||
|
||||
|
||||
//! Returns if an element is an empty element, like <foo />
|
||||
virtual bool isEmptyElement() const
|
||||
{
|
||||
return IsEmptyElement;
|
||||
}
|
||||
|
||||
//! Returns format of the source xml file.
|
||||
virtual ETEXT_FORMAT getSourceFormat() const
|
||||
{
|
||||
return SourceFormat;
|
||||
}
|
||||
|
||||
//! Returns format of the strings returned by the parser.
|
||||
virtual ETEXT_FORMAT getParserFormat() const
|
||||
{
|
||||
return TargetFormat;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Reads the current xml node
|
||||
void parseCurrentNode()
|
||||
{
|
||||
char_type* start = P;
|
||||
|
||||
// more forward until '<' found
|
||||
while(*P != L'<' && *P)
|
||||
++P;
|
||||
|
||||
if (!*P)
|
||||
return;
|
||||
|
||||
if (P - start > 0)
|
||||
{
|
||||
// we found some text, store it
|
||||
if (setText(start, P))
|
||||
return;
|
||||
}
|
||||
|
||||
++P;
|
||||
|
||||
// based on current token, parse and report next element
|
||||
switch(*P)
|
||||
{
|
||||
case L'/':
|
||||
parseClosingXMLElement();
|
||||
break;
|
||||
case L'?':
|
||||
ignoreDefinition();
|
||||
break;
|
||||
case L'!':
|
||||
if (!parseCDATA())
|
||||
parseComment();
|
||||
break;
|
||||
default:
|
||||
parseOpeningXMLElement();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! sets the state that text was found. Returns true if set should be set
|
||||
bool setText(char_type* start, char_type* end)
|
||||
{
|
||||
// check if text is more than 2 characters, and if not, check if there is
|
||||
// only white space, so that this text won't be reported
|
||||
if (end - start < 3)
|
||||
{
|
||||
char_type* p = start;
|
||||
for(; p != end; ++p)
|
||||
if (!isWhiteSpace(*p))
|
||||
break;
|
||||
|
||||
if (p == end)
|
||||
return false;
|
||||
}
|
||||
|
||||
// set current text to the parsed text, and replace xml special characters
|
||||
core::string<char_type> s(start, (int)(end - start));
|
||||
NodeName = replaceSpecialCharacters(s);
|
||||
|
||||
// current XML node type is text
|
||||
CurrentNodeType = EXN_TEXT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! ignores an xml definition like <?xml something />
|
||||
void ignoreDefinition()
|
||||
{
|
||||
CurrentNodeType = EXN_UNKNOWN;
|
||||
|
||||
// move until end marked with '>' reached
|
||||
while(*P != L'>')
|
||||
++P;
|
||||
|
||||
++P;
|
||||
}
|
||||
|
||||
|
||||
//! parses a comment
|
||||
void parseComment()
|
||||
{
|
||||
CurrentNodeType = EXN_COMMENT;
|
||||
P += 1;
|
||||
|
||||
char_type *pCommentBegin = P;
|
||||
|
||||
int count = 1;
|
||||
|
||||
// move until end of comment reached
|
||||
while(count)
|
||||
{
|
||||
if (*P == L'>')
|
||||
--count;
|
||||
else
|
||||
if (*P == L'<')
|
||||
++count;
|
||||
|
||||
++P;
|
||||
}
|
||||
|
||||
P -= 3;
|
||||
NodeName = core::string<char_type>(pCommentBegin+2, (int)(P - pCommentBegin-2));
|
||||
P += 3;
|
||||
}
|
||||
|
||||
|
||||
//! parses an opening xml element and reads attributes
|
||||
void parseOpeningXMLElement()
|
||||
{
|
||||
CurrentNodeType = EXN_ELEMENT;
|
||||
IsEmptyElement = false;
|
||||
Attributes.clear();
|
||||
|
||||
// find name
|
||||
const char_type* startName = P;
|
||||
|
||||
// find end of element
|
||||
while(*P != L'>' && !isWhiteSpace(*P))
|
||||
++P;
|
||||
|
||||
const char_type* endName = P;
|
||||
|
||||
// find Attributes
|
||||
while(*P != L'>')
|
||||
{
|
||||
if (isWhiteSpace(*P))
|
||||
++P;
|
||||
else
|
||||
{
|
||||
if (*P != L'/')
|
||||
{
|
||||
// we've got an attribute
|
||||
|
||||
// read the attribute names
|
||||
const char_type* attributeNameBegin = P;
|
||||
|
||||
while(!isWhiteSpace(*P) && *P != L'=')
|
||||
++P;
|
||||
|
||||
const char_type* attributeNameEnd = P;
|
||||
++P;
|
||||
|
||||
// read the attribute value
|
||||
// check for quotes and single quotes, thx to murphy
|
||||
while( (*P != L'\"') && (*P != L'\'') && *P)
|
||||
++P;
|
||||
|
||||
if (!*P) // malformatted xml file
|
||||
return;
|
||||
|
||||
const char_type attributeQuoteChar = *P;
|
||||
|
||||
++P;
|
||||
const char_type* attributeValueBegin = P;
|
||||
|
||||
while(*P != attributeQuoteChar && *P)
|
||||
++P;
|
||||
|
||||
if (!*P) // malformatted xml file
|
||||
return;
|
||||
|
||||
const char_type* attributeValueEnd = P;
|
||||
++P;
|
||||
|
||||
SAttribute attr;
|
||||
attr.Name = core::string<char_type>(attributeNameBegin,
|
||||
(int)(attributeNameEnd - attributeNameBegin));
|
||||
|
||||
core::string<char_type> s(attributeValueBegin,
|
||||
(int)(attributeValueEnd - attributeValueBegin));
|
||||
|
||||
attr.Value = replaceSpecialCharacters(s);
|
||||
Attributes.push_back(attr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// tag is closed directly
|
||||
++P;
|
||||
IsEmptyElement = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if this tag is closing directly
|
||||
if (endName > startName && *(endName-1) == L'/')
|
||||
{
|
||||
// directly closing tag
|
||||
IsEmptyElement = true;
|
||||
endName--;
|
||||
}
|
||||
|
||||
NodeName = core::string<char_type>(startName, (int)(endName - startName));
|
||||
|
||||
++P;
|
||||
}
|
||||
|
||||
|
||||
//! parses an closing xml tag
|
||||
void parseClosingXMLElement()
|
||||
{
|
||||
CurrentNodeType = EXN_ELEMENT_END;
|
||||
IsEmptyElement = false;
|
||||
Attributes.clear();
|
||||
|
||||
++P;
|
||||
const char_type* pBeginClose = P;
|
||||
|
||||
while(*P != L'>')
|
||||
++P;
|
||||
|
||||
NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose));
|
||||
++P;
|
||||
}
|
||||
|
||||
//! parses a possible CDATA section, returns false if begin was not a CDATA section
|
||||
bool parseCDATA()
|
||||
{
|
||||
if (*(P+1) != L'[')
|
||||
return false;
|
||||
|
||||
CurrentNodeType = EXN_CDATA;
|
||||
|
||||
// skip '<![CDATA['
|
||||
int count=0;
|
||||
while( *P && count<8 )
|
||||
{
|
||||
++P;
|
||||
++count;
|
||||
}
|
||||
|
||||
if (!*P)
|
||||
return true;
|
||||
|
||||
char_type *cDataBegin = P;
|
||||
char_type *cDataEnd = 0;
|
||||
|
||||
// find end of CDATA
|
||||
while(*P && !cDataEnd)
|
||||
{
|
||||
if (*P == L'>' &&
|
||||
(*(P-1) == L']') &&
|
||||
(*(P-2) == L']'))
|
||||
{
|
||||
cDataEnd = P - 2;
|
||||
}
|
||||
|
||||
++P;
|
||||
}
|
||||
|
||||
if ( cDataEnd )
|
||||
NodeName = core::string<char_type>(cDataBegin, (int)(cDataEnd - cDataBegin));
|
||||
else
|
||||
NodeName = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// structure for storing attribute-name pairs
|
||||
struct SAttribute
|
||||
{
|
||||
core::string<char_type> Name;
|
||||
core::string<char_type> Value;
|
||||
};
|
||||
|
||||
// finds a current attribute by name, returns 0 if not found
|
||||
const SAttribute* getAttributeByName(const char_type* name) const
|
||||
{
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
core::string<char_type> n = name;
|
||||
|
||||
for (int i=0; i<(int)Attributes.size(); ++i)
|
||||
if (Attributes[i].Name == n)
|
||||
return &Attributes[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// replaces xml special characters in a string and creates a new one
|
||||
core::string<char_type> replaceSpecialCharacters(
|
||||
core::string<char_type>& origstr)
|
||||
{
|
||||
int pos = origstr.findFirst(L'&');
|
||||
int oldPos = 0;
|
||||
|
||||
if (pos == -1)
|
||||
return origstr;
|
||||
|
||||
core::string<char_type> newstr;
|
||||
|
||||
while(pos != -1 && pos < origstr.size()-2)
|
||||
{
|
||||
// check if it is one of the special characters
|
||||
|
||||
int specialChar = -1;
|
||||
for (int i=0; i<(int)SpecialCharacters.size(); ++i)
|
||||
{
|
||||
const char_type* p = &origstr.c_str()[pos]+1;
|
||||
|
||||
if (equalsn(&SpecialCharacters[i][1], p, SpecialCharacters[i].size()-1))
|
||||
{
|
||||
specialChar = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specialChar != -1)
|
||||
{
|
||||
newstr.append(origstr.subString(oldPos, pos - oldPos));
|
||||
newstr.append(SpecialCharacters[specialChar][0]);
|
||||
pos += SpecialCharacters[specialChar].size();
|
||||
}
|
||||
else
|
||||
{
|
||||
newstr.append(origstr.subString(oldPos, pos - oldPos + 1));
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
// find next &
|
||||
oldPos = pos;
|
||||
pos = origstr.findNext(L'&', pos);
|
||||
}
|
||||
|
||||
if (oldPos < origstr.size()-1)
|
||||
newstr.append(origstr.subString(oldPos, origstr.size()-oldPos));
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! reads the xml file and converts it into the wanted character format.
|
||||
bool readFile(IFileReadCallBack* callback)
|
||||
{
|
||||
int size = callback->getSize();
|
||||
size += 4; // We need two terminating 0's at the end.
|
||||
// For ASCII we need 1 0's, for UTF-16 2, for UTF-32 4.
|
||||
|
||||
char* data8 = new char[size];
|
||||
|
||||
if (!callback->read(data8, size-4))
|
||||
{
|
||||
delete [] data8;
|
||||
return false;
|
||||
}
|
||||
|
||||
// add zeros at end
|
||||
|
||||
data8[size-1] = 0;
|
||||
data8[size-2] = 0;
|
||||
data8[size-3] = 0;
|
||||
data8[size-4] = 0;
|
||||
|
||||
char16* data16 = reinterpret_cast<char16*>(data8);
|
||||
char32* data32 = reinterpret_cast<char32*>(data8);
|
||||
|
||||
// now we need to convert the data to the desired target format
|
||||
// based on the byte order mark.
|
||||
|
||||
const unsigned char UTF8[] = {0xEF, 0xBB, 0xBF}; // 0xEFBBBF;
|
||||
const int UTF16_BE = 0xFFFE;
|
||||
const int UTF16_LE = 0xFEFF;
|
||||
const int UTF32_BE = 0xFFFE0000;
|
||||
const int UTF32_LE = 0x0000FEFF;
|
||||
|
||||
// check source for all utf versions and convert to target data format
|
||||
|
||||
if (size >= 4 && data32[0] == (char32)UTF32_BE)
|
||||
{
|
||||
// UTF-32, big endian
|
||||
SourceFormat = ETF_UTF32_BE;
|
||||
convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header
|
||||
}
|
||||
else
|
||||
if (size >= 4 && data32[0] == (char32)UTF32_LE)
|
||||
{
|
||||
// UTF-32, little endian
|
||||
SourceFormat = ETF_UTF32_LE;
|
||||
convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header
|
||||
}
|
||||
else
|
||||
if (size >= 2 && data16[0] == UTF16_BE)
|
||||
{
|
||||
// UTF-16, big endian
|
||||
SourceFormat = ETF_UTF16_BE;
|
||||
convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header
|
||||
}
|
||||
else
|
||||
if (size >= 2 && data16[0] == UTF16_LE)
|
||||
{
|
||||
// UTF-16, little endian
|
||||
SourceFormat = ETF_UTF16_LE;
|
||||
convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header
|
||||
}
|
||||
else
|
||||
if (size >= 3 && data8[0] == UTF8[0] && data8[1] == UTF8[1] && data8[2] == UTF8[2])
|
||||
{
|
||||
// UTF-8
|
||||
SourceFormat = ETF_UTF8;
|
||||
convertTextData(data8+3, data8, size); // data8+3 because we need to skip the header
|
||||
}
|
||||
else
|
||||
{
|
||||
// ASCII
|
||||
SourceFormat = ETF_ASCII;
|
||||
convertTextData(data8, data8, size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! converts the text file into the desired format.
|
||||
//! \param source: begin of the text (without byte order mark)
|
||||
//! \param pointerToStore: pointer to text data block which can be
|
||||
//! stored or deleted based on the nesessary conversion.
|
||||
//! \param sizeWithoutHeader: Text size in characters without header
|
||||
template<class src_char_type>
|
||||
void convertTextData(src_char_type* source, char* pointerToStore, int sizeWithoutHeader)
|
||||
{
|
||||
// convert little to big endian if necessary
|
||||
if (sizeof(src_char_type) > 1 &&
|
||||
isLittleEndian(TargetFormat) != isLittleEndian(SourceFormat))
|
||||
convertToLittleEndian(source);
|
||||
|
||||
// check if conversion is necessary:
|
||||
if (sizeof(src_char_type) == sizeof(char_type))
|
||||
{
|
||||
// no need to convert
|
||||
TextBegin = (char_type*)source;
|
||||
TextData = (char_type*)pointerToStore;
|
||||
TextSize = sizeWithoutHeader;
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert source into target data format.
|
||||
// TODO: implement a real conversion. This one just
|
||||
// copies bytes. This is a problem when there are
|
||||
// unicode symbols using more than one character.
|
||||
|
||||
TextData = new char_type[sizeWithoutHeader];
|
||||
|
||||
// MSVC debugger complains here about loss of data ...
|
||||
// todo ... I temporarily disabled the check in the build config
|
||||
for (int i=0; i<sizeWithoutHeader; ++i)
|
||||
TextData[i] = (char_type)source[i];
|
||||
|
||||
TextBegin = TextData;
|
||||
TextSize = sizeWithoutHeader;
|
||||
|
||||
// delete original data because no longer needed
|
||||
delete [] pointerToStore;
|
||||
}
|
||||
}
|
||||
|
||||
//! converts whole text buffer to little endian
|
||||
template<class src_char_type>
|
||||
void convertToLittleEndian(src_char_type* t)
|
||||
{
|
||||
if (sizeof(src_char_type) == 4)
|
||||
{
|
||||
// 32 bit
|
||||
|
||||
while(*t)
|
||||
{
|
||||
*t = ((*t & 0xff000000) >> 24) |
|
||||
((*t & 0x00ff0000) >> 8) |
|
||||
((*t & 0x0000ff00) << 8) |
|
||||
((*t & 0x000000ff) << 24);
|
||||
++t;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
|
||||
while(*t)
|
||||
{
|
||||
*t = (*t >> 8) | (*t << 8);
|
||||
++t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! returns if a format is little endian
|
||||
inline bool isLittleEndian(ETEXT_FORMAT f)
|
||||
{
|
||||
return f == ETF_ASCII ||
|
||||
f == ETF_UTF8 ||
|
||||
f == ETF_UTF16_LE ||
|
||||
f == ETF_UTF32_LE;
|
||||
}
|
||||
|
||||
|
||||
//! returns true if a character is whitespace
|
||||
inline bool isWhiteSpace(char_type c)
|
||||
{
|
||||
return (c==' ' || c=='\t' || c=='\n' || c=='\r');
|
||||
}
|
||||
|
||||
|
||||
//! generates a list with xml special characters
|
||||
void createSpecialCharacterList()
|
||||
{
|
||||
// list of strings containing special symbols,
|
||||
// the first character is the special character,
|
||||
// the following is the symbol string without trailing &.
|
||||
|
||||
SpecialCharacters.push_back("&");
|
||||
SpecialCharacters.push_back("<lt;");
|
||||
SpecialCharacters.push_back(">gt;");
|
||||
SpecialCharacters.push_back("\"quot;");
|
||||
SpecialCharacters.push_back("'apos;");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! compares the first n characters of the strings
|
||||
bool equalsn(const char_type* str1, const char_type* str2, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; str1[i] && str2[i] && i < len; ++i)
|
||||
if (str1[i] != str2[i])
|
||||
return false;
|
||||
|
||||
// if one (or both) of the strings was smaller then they
|
||||
// are only equal if they have the same lenght
|
||||
return (i == len) || (str1[i] == 0 && str2[i] == 0);
|
||||
}
|
||||
|
||||
|
||||
//! stores the target text format
|
||||
void storeTargetFormat()
|
||||
{
|
||||
// get target format. We could have done this using template specialization,
|
||||
// but VisualStudio 6 don't like it and we want to support it.
|
||||
|
||||
switch(sizeof(char_type))
|
||||
{
|
||||
case 1:
|
||||
TargetFormat = ETF_UTF8;
|
||||
break;
|
||||
case 2:
|
||||
TargetFormat = ETF_UTF16_LE;
|
||||
break;
|
||||
case 4:
|
||||
TargetFormat = ETF_UTF32_LE;
|
||||
break;
|
||||
default:
|
||||
TargetFormat = ETF_ASCII; // should never happen.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// instance variables:
|
||||
|
||||
char_type* TextData; // data block of the text file
|
||||
char_type* P; // current point in text to parse
|
||||
char_type* TextBegin; // start of text to parse
|
||||
unsigned int TextSize; // size of text to parse in characters, not bytes
|
||||
|
||||
EXML_NODE CurrentNodeType; // type of the currently parsed node
|
||||
ETEXT_FORMAT SourceFormat; // source format of the xml file
|
||||
ETEXT_FORMAT TargetFormat; // output format of this parser
|
||||
|
||||
core::string<char_type> NodeName; // name of the node currently in
|
||||
core::string<char_type> EmptyString; // empty string to be returned by getSafe() methods
|
||||
|
||||
bool IsEmptyElement; // is the currently parsed node empty?
|
||||
|
||||
core::array< core::string<char_type> > SpecialCharacters; // see createSpecialCharacterList()
|
||||
|
||||
core::array<SAttribute> Attributes; // attributes of current element
|
||||
|
||||
}; // end CXMLReaderImpl
|
||||
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,139 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
||||
|
||||
#ifndef __FAST_A_TO_F_H_INCLUDED__
|
||||
#define __FAST_A_TO_F_H_INCLUDED__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
const float fast_atof_table[] = {
|
||||
0.f,
|
||||
0.1f,
|
||||
0.01f,
|
||||
0.001f,
|
||||
0.0001f,
|
||||
0.00001f,
|
||||
0.000001f,
|
||||
0.0000001f,
|
||||
0.00000001f,
|
||||
0.000000001f,
|
||||
0.0000000001f,
|
||||
0.00000000001f,
|
||||
0.000000000001f,
|
||||
0.0000000000001f,
|
||||
0.00000000000001f,
|
||||
0.000000000000001f
|
||||
};
|
||||
|
||||
//! Provides a fast function for converting a string into a float,
|
||||
//! about 6 times faster than atof in win32.
|
||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||
inline char* fast_atof_move(char* c, float& out)
|
||||
{
|
||||
bool inv = false;
|
||||
char *t;
|
||||
float f;
|
||||
|
||||
if (*c=='-')
|
||||
{
|
||||
c++;
|
||||
inv = true;
|
||||
}
|
||||
|
||||
f = (float)strtol(c, &t, 10);
|
||||
|
||||
c = t;
|
||||
|
||||
if (*c == '.')
|
||||
{
|
||||
c++;
|
||||
|
||||
float pl = (float)strtol(c, &t, 10);
|
||||
pl *= fast_atof_table[t-c];
|
||||
|
||||
f += pl;
|
||||
|
||||
c = t;
|
||||
|
||||
if (*c == 'e')
|
||||
{
|
||||
++c;
|
||||
float exp = (float)strtol(c, &t, 10);
|
||||
f *= (float)pow(10.0f, exp);
|
||||
c = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (inv)
|
||||
f *= -1.0f;
|
||||
|
||||
out = f;
|
||||
return c;
|
||||
}
|
||||
|
||||
//! Provides a fast function for converting a string into a float,
|
||||
//! about 6 times faster than atof in win32.
|
||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||
inline const char* fast_atof_move_const(const char* c, float& out)
|
||||
{
|
||||
bool inv = false;
|
||||
char *t;
|
||||
float f;
|
||||
|
||||
if (*c=='-')
|
||||
{
|
||||
c++;
|
||||
inv = true;
|
||||
}
|
||||
|
||||
f = (float)strtol(c, &t, 10);
|
||||
|
||||
c = t;
|
||||
|
||||
if (*c == '.')
|
||||
{
|
||||
c++;
|
||||
|
||||
float pl = (float)strtol(c, &t, 10);
|
||||
pl *= fast_atof_table[t-c];
|
||||
|
||||
f += pl;
|
||||
|
||||
c = t;
|
||||
|
||||
if (*c == 'e')
|
||||
{
|
||||
++c;
|
||||
f32 exp = (f32)strtol(c, &t, 10);
|
||||
f *= (f32)powf(10.0f, exp);
|
||||
c = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (inv)
|
||||
f *= -1.0f;
|
||||
|
||||
out = f;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
inline float fast_atof(const char* c)
|
||||
{
|
||||
float ret;
|
||||
fast_atof_move_const(c, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace core
|
||||
}// end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_HEAPSORT_H_INCLUDED__
|
||||
#define __IRR_HEAPSORT_H_INCLUDED__
|
||||
|
||||
#include "irrTypes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
//! Sinks an element into the heap.
|
||||
template<class T>
|
||||
inline void heapsink(T*array, s32 element, s32 max)
|
||||
{
|
||||
while ((element<<1) < max) // there is a left child
|
||||
{
|
||||
s32 j = (element<<1);
|
||||
|
||||
if (j+1 < max && array[j] < array[j+1])
|
||||
j = j+1; // take right child
|
||||
|
||||
if (array[element] < array[j])
|
||||
{
|
||||
T t = array[j]; // swap elements
|
||||
array[j] = array[element];
|
||||
array[element] = t;
|
||||
element = j;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Sorts an array with size 'size' using heapsort.
|
||||
template<class T>
|
||||
inline void heapsort(T* array_, s32 size)
|
||||
{
|
||||
// for heapsink we pretent this is not c++, where
|
||||
// arrays start with index 0. So we decrease the array pointer,
|
||||
// the maximum always +2 and the element always +1
|
||||
|
||||
T* virtualArray = array_ - 1;
|
||||
s32 virtualSize = size + 2;
|
||||
s32 i;
|
||||
|
||||
// build heap
|
||||
|
||||
for (i=((size-1)/2); i>=0; --i)
|
||||
heapsink(virtualArray, i+1, virtualSize-1);
|
||||
|
||||
// sort array
|
||||
|
||||
for (i=size-1; i>=0; --i)
|
||||
{
|
||||
T t = array_[0];
|
||||
array_[0] = array_[i];
|
||||
array_[i] = t;
|
||||
heapsink(virtualArray, 1, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,444 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
||||
|
||||
#ifndef __IRR_ARRAY_H_INCLUDED__
|
||||
#define __IRR_ARRAY_H_INCLUDED__
|
||||
|
||||
#include "irrTypes.h"
|
||||
#include "heapsort.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
//! Self reallocating template array (like stl vector) with additional features.
|
||||
/** Some features are: Heap sorting, binary search methods, easier debugging.
|
||||
*/
|
||||
template <class T>
|
||||
class array
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
array()
|
||||
: data(0), used(0), allocated(0),
|
||||
free_when_destroyed(true), is_sorted(true)
|
||||
{
|
||||
}
|
||||
|
||||
//! Constructs a array and allocates an initial chunk of memory.
|
||||
//! \param start_count: Amount of elements to allocate.
|
||||
array(u32 start_count)
|
||||
: data(0), used(0), allocated(0),
|
||||
free_when_destroyed(true), is_sorted(true)
|
||||
{
|
||||
reallocate(start_count);
|
||||
}
|
||||
|
||||
|
||||
//! Copy constructor
|
||||
array(const array<T>& other)
|
||||
: data(0)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Destructor. Frees allocated memory, if set_free_when_destroyed
|
||||
//! was not set to false by the user before.
|
||||
~array()
|
||||
{
|
||||
if (free_when_destroyed)
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Reallocates the array, make it bigger or smaller.
|
||||
//! \param new_size: New size of array.
|
||||
void reallocate(u32 new_size)
|
||||
{
|
||||
T* old_data = data;
|
||||
|
||||
data = new T[new_size];
|
||||
allocated = new_size;
|
||||
|
||||
s32 end = used < new_size ? used : new_size;
|
||||
for (s32 i=0; i<end; ++i)
|
||||
data[i] = old_data[i];
|
||||
|
||||
if (allocated < used)
|
||||
used = allocated;
|
||||
|
||||
delete [] old_data;
|
||||
}
|
||||
|
||||
//! Adds an element at back of array. If the array is to small to
|
||||
//! add this new element, the array is made bigger.
|
||||
//! \param element: Element to add at the back of the array.
|
||||
void push_back(const T& element)
|
||||
{
|
||||
if (used + 1 > allocated)
|
||||
{
|
||||
// reallocate(used * 2 +1);
|
||||
// this doesn't work if the element is in the same array. So
|
||||
// we'll copy the element first to be sure we'll get no data
|
||||
// corruption
|
||||
|
||||
T e;
|
||||
e = element; // copy element
|
||||
reallocate(used * 2 +1); // increase data block
|
||||
data[used++] = e; // push_back
|
||||
is_sorted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
data[used++] = element;
|
||||
is_sorted = false;
|
||||
}
|
||||
|
||||
|
||||
//! Adds an element at the front of the array. If the array is to small to
|
||||
//! add this new element, the array is made bigger. Please note that this
|
||||
//! is slow, because the whole array needs to be copied for this.
|
||||
//! \param element: Element to add at the back of the array.
|
||||
void push_front(const T& element)
|
||||
{
|
||||
if (used + 1 > allocated)
|
||||
reallocate(used * 2 +1);
|
||||
|
||||
for (int i=(int)used; i>0; --i)
|
||||
data[i] = data[i-1];
|
||||
|
||||
data[0] = element;
|
||||
is_sorted = false;
|
||||
++used;
|
||||
}
|
||||
|
||||
|
||||
//! Insert item into array at specified position. Please use this
|
||||
//! only if you know what you are doing (possible performance loss).
|
||||
//! The preferred method of adding elements should be push_back().
|
||||
//! \param element: Element to be inserted
|
||||
//! \param index: Where position to insert the new element.
|
||||
void insert(const T& element, u32 index=0)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>used) // access violation
|
||||
|
||||
if (used + 1 > allocated)
|
||||
reallocate(used * 2 +1);
|
||||
|
||||
for (u32 i=used++; i>index; i--)
|
||||
data[i] = data[i-1];
|
||||
|
||||
data[index] = element;
|
||||
is_sorted = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//! Clears the array and deletes all allocated memory.
|
||||
void clear()
|
||||
{
|
||||
delete [] data;
|
||||
data = 0;
|
||||
used = 0;
|
||||
allocated = 0;
|
||||
is_sorted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Sets pointer to new array, using this as new workspace.
|
||||
//! \param newPointer: Pointer to new array of elements.
|
||||
//! \param size: Size of the new array.
|
||||
void set_pointer(T* newPointer, u32 size)
|
||||
{
|
||||
delete [] data;
|
||||
data = newPointer;
|
||||
allocated = size;
|
||||
used = size;
|
||||
is_sorted = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Sets if the array should delete the memory it used.
|
||||
//! \param f: If true, the array frees the allocated memory in its
|
||||
//! destructor, otherwise not. The default is true.
|
||||
void set_free_when_destroyed(bool f)
|
||||
{
|
||||
free_when_destroyed = f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Sets the size of the array.
|
||||
//! \param usedNow: Amount of elements now used.
|
||||
void set_used(u32 usedNow)
|
||||
{
|
||||
if (allocated < usedNow)
|
||||
reallocate(usedNow);
|
||||
|
||||
used = usedNow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Assignement operator
|
||||
void operator=(const array<T>& other)
|
||||
{
|
||||
if (data)
|
||||
delete [] data;
|
||||
|
||||
//if (allocated < other.allocated)
|
||||
if (other.allocated == 0)
|
||||
data = 0;
|
||||
else
|
||||
data = new T[other.allocated];
|
||||
|
||||
used = other.used;
|
||||
free_when_destroyed = other.free_when_destroyed;
|
||||
is_sorted = other.is_sorted;
|
||||
allocated = other.allocated;
|
||||
|
||||
for (u32 i=0; i<other.used; ++i)
|
||||
data[i] = other.data[i];
|
||||
}
|
||||
|
||||
|
||||
//! Direct access operator
|
||||
T& operator [](u32 index)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used) // access violation
|
||||
|
||||
return data[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Direct access operator
|
||||
const T& operator [](u32 index) const
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used) // access violation
|
||||
|
||||
return data[index];
|
||||
}
|
||||
|
||||
//! Gets last frame
|
||||
const T& getLast() const
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!used) // access violation
|
||||
|
||||
return data[used-1];
|
||||
}
|
||||
|
||||
//! Gets last frame
|
||||
T& getLast()
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(!used) // access violation
|
||||
|
||||
return data[used-1];
|
||||
}
|
||||
|
||||
|
||||
//! Returns a pointer to the array.
|
||||
//! \return Pointer to the array.
|
||||
T* pointer()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns a const pointer to the array.
|
||||
//! \return Pointer to the array.
|
||||
const T* const_pointer() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns size of used array.
|
||||
//! \return Size of elements in the array.
|
||||
u32 size() const
|
||||
{
|
||||
return used;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns amount memory allocated.
|
||||
//! \return Returns amount of memory allocated. The amount of bytes
|
||||
//! allocated would be allocated_size() * sizeof(ElementsUsed);
|
||||
u32 allocated_size() const
|
||||
{
|
||||
return allocated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns true if array is empty
|
||||
//! \return True if the array is empty, false if not.
|
||||
bool empty() const
|
||||
{
|
||||
return used == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Sorts the array using heapsort. There is no additional memory waste and
|
||||
//! the algorithm performs (O) n log n in worst case.
|
||||
void sort()
|
||||
{
|
||||
if (is_sorted || used<2)
|
||||
return;
|
||||
|
||||
heapsort(data, used);
|
||||
is_sorted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Performs a binary search for an element, returns -1 if not found.
|
||||
//! The array will be sorted before the binary search if it is not
|
||||
//! already sorted.
|
||||
//! \param element: Element to search for.
|
||||
//! \return Returns position of the searched element if it was found,
|
||||
//! otherwise -1 is returned.
|
||||
s32 binary_search(const T& element)
|
||||
{
|
||||
return binary_search(element, 0, used-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Performs a binary search for an element, returns -1 if not found.
|
||||
//! The array will be sorted before the binary search if it is not
|
||||
//! already sorted.
|
||||
//! \param element: Element to search for.
|
||||
//! \param left: First left index
|
||||
//! \param right: Last right index.
|
||||
//! \return Returns position of the searched element if it was found,
|
||||
//! otherwise -1 is returned.
|
||||
s32 binary_search(const T& element, s32 left, s32 right)
|
||||
{
|
||||
if (!used)
|
||||
return -1;
|
||||
|
||||
sort();
|
||||
|
||||
s32 m;
|
||||
|
||||
do
|
||||
{
|
||||
m = (left+right)>>1;
|
||||
|
||||
if (element < data[m])
|
||||
right = m - 1;
|
||||
else
|
||||
left = m + 1;
|
||||
|
||||
} while((element < data[m] || data[m] < element) && left<=right);
|
||||
|
||||
// this last line equals to:
|
||||
// " while((element != array[m]) && left<=right);"
|
||||
// but we only want to use the '<' operator.
|
||||
// the same in next line, it is "(element == array[m])"
|
||||
|
||||
if (!(element < data[m]) && !(data[m] < element))
|
||||
return m;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Finds an element in linear time, which is very slow. Use
|
||||
//! binary_search for faster finding. Only works if =operator is implemented.
|
||||
//! \param element: Element to search for.
|
||||
//! \return Returns position of the searched element if it was found,
|
||||
//! otherwise -1 is returned.
|
||||
s32 linear_search(T& element)
|
||||
{
|
||||
for (u32 i=0; i<used; ++i)
|
||||
if (!(element < data[i]) && !(data[i] < element))
|
||||
return (s32)i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Finds an element in linear time, which is very slow. Use
|
||||
//! binary_search for faster finding. Only works if =operator is implemented.
|
||||
//! \param element: Element to search for.
|
||||
//! \return Returns position of the searched element if it was found,
|
||||
//! otherwise -1 is returned.
|
||||
s32 linear_reverse_search(T& element)
|
||||
{
|
||||
for (s32 i=used-1; i>=0; --i)
|
||||
if (data[i] == element)
|
||||
return (s32)i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Erases an element from the array. May be slow, because all elements
|
||||
//! following after the erased element have to be copied.
|
||||
//! \param index: Index of element to be erased.
|
||||
void erase(u32 index)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used || index<0) // access violation
|
||||
|
||||
for (u32 i=index+1; i<used; ++i)
|
||||
data[i-1] = data[i];
|
||||
|
||||
--used;
|
||||
}
|
||||
|
||||
|
||||
//! Erases some elements from the array. may be slow, because all elements
|
||||
//! following after the erased element have to be copied.
|
||||
//! \param index: Index of the first element to be erased.
|
||||
//! \param count: Amount of elements to be erased.
|
||||
void erase(u32 index, s32 count)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used || index<0 || count<1 || index+count>used) // access violation
|
||||
|
||||
for (u32 i=index+count; i<used; ++i)
|
||||
data[i-count] = data[i];
|
||||
|
||||
used-= count;
|
||||
}
|
||||
|
||||
|
||||
//! Sets if the array is sorted
|
||||
void set_sorted(bool _is_sorted)
|
||||
{
|
||||
is_sorted = _is_sorted;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
T* data;
|
||||
u32 allocated;
|
||||
u32 used;
|
||||
bool free_when_destroyed;
|
||||
bool is_sorted;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,664 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
||||
|
||||
#ifndef __IRR_STRING_H_INCLUDED__
|
||||
#define __IRR_STRING_H_INCLUDED__
|
||||
|
||||
#include "irrTypes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
//! Very simple string class with some useful features.
|
||||
/** string<c8> and string<wchar_t> work both with unicode AND ascii,
|
||||
so you can assign unicode to string<c8> and ascii to string<wchar_t>
|
||||
(and the other way round) if your ever would want to.
|
||||
Note that the conversation between both is not done using an encoding.
|
||||
|
||||
Known bugs:
|
||||
Special characters like 'Ä', 'Ü' and 'Ö' are ignored in the
|
||||
methods make_upper, make_lower and equals_ignore_case.
|
||||
*/
|
||||
template <class T>
|
||||
class string
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
string()
|
||||
: allocated(1), used(1), array(0)
|
||||
{
|
||||
array = new T[1];
|
||||
array[0] = 0x0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor
|
||||
string(const string<T>& other)
|
||||
: allocated(0), used(0), array(0)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
||||
//! Constructs a string from an int
|
||||
string(int number)
|
||||
: allocated(0), used(0), array(0)
|
||||
{
|
||||
// store if negative and make positive
|
||||
|
||||
bool negative = false;
|
||||
if (number < 0)
|
||||
{
|
||||
number *= -1;
|
||||
negative = true;
|
||||
}
|
||||
|
||||
// temporary buffer for 16 numbers
|
||||
|
||||
c8 tmpbuf[16];
|
||||
tmpbuf[15] = 0;
|
||||
s32 idx = 15;
|
||||
|
||||
// special case '0'
|
||||
|
||||
if (!number)
|
||||
{
|
||||
tmpbuf[14] = '0';
|
||||
*this = &tmpbuf[14];
|
||||
return;
|
||||
}
|
||||
|
||||
// add numbers
|
||||
|
||||
while(number && idx)
|
||||
{
|
||||
idx--;
|
||||
tmpbuf[idx] = (c8)('0' + (number % 10));
|
||||
number = number / 10;
|
||||
}
|
||||
|
||||
// add sign
|
||||
|
||||
if (negative)
|
||||
{
|
||||
idx--;
|
||||
tmpbuf[idx] = '-';
|
||||
}
|
||||
|
||||
*this = &tmpbuf[idx];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor for copying a string from a pointer with a given lenght
|
||||
template <class B>
|
||||
string(const B* c, s32 lenght)
|
||||
: allocated(0), used(0), array(0)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
allocated = used = lenght+1;
|
||||
array = new T[used];
|
||||
|
||||
for (s32 l = 0; l<lenght; ++l)
|
||||
array[l] = (T)c[l];
|
||||
|
||||
array[lenght] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Constructor for unicode and ascii strings
|
||||
template <class B>
|
||||
string(const B* c)
|
||||
: allocated(0), used(0), array(0)
|
||||
{
|
||||
*this = c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! destructor
|
||||
~string()
|
||||
{
|
||||
delete [] array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Assignment operator
|
||||
string<T>& operator=(const string<T>& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
delete [] array;
|
||||
allocated = used = other.size()+1;
|
||||
array = new T[used];
|
||||
|
||||
const T* p = other.c_str();
|
||||
for (s32 i=0; i<used; ++i, ++p)
|
||||
array[i] = *p;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Assignment operator for strings, ascii and unicode
|
||||
template <class B>
|
||||
string<T>& operator=(const B* c)
|
||||
{
|
||||
if (!c)
|
||||
{
|
||||
if (!array)
|
||||
{
|
||||
array = new T[1];
|
||||
allocated = 1;
|
||||
used = 1;
|
||||
}
|
||||
array[0] = 0x0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if ((void*)c == (void*)array)
|
||||
return *this;
|
||||
|
||||
s32 len = 0;
|
||||
const B* p = c;
|
||||
while(*p)
|
||||
{
|
||||
++len;
|
||||
++p;
|
||||
}
|
||||
|
||||
// we'll take the old string for a while, because the new string could be
|
||||
// a part of the current string.
|
||||
T* oldArray = array;
|
||||
|
||||
allocated = used = len+1;
|
||||
array = new T[used];
|
||||
|
||||
for (s32 l = 0; l<len+1; ++l)
|
||||
array[l] = (T)c[l];
|
||||
|
||||
delete [] oldArray;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Add operator for other strings
|
||||
string<T> operator+(const string<T>& other)
|
||||
{
|
||||
string<T> str(*this);
|
||||
str.append(other);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
//! Add operator for strings, ascii and unicode
|
||||
template <class B>
|
||||
string<T> operator+(const B* c)
|
||||
{
|
||||
string<T> str(*this);
|
||||
str.append(c);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Direct access operator
|
||||
T& operator [](const s32 index) const
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used) // bad index
|
||||
|
||||
return array[index];
|
||||
}
|
||||
|
||||
|
||||
//! Comparison operator
|
||||
bool operator ==(const T* str) const
|
||||
{
|
||||
int i;
|
||||
for(i=0; array[i] && str[i]; ++i)
|
||||
if (array[i] != str[i])
|
||||
return false;
|
||||
|
||||
return !array[i] && !str[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Comparison operator
|
||||
bool operator ==(const string<T>& other) const
|
||||
{
|
||||
for(s32 i=0; array[i] && other.array[i]; ++i)
|
||||
if (array[i] != other.array[i])
|
||||
return false;
|
||||
|
||||
return used == other.used;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Is smaller operator
|
||||
bool operator <(const string<T>& other) const
|
||||
{
|
||||
for(s32 i=0; array[i] && other.array[i]; ++i)
|
||||
if (array[i] != other.array[i])
|
||||
return (array[i] < other.array[i]);
|
||||
|
||||
return used < other.used;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Equals not operator
|
||||
bool operator !=(const string<T>& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns length of string
|
||||
/** \return Returns length of the string in characters. */
|
||||
s32 size() const
|
||||
{
|
||||
return used-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Returns character string
|
||||
/** \return Returns pointer to C-style zero terminated string. */
|
||||
const T* c_str() const
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Makes the string lower case.
|
||||
void make_lower()
|
||||
{
|
||||
const T A = (T)'A';
|
||||
const T Z = (T)'Z';
|
||||
const T diff = (T)'a' - A;
|
||||
|
||||
for (s32 i=0; i<used; ++i)
|
||||
{
|
||||
if (array[i]>=A && array[i]<=Z)
|
||||
array[i] += diff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Makes the string upper case.
|
||||
void make_upper()
|
||||
{
|
||||
const T a = (T)'a';
|
||||
const T z = (T)'z';
|
||||
const T diff = (T)'A' - a;
|
||||
|
||||
for (s32 i=0; i<used; ++i)
|
||||
{
|
||||
if (array[i]>=a && array[i]<=z)
|
||||
array[i] += diff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Compares the string ignoring case.
|
||||
/** \param other: Other string to compare.
|
||||
\return Returns true if the string are equal ignoring case. */
|
||||
bool equals_ignore_case(const string<T>& other) const
|
||||
{
|
||||
for(s32 i=0; array[i] && other[i]; ++i)
|
||||
if (toLower(array[i]) != toLower(other[i]))
|
||||
return false;
|
||||
|
||||
return used == other.used;
|
||||
}
|
||||
|
||||
|
||||
//! compares the first n characters of the strings
|
||||
bool equalsn(const string<T>& other, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; array[i] && other[i] && i < len; ++i)
|
||||
if (array[i] != other[i])
|
||||
return false;
|
||||
|
||||
// if one (or both) of the strings was smaller then they
|
||||
// are only equal if they have the same lenght
|
||||
return (i == len) || (used == other.used);
|
||||
}
|
||||
|
||||
|
||||
//! compares the first n characters of the strings
|
||||
bool equalsn(const T* str, int len)
|
||||
{
|
||||
int i;
|
||||
for(i=0; array[i] && str[i] && i < len; ++i)
|
||||
if (array[i] != str[i])
|
||||
return false;
|
||||
|
||||
// if one (or both) of the strings was smaller then they
|
||||
// are only equal if they have the same lenght
|
||||
return (i == len) || (array[i] == 0 && str[i] == 0);
|
||||
}
|
||||
|
||||
|
||||
//! Appends a character to this string
|
||||
/** \param character: Character to append. */
|
||||
void append(T character)
|
||||
{
|
||||
if (used + 1 > allocated)
|
||||
reallocate((s32)used + 1);
|
||||
|
||||
used += 1;
|
||||
|
||||
array[used-2] = character;
|
||||
array[used-1] = 0;
|
||||
}
|
||||
|
||||
//! Appends a string to this string
|
||||
/** \param other: String to append. */
|
||||
void append(const string<T>& other)
|
||||
{
|
||||
--used;
|
||||
|
||||
s32 len = other.size();
|
||||
|
||||
if (used + len + 1 > allocated)
|
||||
reallocate((s32)used + (s32)len + 1);
|
||||
|
||||
for (s32 l=0; l<len+1; ++l)
|
||||
array[l+used] = other[l];
|
||||
|
||||
used = used + len + 1;
|
||||
}
|
||||
|
||||
|
||||
//! Appends a string of the length l to this string.
|
||||
/** \param other: other String to append to this string.
|
||||
\param length: How much characters of the other string to add to this one. */
|
||||
void append(const string<T>& other, s32 length)
|
||||
{
|
||||
s32 len = other.size();
|
||||
|
||||
if (len < length)
|
||||
{
|
||||
append(other);
|
||||
return;
|
||||
}
|
||||
|
||||
len = length;
|
||||
--used;
|
||||
|
||||
if (used + len > allocated)
|
||||
reallocate((s32)used + (s32)len);
|
||||
|
||||
for (s32 l=0; l<len; ++l)
|
||||
array[l+used] = other[l];
|
||||
|
||||
used = used + len;
|
||||
}
|
||||
|
||||
|
||||
//! Reserves some memory.
|
||||
/** \param count: Amount of characters to reserve. */
|
||||
void reserve(s32 count)
|
||||
{
|
||||
if (count < allocated)
|
||||
return;
|
||||
|
||||
reallocate(count);
|
||||
}
|
||||
|
||||
|
||||
//! finds first occurrence of character in string
|
||||
/** \param c: Character to search for.
|
||||
\return Returns position where the character has been found,
|
||||
or -1 if not found. */
|
||||
s32 findFirst(T c) const
|
||||
{
|
||||
for (s32 i=0; i<used; ++i)
|
||||
if (array[i] == c)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//! finds first occurrence of a character of a list in string
|
||||
/** \param c: List of strings to find. For example if the method
|
||||
should find the first occurance of 'a' or 'b', this parameter should be "ab".
|
||||
\param count: Amount of characters in the list. Ususally,
|
||||
this should be strlen(ofParameter1)
|
||||
\return Returns position where one of the character has been found,
|
||||
or -1 if not found. */
|
||||
s32 findFirstChar(T* c, int count) const
|
||||
{
|
||||
for (s32 i=0; i<used; ++i)
|
||||
for (int j=0; j<count; ++j)
|
||||
if (array[i] == c[j])
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Finds first position of a character not in a given list.
|
||||
/** \param c: List of characters not to find. For example if the method
|
||||
should find the first occurance of a character not 'a' or 'b', this parameter should be "ab".
|
||||
\param count: Amount of characters in the list. Ususally,
|
||||
this should be strlen(ofParameter1)
|
||||
\return Returns position where the character has been found,
|
||||
or -1 if not found. */
|
||||
template <class B>
|
||||
s32 findFirstCharNotInList(B* c, int count) const
|
||||
{
|
||||
for (int i=0; i<used; ++i)
|
||||
{
|
||||
int j;
|
||||
for (j=0; j<count; ++j)
|
||||
if (array[i] == c[j])
|
||||
break;
|
||||
|
||||
if (j==count)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//! Finds last position of a character not in a given list.
|
||||
/** \param c: List of characters not to find. For example if the method
|
||||
should find the first occurance of a character not 'a' or 'b', this parameter should be "ab".
|
||||
\param count: Amount of characters in the list. Ususally,
|
||||
this should be strlen(ofParameter1)
|
||||
\return Returns position where the character has been found,
|
||||
or -1 if not found. */
|
||||
template <class B>
|
||||
s32 findLastCharNotInList(B* c, int count) const
|
||||
{
|
||||
for (int i=used-2; i>=0; --i)
|
||||
{
|
||||
int j;
|
||||
for (j=0; j<count; ++j)
|
||||
if (array[i] == c[j])
|
||||
break;
|
||||
|
||||
if (j==count)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//! finds next occurrence of character in string
|
||||
/** \param c: Character to search for.
|
||||
\param startPos: Position in string to start searching.
|
||||
\return Returns position where the character has been found,
|
||||
or -1 if not found. */
|
||||
s32 findNext(T c, s32 startPos) const
|
||||
{
|
||||
for (s32 i=startPos; i<used; ++i)
|
||||
if (array[i] == c)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! finds last occurrence of character in string
|
||||
//! \param c: Character to search for.
|
||||
//! \return Returns position where the character has been found,
|
||||
//! or -1 if not found.
|
||||
s32 findLast(T c) const
|
||||
{
|
||||
for (s32 i=used-1; i>=0; --i)
|
||||
if (array[i] == c)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Returns a substring
|
||||
//! \param begin: Start of substring.
|
||||
//! \param length: Length of substring.
|
||||
string<T> subString(s32 begin, s32 length)
|
||||
{
|
||||
if (length <= 0)
|
||||
return string<T>("");
|
||||
|
||||
string<T> o;
|
||||
o.reserve(length+1);
|
||||
|
||||
for (s32 i=0; i<length; ++i)
|
||||
o.array[i] = array[i+begin];
|
||||
|
||||
o.array[length] = 0;
|
||||
o.used = o.allocated;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
void operator += (T c)
|
||||
{
|
||||
append(c);
|
||||
}
|
||||
|
||||
void operator += (const string<T>& other)
|
||||
{
|
||||
append(other);
|
||||
}
|
||||
|
||||
void operator += (int i)
|
||||
{
|
||||
append(string<T>(i));
|
||||
}
|
||||
|
||||
//! replaces all characters of a special type with another one
|
||||
void replace(T toReplace, T replaceWith)
|
||||
{
|
||||
for (s32 i=0; i<used; ++i)
|
||||
if (array[i] == toReplace)
|
||||
array[i] = replaceWith;
|
||||
}
|
||||
|
||||
//! trims the string.
|
||||
/** Removes whitespace from begin and end of the string. */
|
||||
void trim()
|
||||
{
|
||||
const char whitespace[] = " \t\n";
|
||||
const int whitespacecount = 3;
|
||||
|
||||
// find start and end of real string without whitespace
|
||||
int begin = findFirstCharNotInList(whitespace, whitespacecount);
|
||||
if (begin == -1)
|
||||
return;
|
||||
|
||||
int end = findLastCharNotInList(whitespace, whitespacecount);
|
||||
if (end == -1)
|
||||
return;
|
||||
|
||||
*this = subString(begin, (end +1) - begin);
|
||||
}
|
||||
|
||||
|
||||
//! Erases a character from the string. May be slow, because all elements
|
||||
//! following after the erased element have to be copied.
|
||||
//! \param index: Index of element to be erased.
|
||||
void erase(int index)
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(index>=used || index<0) // access violation
|
||||
|
||||
for (int i=index+1; i<used; ++i)
|
||||
array[i-1] = array[i];
|
||||
|
||||
--used;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//! Returns a character converted to lower case
|
||||
T toLower(const T& t) const
|
||||
{
|
||||
if (t>=(T)'A' && t<=(T)'Z')
|
||||
return t + ((T)'a' - (T)'A');
|
||||
else
|
||||
return t;
|
||||
}
|
||||
|
||||
//! Reallocate the array, make it bigger or smaler
|
||||
void reallocate(s32 new_size)
|
||||
{
|
||||
T* old_array = array;
|
||||
|
||||
array = new T[new_size];
|
||||
allocated = new_size;
|
||||
|
||||
s32 amount = used < new_size ? used : new_size;
|
||||
for (s32 i=0; i<amount; ++i)
|
||||
array[i] = old_array[i];
|
||||
|
||||
if (allocated < used)
|
||||
used = allocated;
|
||||
|
||||
delete [] old_array;
|
||||
}
|
||||
|
||||
|
||||
//--- member variables
|
||||
|
||||
T* array;
|
||||
s32 allocated;
|
||||
s32 used;
|
||||
};
|
||||
|
||||
|
||||
//! Typedef for character strings
|
||||
typedef string<irr::c8> stringc;
|
||||
|
||||
//! Typedef for wide character strings
|
||||
typedef string<wchar_t> stringw;
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_TYPES_H_INCLUDED__
|
||||
#define __IRR_TYPES_H_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
//! 8 bit unsigned variable.
|
||||
/** This is a typedef for unsigned char, it ensures portability of the engine. */
|
||||
typedef unsigned char u8;
|
||||
|
||||
//! 8 bit signed variable.
|
||||
/** This is a typedef for signed char, it ensures portability of the engine. */
|
||||
typedef signed char s8;
|
||||
|
||||
//! 8 bit character variable.
|
||||
/** This is a typedef for char, it ensures portability of the engine. */
|
||||
typedef char c8;
|
||||
|
||||
|
||||
|
||||
//! 16 bit unsigned variable.
|
||||
/** This is a typedef for unsigned short, it ensures portability of the engine. */
|
||||
typedef unsigned short u16;
|
||||
|
||||
//! 16 bit signed variable.
|
||||
/** This is a typedef for signed short, it ensures portability of the engine. */
|
||||
typedef signed short s16;
|
||||
|
||||
|
||||
|
||||
//! 32 bit unsigned variable.
|
||||
/** This is a typedef for unsigned int, it ensures portability of the engine. */
|
||||
typedef unsigned int u32;
|
||||
|
||||
//! 32 bit signed variable.
|
||||
/** This is a typedef for signed int, it ensures portability of the engine. */
|
||||
typedef signed int s32;
|
||||
|
||||
|
||||
|
||||
// 64 bit signed variable.
|
||||
// This is a typedef for __int64, it ensures portability of the engine.
|
||||
// This type is currently not used by the engine and not supported by compilers
|
||||
// other than Microsoft Compilers, so it is outcommented.
|
||||
//typedef __int64 s64;
|
||||
|
||||
|
||||
|
||||
//! 32 bit floating point variable.
|
||||
/** This is a typedef for float, it ensures portability of the engine. */
|
||||
typedef float f32;
|
||||
|
||||
//! 64 bit floating point variable.
|
||||
/** This is a typedef for double, it ensures portability of the engine. */
|
||||
typedef double f64;
|
||||
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
||||
// define the wchar_t type if not already built in.
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _WCHAR_T_DEFINED
|
||||
//! A 16 bit wide character type.
|
||||
/**
|
||||
Defines the wchar_t-type.
|
||||
In VS6, its not possible to tell
|
||||
the standard compiler to treat wchar_t as a built-in type, and
|
||||
sometimes we just don't want to include the huge stdlib.h or wchar.h,
|
||||
so we'll use this.
|
||||
*/
|
||||
typedef unsigned short wchar_t;
|
||||
#define _WCHAR_T_DEFINED
|
||||
#endif // wchar is not defined
|
||||
#endif // microsoft compiler
|
||||
|
||||
//! define a break macro for debugging only in Win32 mode.
|
||||
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
|
||||
#else
|
||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
||||
#endif
|
||||
|
||||
//! Defines a small statement to work around a microsoft compiler bug.
|
||||
/** The microsft compiler 7.0 - 7.1 has a bug:
|
||||
When you call unmanaged code that returns a bool type value of false from managed code,
|
||||
the return value may appear as true. See
|
||||
http://support.microsoft.com/default.aspx?kbid=823071 for details.
|
||||
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
|
||||
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
|
||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100
|
||||
#else
|
||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
|
||||
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
|
||||
|
||||
#endif // __IRR_TYPES_H_INCLUDED__
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
||||
|
||||
// Need to include Assimp, too. We're using Assimp's version of fast_atof
|
||||
// so we need stdint.h
|
||||
|
||||
#include "./../../include/aiTypes.h"
|
||||
|
||||
#include "irrXML.h"
|
||||
#include "irrString.h"
|
||||
#include "irrArray.h"
|
||||
#include "./../fast_atof.h"
|
||||
#include "CXMLReaderImpl.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
//! Implementation of the file read callback for ordinary files
|
||||
class CFileReadCallBack : public IFileReadCallBack
|
||||
{
|
||||
public:
|
||||
|
||||
//! construct from filename
|
||||
CFileReadCallBack(const char* filename)
|
||||
: File(0), Size(0), Close(true)
|
||||
{
|
||||
// open file
|
||||
File = fopen(filename, "rb");
|
||||
|
||||
if (File)
|
||||
getFileSize();
|
||||
}
|
||||
|
||||
//! construct from FILE pointer
|
||||
CFileReadCallBack(FILE* file)
|
||||
: File(file), Size(0), Close(false)
|
||||
{
|
||||
if (File)
|
||||
getFileSize();
|
||||
}
|
||||
|
||||
//! destructor
|
||||
virtual ~CFileReadCallBack()
|
||||
{
|
||||
if (Close && File)
|
||||
fclose(File);
|
||||
}
|
||||
|
||||
//! Reads an amount of bytes from the file.
|
||||
virtual int read(void* buffer, int sizeToRead)
|
||||
{
|
||||
if (!File)
|
||||
return 0;
|
||||
|
||||
return (int)fread(buffer, 1, sizeToRead, File);
|
||||
}
|
||||
|
||||
//! Returns size of file in bytes
|
||||
virtual int getSize()
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! retrieves the file size of the open file
|
||||
void getFileSize()
|
||||
{
|
||||
fseek(File, 0, SEEK_END);
|
||||
Size = ftell(File);
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
FILE* File;
|
||||
int Size;
|
||||
bool Close;
|
||||
|
||||
}; // end class CFileReadCallBack
|
||||
|
||||
|
||||
|
||||
// FACTORY FUNCTIONS:
|
||||
|
||||
|
||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||
IrrXMLReader* createIrrXMLReader(const char* filename)
|
||||
{
|
||||
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(filename));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||
IrrXMLReader* createIrrXMLReader(FILE* file)
|
||||
{
|
||||
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(file));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback)
|
||||
{
|
||||
return new CXMLReaderImpl<char, IXMLBase>(callback, false);
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-16 xml parser.
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename)
|
||||
{
|
||||
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(filename));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-16 xml parser.
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file)
|
||||
{
|
||||
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(file));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-16 xml parser.
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback)
|
||||
{
|
||||
return new CXMLReaderImpl<char16, IXMLBase>(callback, false);
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-32 xml parser.
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename)
|
||||
{
|
||||
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(filename));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-32 xml parser.
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file)
|
||||
{
|
||||
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(file));
|
||||
}
|
||||
|
||||
|
||||
//! Creates an instance of an UTF-32 xml parser.
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback)
|
||||
{
|
||||
return new CXMLReaderImpl<char32, IXMLBase>(callback, false);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace io
|
||||
} // end namespace irr
|
|
@ -0,0 +1,540 @@
|
|||
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
||||
|
||||
#ifndef __IRR_XML_H_INCLUDED__
|
||||
#define __IRR_XML_H_INCLUDED__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/** \mainpage irrXML 1.2 API documentation
|
||||
<div align="center"><img src="logobig.png" ></div>
|
||||
|
||||
\section intro Introduction
|
||||
|
||||
Welcome to the irrXML API documentation.
|
||||
Here you'll find any information you'll need to develop applications with
|
||||
irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample,
|
||||
at the homepage of irrXML at <A HREF="http://xml.irrlicht3d.org" >xml.irrlicht3d.org</A>
|
||||
or into the SDK in the directory \example.
|
||||
|
||||
irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and
|
||||
this documentation is an important part of it. If you have any questions or
|
||||
suggestions, just send a email to the author of the engine, Nikolaus Gebhardt
|
||||
(niko (at) irrlicht3d.org). For more informations about this parser, see \ref history.
|
||||
|
||||
\section features Features
|
||||
|
||||
irrXML provides forward-only, read-only
|
||||
access to a stream of non validated XML data. It was fully implemented by
|
||||
Nikolaus Gebhardt. Its current features are:
|
||||
|
||||
- It it fast as lighting and has very low memory usage. It was
|
||||
developed with the intention of being used in 3D games, as it already has been.
|
||||
- irrXML is very small: It only consists of 60 KB of code and can be added easily
|
||||
to your existing project.
|
||||
- Of course, it is platform independent and works with lots of compilers.
|
||||
- It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in
|
||||
little and big endian format.
|
||||
- Independent of the input file format, the parser can return all strings in ASCII, UTF-8,
|
||||
UTF-16 and UTF-32 format.
|
||||
- With its optional file access abstraction it has the advantage that it can read not
|
||||
only from files but from any type of data (memory, network, ...). For example when
|
||||
used with the Irrlicht Engine, it directly reads from compressed .zip files.
|
||||
- Just like the Irrlicht Engine for which it was originally created, it is extremely easy
|
||||
to use.
|
||||
- It has no external dependencies, it does not even need the STL.
|
||||
|
||||
Although irrXML has some strenghts, it currently also has the following limitations:
|
||||
|
||||
- The input xml file is not validated and assumed to be correct.
|
||||
|
||||
\section irrxmlexample Example
|
||||
|
||||
The following code demonstrates the basic usage of irrXML. A simple xml
|
||||
file like this is parsed:
|
||||
\code
|
||||
<?xml version="1.0"?>
|
||||
<config>
|
||||
<!-- This is a config file for the mesh viewer -->
|
||||
<model file="dwarf.dea" />
|
||||
<messageText caption="Irrlicht Engine Mesh Viewer">
|
||||
Welcome to the Mesh Viewer of the "Irrlicht Engine".
|
||||
</messageText>
|
||||
</config>
|
||||
\endcode
|
||||
|
||||
The code for parsing this file would look like this:
|
||||
\code
|
||||
#include <irrXML.h>
|
||||
using namespace irr; // irrXML is located in the namespace irr::io
|
||||
using namespace io;
|
||||
|
||||
#include <string> // we use STL strings to store data in this example
|
||||
|
||||
void main()
|
||||
{
|
||||
// create the reader using one of the factory functions
|
||||
|
||||
IrrXMLReader* xml = createIrrXMLReader("config.xml");
|
||||
|
||||
// strings for storing the data we want to get out of the file
|
||||
std::string modelFile;
|
||||
std::string messageText;
|
||||
std::string caption;
|
||||
|
||||
// parse the file until end reached
|
||||
|
||||
while(xml && xml->read())
|
||||
{
|
||||
switch(xml->getNodeType())
|
||||
{
|
||||
case EXN_TEXT:
|
||||
// in this xml file, the only text which occurs is the messageText
|
||||
messageText = xml->getNodeData();
|
||||
break;
|
||||
case EXN_ELEMENT:
|
||||
{
|
||||
if (!strcmp("model", xml->getNodeName()))
|
||||
modelFile = xml->getAttributeValue("file");
|
||||
else
|
||||
if (!strcmp("messageText", xml->getNodeName()))
|
||||
caption = xml->getAttributeValue("caption");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// delete the xml parser after usage
|
||||
delete xml;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\section howto How to use
|
||||
|
||||
Simply add the source files in the /src directory of irrXML to your project. Done.
|
||||
|
||||
\section license License
|
||||
|
||||
The irrXML license is based on the zlib license. Basicly, this means you can do with
|
||||
irrXML whatever you want:
|
||||
|
||||
Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
\section history History
|
||||
|
||||
As lots of references in this documentation and the source show, this xml
|
||||
parser has originally been a part of the
|
||||
<A HREF="http://irrlicht.sourceforge.net" >Irrlicht Engine</A>. But because
|
||||
the parser has become very useful with the latest release, people asked for a
|
||||
separate version of it, to be able to use it in non Irrlicht projects. With
|
||||
irrXML 1.0, this has now been done.
|
||||
*/
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
//! Enumeration of all supported source text file formats
|
||||
enum ETEXT_FORMAT
|
||||
{
|
||||
//! ASCII, file without byte order mark, or not a text file
|
||||
ETF_ASCII,
|
||||
|
||||
//! UTF-8 format
|
||||
ETF_UTF8,
|
||||
|
||||
//! UTF-16 format, big endian
|
||||
ETF_UTF16_BE,
|
||||
|
||||
//! UTF-16 format, little endian
|
||||
ETF_UTF16_LE,
|
||||
|
||||
//! UTF-32 format, big endian
|
||||
ETF_UTF32_BE,
|
||||
|
||||
//! UTF-32 format, little endian
|
||||
ETF_UTF32_LE,
|
||||
};
|
||||
|
||||
|
||||
//! Enumeration for all xml nodes which are parsed by IrrXMLReader
|
||||
enum EXML_NODE
|
||||
{
|
||||
//! No xml node. This is usually the node if you did not read anything yet.
|
||||
EXN_NONE,
|
||||
|
||||
//! A xml element, like <foo>
|
||||
EXN_ELEMENT,
|
||||
|
||||
//! End of an xml element, like </foo>
|
||||
EXN_ELEMENT_END,
|
||||
|
||||
//! Text within a xml element: <foo> this is the text. </foo>
|
||||
EXN_TEXT,
|
||||
|
||||
//! An xml comment like <!-- I am a comment --> or a DTD definition.
|
||||
EXN_COMMENT,
|
||||
|
||||
//! An xml cdata section like <![CDATA[ this is some CDATA ]]>
|
||||
EXN_CDATA,
|
||||
|
||||
//! Unknown element.
|
||||
EXN_UNKNOWN
|
||||
};
|
||||
|
||||
//! Callback class for file read abstraction.
|
||||
/** With this, it is possible to make the xml parser read in other things
|
||||
than just files. The Irrlicht engine is using this for example to
|
||||
read xml from compressed .zip files. To make the parser read in
|
||||
any other data, derive a class from this interface, implement the
|
||||
two methods to read your data and give a pointer to an instance of
|
||||
your implementation when calling createIrrXMLReader(),
|
||||
createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
|
||||
class IFileReadCallBack
|
||||
{
|
||||
public:
|
||||
|
||||
//! virtual destructor
|
||||
virtual ~IFileReadCallBack() {};
|
||||
|
||||
//! Reads an amount of bytes from the file.
|
||||
/** \param buffer: Pointer to buffer where to read bytes will be written to.
|
||||
\param sizeToRead: Amount of bytes to read from the file.
|
||||
\return Returns how much bytes were read. */
|
||||
virtual int read(void* buffer, int sizeToRead) = 0;
|
||||
|
||||
//! Returns size of file in bytes
|
||||
virtual int getSize() = 0;
|
||||
};
|
||||
|
||||
//! Empty class to be used as parent class for IrrXMLReader.
|
||||
/** If you need another class as base class for the xml reader, you can do this by creating
|
||||
the reader using for example new CXMLReaderImpl<char, YourBaseClass>(yourcallback);
|
||||
The Irrlicht Engine for example needs IUnknown as base class for every object to
|
||||
let it automaticly reference countend, hence it replaces IXMLBase with IUnknown.
|
||||
See irrXML.cpp on how this can be done in detail. */
|
||||
class IXMLBase
|
||||
{
|
||||
};
|
||||
|
||||
//! Interface providing easy read access to a XML file.
|
||||
/** You can create an instance of this reader using one of the factory functions
|
||||
createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32().
|
||||
If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader()
|
||||
instead.
|
||||
For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features.
|
||||
|
||||
The typical usage of this parser looks like this:
|
||||
\code
|
||||
#include <irrXML.h>
|
||||
using namespace irr; // irrXML is located in the namespace irr::io
|
||||
using namespace io;
|
||||
|
||||
void main()
|
||||
{
|
||||
// create the reader using one of the factory functions
|
||||
IrrXMLReader* xml = createIrrXMLReader("config.xml");
|
||||
|
||||
if (xml == 0)
|
||||
return; // file could not be opened
|
||||
|
||||
// parse the file until end reached
|
||||
while(xml->read())
|
||||
{
|
||||
// based on xml->getNodeType(), do something.
|
||||
}
|
||||
|
||||
// delete the xml parser after usage
|
||||
delete xml;
|
||||
}
|
||||
\endcode
|
||||
See \ref irrxmlexample for a more detailed example.
|
||||
*/
|
||||
template<class char_type, class super_class>
|
||||
class IIrrXMLReader : public super_class
|
||||
{
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
virtual ~IIrrXMLReader() {};
|
||||
|
||||
//! Reads forward to the next xml node.
|
||||
/** \return Returns false, if there was no further node. */
|
||||
virtual bool read() = 0;
|
||||
|
||||
//! Returns the type of the current XML node.
|
||||
virtual EXML_NODE getNodeType() const = 0;
|
||||
|
||||
//! Returns attribute count of the current XML node.
|
||||
/** This is usually
|
||||
non null if the current node is EXN_ELEMENT, and the element has attributes.
|
||||
\return Returns amount of attributes of this xml node. */
|
||||
virtual int getAttributeCount() const = 0;
|
||||
|
||||
//! Returns name of an attribute.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Name of the attribute, 0 if an attribute with this index does not exist. */
|
||||
virtual const char_type* getAttributeName(int idx) const = 0;
|
||||
|
||||
//! Returns the value of an attribute.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Value of the attribute, 0 if an attribute with this index does not exist. */
|
||||
virtual const char_type* getAttributeValue(int idx) const = 0;
|
||||
|
||||
//! Returns the value of an attribute.
|
||||
/** \param name: Name of the attribute.
|
||||
\return Value of the attribute, 0 if an attribute with this name does not exist. */
|
||||
virtual const char_type* getAttributeValue(const char_type* name) const = 0;
|
||||
|
||||
//! Returns the value of an attribute in a safe way.
|
||||
/** Like getAttributeValue(), but does not
|
||||
return 0 if the attribute does not exist. An empty string ("") is returned then.
|
||||
\param name: Name of the attribute.
|
||||
\return Value of the attribute, and "" if an attribute with this name does not exist */
|
||||
virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
/** \param name Name of the attribute.
|
||||
\return Value of the attribute as integer, and 0 if an attribute with this name does not exist or
|
||||
the value could not be interpreted as integer. */
|
||||
virtual int getAttributeValueAsInt(const char_type* name) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as integer.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Value of the attribute as integer, and 0 if an attribute with this index does not exist or
|
||||
the value could not be interpreted as integer. */
|
||||
virtual int getAttributeValueAsInt(int idx) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
/** \param name: Name of the attribute.
|
||||
\return Value of the attribute as float, and 0 if an attribute with this name does not exist or
|
||||
the value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\return Value of the attribute as float, and 0 if an attribute with this index does not exist or
|
||||
the value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(int idx) const = 0;
|
||||
|
||||
//! Returns the name of the current node.
|
||||
/** Only non null, if the node type is EXN_ELEMENT.
|
||||
\return Name of the current node or 0 if the node has no name. */
|
||||
virtual const char_type* getNodeName() const = 0;
|
||||
|
||||
//! Returns data of the current node.
|
||||
/** Only non null if the node has some
|
||||
data and it is of type EXN_TEXT or EXN_UNKNOWN. */
|
||||
virtual const char_type* getNodeData() const = 0;
|
||||
|
||||
//! Returns if an element is an empty element, like <foo />
|
||||
virtual bool isEmptyElement() const = 0;
|
||||
|
||||
//! Returns format of the source xml file.
|
||||
/** It is not necessary to use
|
||||
this method because the parser will convert the input file format
|
||||
to the format wanted by the user when creating the parser. This
|
||||
method is useful to get/display additional informations. */
|
||||
virtual ETEXT_FORMAT getSourceFormat() const = 0;
|
||||
|
||||
//! Returns format of the strings returned by the parser.
|
||||
/** This will be UTF8 for example when you created a parser with
|
||||
IrrXMLReaderUTF8() and UTF32 when it has been created using
|
||||
IrrXMLReaderUTF32. It should not be necessary to call this
|
||||
method and only exists for informational purposes. */
|
||||
virtual ETEXT_FORMAT getParserFormat() const = 0;
|
||||
};
|
||||
|
||||
|
||||
//! defines the utf-16 type.
|
||||
/** Not using wchar_t for this because
|
||||
wchar_t has 16 bit on windows and 32 bit on other operating systems. */
|
||||
typedef unsigned short char16;
|
||||
|
||||
//! defines the utf-32 type.
|
||||
/** Not using wchar_t for this because
|
||||
wchar_t has 16 bit on windows and 32 bit on other operating systems. */
|
||||
typedef unsigned long char32;
|
||||
|
||||
//! A UTF-8 or ASCII character xml parser.
|
||||
/** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser.
|
||||
The file to read can be in any format, it will be converted to UTF-8 if it is not
|
||||
in this format.
|
||||
Create an instance of this with createIrrXMLReader();
|
||||
See IIrrXMLReader for description on how to use it. */
|
||||
typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader;
|
||||
|
||||
//! A UTF-16 xml parser.
|
||||
/** This means that all character data will be returned in UTF-16 by this parser.
|
||||
The file to read can be in any format, it will be converted to UTF-16 if it is not
|
||||
in this format.
|
||||
Create an instance of this with createIrrXMLReaderUTF16();
|
||||
See IIrrXMLReader for description on how to use it. */
|
||||
typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16;
|
||||
|
||||
//! A UTF-32 xml parser.
|
||||
/** This means that all character data will be returned in UTF-32 by this parser.
|
||||
The file to read can be in any format, it will be converted to UTF-32 if it is not
|
||||
in this format.
|
||||
Create an instance of this with createIrrXMLReaderUTF32();
|
||||
See IIrrXMLReader for description on how to use it. */
|
||||
typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
|
||||
|
||||
|
||||
//! 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.
|
||||
The file to read can be in any format, it will be converted to UTF-8 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReaderUTF8() instead.
|
||||
\param filename: Name of file to be opened.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReader* createIrrXMLReader(const char* filename);
|
||||
|
||||
//! 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. The file to read can
|
||||
be in any format, it will be converted to UTF-8 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReaderUTF8() instead.
|
||||
\param file: Pointer to opened file, must have been opened in binary mode, e.g.
|
||||
using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReader* createIrrXMLReader(FILE* file);
|
||||
|
||||
//! 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. The file to read can
|
||||
be in any format, it will be converted to UTF-8 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReaderUTF8() instead.
|
||||
\param callback: Callback for file read abstraction. Implement your own
|
||||
callback to make the xml parser read in other things than just files. See
|
||||
IFileReadCallBack for more information about this.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
|
||||
|
||||
//! Creates an instance of an UFT-16 xml parser.
|
||||
/** This means that
|
||||
all character data will be returned in UTF-16. The file to read can
|
||||
be in any format, it will be converted to UTF-16 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param filename: Name of file to be opened.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
|
||||
|
||||
//! Creates an instance of an UFT-16 xml parser.
|
||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||
be in any format, it will be converted to UTF-16 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param file: Pointer to opened file, must have been opened in binary mode, e.g.
|
||||
using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
|
||||
|
||||
//! Creates an instance of an UFT-16 xml parser.
|
||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||
be in any format, it will be converted to UTF-16 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param callback: Callback for file read abstraction. Implement your own
|
||||
callback to make the xml parser read in other things than just files. See
|
||||
IFileReadCallBack for more information about this.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
|
||||
|
||||
|
||||
//! Creates an instance of an UFT-32 xml parser.
|
||||
/** This means that all character data will be returned in UTF-32. The file to read can
|
||||
be in any format, it will be converted to UTF-32 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param filename: Name of file to be opened.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
|
||||
|
||||
//! Creates an instance of an UFT-32 xml parser.
|
||||
/** This means that all character data will be returned in UTF-32. The file to read can
|
||||
be in any format, it will be converted to UTF-32 if it is not in this format.
|
||||
if you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param file: Pointer to opened file, must have been opened in binary mode, e.g.
|
||||
using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
|
||||
|
||||
//! Creates an instance of an UFT-32 xml parser.
|
||||
/** This means that
|
||||
all character data will be returned in UTF-32. The file to read can
|
||||
be in any format, it will be converted to UTF-32 if it is not in this format.
|
||||
If you are using the Irrlicht Engine, it is better not to use this function but
|
||||
IFileSystem::createXMLReader() instead.
|
||||
\param callback: Callback for file read abstraction. Implement your own
|
||||
callback to make the xml parser read in other things than just files. See
|
||||
IFileReadCallBack for more information about this.
|
||||
\return Returns a pointer to the created xml parser. This pointer should be
|
||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||
and the file could not be opened. */
|
||||
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
|
||||
|
||||
|
||||
/*! \file irrxml.h
|
||||
\brief Header file of the irrXML, the Irrlicht XML parser.
|
||||
|
||||
This file includes everything needed for using irrXML,
|
||||
the XML parser of the Irrlicht Engine. To use irrXML,
|
||||
you only need to include this file in your project:
|
||||
|
||||
\code
|
||||
#include <irrXML.h>
|
||||
\endcode
|
||||
|
||||
It is also common to use the two namespaces in which irrXML is included,
|
||||
directly after #including irrXML.h:
|
||||
|
||||
\code
|
||||
#include <irrXML.h>
|
||||
using namespace irr;
|
||||
using namespace io;
|
||||
\endcode
|
||||
*/
|
||||
|
||||
} // end namespace io
|
||||
} // end namespace irr
|
||||
|
||||
#endif // __IRR_XML_H_INCLUDED__
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
#ifndef AI_IRRXML_WRAPPER_H_INCLUDED
|
||||
#define AI_IRRXML_WRAPPER_H_INCLUDED
|
||||
|
||||
#include "irrXML.h"
|
||||
#include "./../../include/IOStream.h"
|
||||
|
||||
namespace Assimp {
|
||||
using namespace irr;
|
||||
using namespace irr::io;
|
||||
|
||||
class CIrrXML_IOStreamReader
|
||||
{
|
||||
public:
|
||||
|
||||
CIrrXML_IOStreamReader(IOStream* _stream)
|
||||
: stream (_stream)
|
||||
{}
|
||||
|
||||
//! virtual destructor
|
||||
virtual ~CIrrXML_IOStreamReader() {};
|
||||
|
||||
//! Reads an amount of bytes from the file.
|
||||
/** \param buffer: Pointer to buffer where to read bytes will be written to.
|
||||
\param sizeToRead: Amount of bytes to read from the file.
|
||||
\return Returns how much bytes were read. */
|
||||
virtual int read(void* buffer, int sizeToRead)
|
||||
{
|
||||
return (int)stream->Read(buffer,1,sizeToRead);
|
||||
}
|
||||
|
||||
//! Returns size of file in bytes
|
||||
virtual int getSize()
|
||||
{
|
||||
return (int)stream->FileSize();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
IOStream* stream;
|
||||
};
|
||||
|
||||
|
||||
} // ! Assimp
|
||||
|
||||
#endif
|
|
@ -67,7 +67,9 @@ SOURCES = AssimpPCH.cpp \
|
|||
SceneCombiner.cpp \
|
||||
SkeletonMeshBuilder.cpp \
|
||||
FindDegenerates.cpp \
|
||||
XFileParser.cpp
|
||||
XFileParser.cpp \
|
||||
./irrXML/irrXML.cpp \
|
||||
IRRMeshLoader.cpp
|
||||
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
|
|
|
@ -67,7 +67,9 @@ SOURCES = AssimpPCH.cpp \
|
|||
SceneCombiner.cpp \
|
||||
FindDegenerates.cpp \
|
||||
SkeletonMeshBuilder.cpp \
|
||||
BVHLoader.cpp
|
||||
BVHLoader.cpp \
|
||||
./irrXML/irrXML.cpp \
|
||||
IRRMeshLoader.cpp
|
||||
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
#****************************************************************************
|
||||
#
|
||||
# Makefile for TinyXml test.
|
||||
# Lee Thomason
|
||||
# www.grinninglizard.com
|
||||
#
|
||||
# This is a GNU make (gmake) makefile
|
||||
#****************************************************************************
|
||||
|
||||
# DEBUG can be set to YES to include debugging info, or NO otherwise
|
||||
DEBUG := YES
|
||||
|
||||
# PROFILE can be set to YES to include profiling info, or NO otherwise
|
||||
PROFILE := NO
|
||||
|
||||
# TINYXML_USE_STL can be used to turn on STL support. NO, then STL
|
||||
# will not be used. YES will include the STL files.
|
||||
TINYXML_USE_STL := YES
|
||||
|
||||
#****************************************************************************
|
||||
|
||||
CC := gcc
|
||||
CXX := g++
|
||||
LD := g++
|
||||
AR := ar rc
|
||||
RANLIB := ranlib
|
||||
|
||||
DEBUG_CFLAGS := -Wall -Wno-format -g -DDEBUG
|
||||
RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3
|
||||
|
||||
LIBS :=
|
||||
|
||||
DEBUG_CXXFLAGS := ${DEBUG_CFLAGS}
|
||||
RELEASE_CXXFLAGS := ${RELEASE_CFLAGS}
|
||||
|
||||
DEBUG_LDFLAGS := -g
|
||||
RELEASE_LDFLAGS :=
|
||||
|
||||
ifeq (YES, ${DEBUG})
|
||||
CFLAGS := ${DEBUG_CFLAGS}
|
||||
CXXFLAGS := ${DEBUG_CXXFLAGS}
|
||||
LDFLAGS := ${DEBUG_LDFLAGS}
|
||||
else
|
||||
CFLAGS := ${RELEASE_CFLAGS}
|
||||
CXXFLAGS := ${RELEASE_CXXFLAGS}
|
||||
LDFLAGS := ${RELEASE_LDFLAGS}
|
||||
endif
|
||||
|
||||
ifeq (YES, ${PROFILE})
|
||||
CFLAGS := ${CFLAGS} -pg -O3
|
||||
CXXFLAGS := ${CXXFLAGS} -pg -O3
|
||||
LDFLAGS := ${LDFLAGS} -pg
|
||||
endif
|
||||
|
||||
#****************************************************************************
|
||||
# Preprocessor directives
|
||||
#****************************************************************************
|
||||
|
||||
ifeq (YES, ${TINYXML_USE_STL})
|
||||
DEFS := -DTIXML_USE_STL
|
||||
else
|
||||
DEFS :=
|
||||
endif
|
||||
|
||||
#****************************************************************************
|
||||
# Include paths
|
||||
#****************************************************************************
|
||||
|
||||
#INCS := -I/usr/include/g++-2 -I/usr/local/include
|
||||
INCS :=
|
||||
|
||||
|
||||
#****************************************************************************
|
||||
# Makefile code common to all platforms
|
||||
#****************************************************************************
|
||||
|
||||
CFLAGS := ${CFLAGS} ${DEFS}
|
||||
CXXFLAGS := ${CXXFLAGS} ${DEFS}
|
||||
|
||||
#****************************************************************************
|
||||
# Targets of the build
|
||||
#****************************************************************************
|
||||
|
||||
OUTPUT := xmltest
|
||||
|
||||
all: ${OUTPUT}
|
||||
|
||||
|
||||
#****************************************************************************
|
||||
# Source files
|
||||
#****************************************************************************
|
||||
|
||||
SRCS := tinyxml.cpp tinyxmlparser.cpp xmltest.cpp tinyxmlerror.cpp tinystr.cpp
|
||||
|
||||
# Add on the sources for libraries
|
||||
SRCS := ${SRCS}
|
||||
|
||||
OBJS := $(addsuffix .o,$(basename ${SRCS}))
|
||||
|
||||
#****************************************************************************
|
||||
# Output
|
||||
#****************************************************************************
|
||||
|
||||
${OUTPUT}: ${OBJS}
|
||||
${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}
|
||||
|
||||
#****************************************************************************
|
||||
# common rules
|
||||
#****************************************************************************
|
||||
|
||||
# Rules for compiling source files to object files
|
||||
%.o : %.cpp
|
||||
${CXX} -c ${CXXFLAGS} ${INCS} $< -o $@
|
||||
|
||||
%.o : %.c
|
||||
${CC} -c ${CFLAGS} ${INCS} $< -o $@
|
||||
|
||||
dist:
|
||||
bash makedistlinux
|
||||
|
||||
clean:
|
||||
-rm -f core ${OBJS} ${OUTPUT}
|
||||
|
||||
depend:
|
||||
#makedepend ${INCS} ${SRCS}
|
||||
|
||||
tinyxml.o: tinyxml.h tinystr.h
|
||||
tinyxmlparser.o: tinyxml.h tinystr.h
|
||||
xmltest.o: tinyxml.h tinystr.h
|
||||
tinyxmlerror.o: tinyxml.h tinystr.h
|
|
@ -1,269 +0,0 @@
|
|||
Changes in version 1.0.1:
|
||||
- Fixed comment tags which were outputing as '<?--' instead of
|
||||
the correct '<!--'.
|
||||
- Implemented the Next and Prev methods of the TiXmlAttribute class.
|
||||
- Renamed 'LastAttribtute' to 'LastAttribute'
|
||||
- Fixed bad pointer to 'isspace' that could occur while parsing text.
|
||||
- Errors finding beginning and end of tags no longer throw it into an
|
||||
infinite loop. (Hopefully.)
|
||||
|
||||
Changes in version 1.0.2
|
||||
- Minor documentation fixes.
|
||||
|
||||
Changes in version 1.0.3
|
||||
- After nodes are added to a document, they return a pointer
|
||||
to the new node instead of a bool for success.
|
||||
- Elements can be constructed with a value, which is the
|
||||
element name. Every element must have a value or it will be
|
||||
invalid, but the code changes to enforce this are not fully
|
||||
in place.
|
||||
|
||||
Changes in version 1.1.0
|
||||
- Added the TiXmlAttributeSet class to pull the attributes into
|
||||
a seperate container.
|
||||
- Moved the doubly liked list out of XmlBase. Now XmlBase only
|
||||
requires the Print() function and defines some utility functions.
|
||||
- Moved errors into a seperate file. (With the idea of internationalization
|
||||
to the other latin-1 languages.)
|
||||
- Added the "NodeType"
|
||||
- Fixed white space parsing in text to conform with the standard.
|
||||
Basically, all white space becomes just one space.
|
||||
- Added the TiXmlDeclaration class to read xml declarations.
|
||||
|
||||
Changes in version 1.2.0
|
||||
- Removed the factory. The factory was not really in the spirit
|
||||
of small and simple, confused the code, and was of limited value.
|
||||
- Added FirstChildElement and NextSiblingElement, because they
|
||||
are such common functions.
|
||||
- Re-wrote the example to test and demonstrate more functionality.
|
||||
|
||||
Changes in version 1.2.1
|
||||
- Fixed a bug where comments couldn't be inside elements.
|
||||
- Loading now clears out existing XML rather than appending.
|
||||
- Added the "Clear" method on a node to delete all its children.
|
||||
|
||||
Changes in version 1.2.2
|
||||
- Fixed TiXmlAttribute::Previous actually returning "next." Thanks
|
||||
to Rickard Troedsson for the bug fix.
|
||||
|
||||
Changes in version 1.2.3
|
||||
- Added the TIXML prefix to the error strings to resolve conflicts
|
||||
with #defines in OS headers. Thanks to Steve Lhomme.
|
||||
- Fixed a delete buf that should be a delete [] buf.
|
||||
Thanks to Ephi Sinowitz.
|
||||
|
||||
Changes in version 1.2.4
|
||||
- ReplaceChild() was almost guarenteed to fail. Should be fixed,
|
||||
thanks to Joe Smith. Joe also pointed out that the Print() functions
|
||||
should take stream references: I agree, and would like to overload
|
||||
the Print() method to take either format, but I don't want to do
|
||||
this in a dot release.
|
||||
- Some compilers seem to need an extra <ctype.h> include. Thanks
|
||||
to Steve Lhomme for that.
|
||||
|
||||
Changes in version 2.0.0 BETA
|
||||
- Made the ToXXX() casts safe if 'this' is null.
|
||||
When "LoadFile" is called with a filename, the value will correctly get set.
|
||||
Thanks to Brian Yoder.
|
||||
- Fixed bug where isalpha() and isalnum() would get called with a negative value for
|
||||
high ascii numbers. Thanks to Alesky Aksenov.
|
||||
- Fixed some errors codes that were not getting set.
|
||||
- Made methods "const" that were not.
|
||||
- Added a switch to enable or disable the ignoring of white space. ( TiXmlDocument::SetIgnoreWhiteSpace() )
|
||||
- Greater standardization and code re-use in the parser.
|
||||
- Added a stream out operator.
|
||||
- Added a stream in operator.
|
||||
- Entity support, of predefined entites. &#x entities are untouched by input or output.
|
||||
- Improved text out formatting.
|
||||
- Fixed ReplaceChild bug, thanks to Tao Chen.
|
||||
|
||||
Changes in version 2.0.1
|
||||
- Fixed hanging on loading a 0 length file. Thanks to Jeff Scozzafava.
|
||||
- Fixed crashing on InsertBeforeChild and InsertAfterChild. Also possibility of bad links being
|
||||
created by same function. Thanks to Frank De prins.
|
||||
- Added missing licence text. Thanks to Lars Willemsens.
|
||||
- Added <ctype.h> include, at the suggestion of Steve Walters.
|
||||
|
||||
Changes in version 2.1.0
|
||||
- Yves Berquin brings us the STL switch. The forum on SourceForge, and various emails to
|
||||
me, have long debated all out STL vs. no STL at all. And now you can have it both ways.
|
||||
TinyXml will compile either way.
|
||||
|
||||
Changes in version 2.1.1
|
||||
- Compilation warnings.
|
||||
|
||||
Changes in version 2.1.2
|
||||
- Uneeded code is not compiled in the STL case.
|
||||
- Changed headers so that STL can be turned on or off in tinyxml.h
|
||||
|
||||
Changes in version 2.1.3
|
||||
- Fixed non-const reference in API; now uses a pointer.
|
||||
- Copy constructor of TiXmlString not checking for assignment to self.
|
||||
- Nimrod Cohen found a truly evil bug in the STL implementation that occurs
|
||||
when a string is converted to a c_str and then assigned to self. Search for
|
||||
STL_STRING_BUG for a full description. I'm asserting this is a Microsoft STL
|
||||
bug, since &string and string.c_str() should never be the same. Nevertheless,
|
||||
the code works around it.
|
||||
- Urivan Saaib pointed out a compiler conflict, where the C headers define
|
||||
the isblank macro, which was wiping out the TiXmlString::isblank() method.
|
||||
The method was unused and has been removed.
|
||||
|
||||
Changes in version 2.1.4
|
||||
- Reworked the entity code. Entities were not correctly surving round trip input and output.
|
||||
Will now automatically create entities for high ascii in output.
|
||||
|
||||
Changes in version 2.1.5
|
||||
- Bug fix by kylotan : infinite loop on some input (tinyxmlparser.cpp rev 1.27)
|
||||
- Contributed by Ivica Aracic (bytelord) : 1 new VC++ project to compile versions as static libraries (tinyxml_lib.dsp),
|
||||
and an example usage in xmltest.dsp
|
||||
(Patch request ID 678605)
|
||||
- A suggestion by Ronald Fenner Jr (dormlock) to add #include <istream> and <ostream> for Apple's Project Builder
|
||||
(Patch request ID 697642)
|
||||
- A patch from ohommes that allows to parse correctly dots in element names and attribute names
|
||||
(Patch request 602600 and kylotan 701728)
|
||||
- A patch from hermitgeek ( James ) and wasteland for improper error reporting
|
||||
- Reviewed by Lee, with the following changes:
|
||||
- Got sick of fighting the STL/non-STL thing in the windows build. Broke
|
||||
them out as seperate projects.
|
||||
- I have too long not included the dsw. Added.
|
||||
- TinyXmlText had a protected Print. Odd.
|
||||
- Made LinkEndChild public, with docs and appropriate warnings.
|
||||
- Updated the docs.
|
||||
|
||||
2.2.0
|
||||
- Fixed an uninitialized pointer in the TiXmlAttributes
|
||||
- Fixed STL compilation problem in MinGW (and gcc 3?) - thanks Brian Yoder for finding this one
|
||||
- Fixed a syntax error in TiXmlDeclaration - thanks Brian Yoder
|
||||
- Fletcher Dunn proposed and submitted new error handling that tracked the row and column. Lee
|
||||
modified it to not have performance impact.
|
||||
- General cleanup suggestions from Fletcher Dunn.
|
||||
- In error handling, general errors will no longer clear the error state of specific ones.
|
||||
- Fix error in documentation : comments starting with "<?--" instead of "<!--" (thanks ion_pulse)
|
||||
- Added the TiXmlHandle. An easy, safe way to browse XML DOMs with less code.
|
||||
- Added QueryAttribute calls which have better error messaging. (Proposed by Fletcher Dunn)
|
||||
- Nodes and attributes can now print themselves to strings. (Yves suggestion)
|
||||
- Fixed bug where entities with one character would confuse parser. (Thanks Roman)
|
||||
|
||||
2.2.1
|
||||
- Additional testing (no more bugs found to be fixed in this release)
|
||||
- Significant performance improvement to the cursor code.
|
||||
|
||||
2.3.0
|
||||
- User Data are now defined in TiXmlBase instead of TiXmlNode
|
||||
- Character Entities are now UCS-2
|
||||
- Character Entities can be decimal or hexadecimal
|
||||
- UTF-8 conversion.
|
||||
- Fixed many, many bugs.
|
||||
|
||||
2.3.1
|
||||
- Fixed bug in handling nulls embedded in the input.
|
||||
- Make UTF-8 parser tolerant of bad text encoding.
|
||||
- Added encoding detection.
|
||||
- Many fixes and input from John-Philip Leonard Johansson (JP) and Ellers,
|
||||
including UTF-8 feedback, bug reports, and patches. Thanks!
|
||||
- Added version # constants - a suggestion from JP and Ellers.
|
||||
- [ 979180 ] Missing ; in entity reference, fix from Rob Laveaux.
|
||||
- Copy constructors and assignment have been a long time coming. Thanks to
|
||||
Fokke and JP.
|
||||
|
||||
2.3.2
|
||||
- Made the IsAlpha and IsAlphaNum much more tolerant of non-UTF-8 encodings. Thanks
|
||||
Volker Boerchers for finding the issue.
|
||||
- Ran the program though the magnificent Valgrind - http://valgrind.kde.org - to check
|
||||
for memory errors. Fixed some minor issues.
|
||||
|
||||
2.3.3
|
||||
- Fixed crash when test program was run from incorrect directory.
|
||||
- Fixed bug 1070717 - empty document not returned correctly - thanks Katsuhisa Yuasa.
|
||||
- Bug 1079301 resolved - deprecated stdlib calls. Thanks Adrian Boeing.
|
||||
- Bug 1035218 fixed - documentation errors. Xunji Luo
|
||||
- Other bug fixes have accumulated and been fixed on the way as well; my apologies to
|
||||
authors not credited!
|
||||
- Big fix / addition is to correctly return const values. TinyXml could basically
|
||||
remove const in a method like this: TiXmlElement* Foo() const, where the returned element
|
||||
was a pointer to internal data. That is now: const TiXmlElement* Foo() const and
|
||||
TiXmlElement* Foo().
|
||||
|
||||
2.3.4
|
||||
- Fixed additional const errors, thanks Kent Gibson.
|
||||
- Correctly re-enable warnings after tinyxml header. Thanks Cory Nelson.
|
||||
- Variety of type cleanup and warning fixes. Thanks Warren Stevens.
|
||||
- Cleaned up unneeded constructor calls in TinyString - thanks to Geoff Carlton and
|
||||
the discussion group on sourceforge.
|
||||
|
||||
2.4.0
|
||||
- Improved string class, thanks Tyge Lovset (whose name gets mangled in English - sorry)
|
||||
- Type cast compiler warning, thanks Rob van den Bogaard
|
||||
- Added GetText() convenience function. Thanks Ilya Parniuk & Andrew Ellers for input.
|
||||
- Many thanks to marlonism for finding an infinite loop in bad xml.
|
||||
- A patch to cleanup warnings from Robert Gebis.
|
||||
- Added ValueStr() to get the value of a node as a string.
|
||||
- TiXmlText can now parse and output as CDATA
|
||||
- Additional string improvement from James (z2895)
|
||||
- Removed extraneous 'const', thanks David Aldrich
|
||||
- First pass at switching to the "safe" stdlib functions. Many people have suggested and
|
||||
pushed on this, but Warren Stevens put together the first proposal.
|
||||
- TinyXml now will do EOL normalization before parsing, consistent with the W3C XML spec.
|
||||
- Documents loaded with the UTF-8 BOM will now save with the UTF-8 BOM. Good suggestion
|
||||
from 'instructor_'
|
||||
- Ellers submitted his very popular tutorials, which have been added to the distribution.
|
||||
|
||||
2.4.1
|
||||
- Fixed CDATA output formatting
|
||||
- Fixed memory allocators in TinyString to work with overloaded new/delete
|
||||
|
||||
2.4.2
|
||||
- solosnake pointed out that TIXML_LOG causes problems on an XBOX. The definition in the header
|
||||
was superflous and was moved inside of DEBUG_PARSING
|
||||
|
||||
2.4.3
|
||||
- Fixed a test bug that caused a crash in 'xmltest'. TinyXML was fine, but it isn't good
|
||||
to ship with a broken test suite.
|
||||
- Started converting some functions to not cast between std::string and const char*
|
||||
quite as often.
|
||||
- Added FILE* versions of the document loads - good suggestion from Wade Brainerd
|
||||
- Empty documents might not always return the errors they should. [1398915] Thanks to igor v.
|
||||
- Added some asserts for multiply adding a node, regardng bug [1391937] suggested by Paco Arjonilla.
|
||||
|
||||
2.4.4
|
||||
- Bug find thanks to andre-gross found a memory leak that occured when a document failed to load.
|
||||
- Bug find (and good analysis) by VirtualJim who found a case where attribute parsing
|
||||
should be throwing an error and wasn't.
|
||||
- Steve Hyatt suggested the QueryValueAttribute method, which is now implemented.
|
||||
- DavidA identified a chunk of dead code.
|
||||
- Andrew Baxter sent in some compiler warnings that were good clean up points.
|
||||
|
||||
2.5
|
||||
- Added the Visit() API. Many thanks to both Andrew Ellerton and John-Philip for all their
|
||||
work, code, suggestion, and just general pushing that it should be done.
|
||||
- Removed existing streaming code and use TiXmlPrinter instead.
|
||||
- [ tinyxml-Bugs-1527079 ] Compile error in tinystr.cpp fixed, thanks to Paul Suggs
|
||||
- [ tinyxml-Bugs-1522890 ] SaveFile has no error checks fixed, thanks to Ivan Dobrokotov
|
||||
- Ivan Dobrokotov also reported redundant memory allocation in the Attribute() method, which
|
||||
upon investigation was a mess. The attribute should now be fixed for both const char* and
|
||||
std::string, and the return types match the input parameters.
|
||||
- Feature [ 1511105 ] Make TiXmlComment constructor accept a string / char*, implemented.
|
||||
Thanks to Karl Itschen for the feedback.
|
||||
- [ 1480108 ] Stream parsing fails when CDATA contains tags was found by Tobias Grimm, who also
|
||||
submitted a test case and patch. A significant bug in CDATA streaming (operator>>) has now
|
||||
been fixed.
|
||||
|
||||
2.5.2
|
||||
- Lieven, and others, pointed out a missing const-cast that upset the Open Watcom compiler.
|
||||
Should now be fixed.
|
||||
- ErrorRow and ErrorCol should have been const, and weren't. Fixed thanks to Dmitry Polutov.
|
||||
|
||||
2.5.3
|
||||
- zloe_zlo identified a missing string specialization for QueryValueAttribute() [ 1695429 ]. Worked
|
||||
on this bug, but not sure how to fix it in a safe, cross-compiler way.
|
||||
- increased warning level to 4 and turned on detect 64 bit portability issues for VC2005.
|
||||
May address [ 1677737 ] VS2005: /Wp64 warnings
|
||||
- grosheck identified several problems with the Document copy. Many thanks for [ 1660367 ]
|
||||
- Nice catch, and suggested fix, be Gilad Novik on the Printer dropping entities.
|
||||
"[ 1600650 ] Bug when printing xml text" is now fixed.
|
||||
- A subtle fix from Nicos Gollan in the tinystring initializer:
|
||||
[ 1581449 ] Fix initialiser of TiXmlString::nullrep_
|
||||
- Great catch, although there isn't a submitter for the bug. [ 1475201 ] TinyXML parses entities in comments.
|
||||
Comments should not, in fact, parse entities. Fixed the code path and added tests.
|
||||
- We were not catching all the returns from ftell. Thanks to Bernard for catching that.
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="echo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=echo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "echo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "echo.mak" CFG="echo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "echo - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "echo - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "echo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "echoRelease"
|
||||
# PROP Intermediate_Dir "echoRelease"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "echo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "echo___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "echo___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "echoDebug"
|
||||
# PROP Intermediate_Dir "echoDebug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "echo - Win32 Release"
|
||||
# Name "echo - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltester\bugtest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlerror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlparser.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,530 +0,0 @@
|
|||
/** @mainpage
|
||||
|
||||
<h1> TinyXML </h1>
|
||||
|
||||
TinyXML is a simple, small, C++ XML parser that can be easily
|
||||
integrated into other programs.
|
||||
|
||||
<h2> What it does. </h2>
|
||||
|
||||
In brief, TinyXML parses an XML document, and builds from that a
|
||||
Document Object Model (DOM) that can be read, modified, and saved.
|
||||
|
||||
XML stands for "eXtensible Markup Language." It allows you to create
|
||||
your own document markups. Where HTML does a very good job of marking
|
||||
documents for browsers, XML allows you to define any kind of document
|
||||
markup, for example a document that describes a "to do" list for an
|
||||
organizer application. XML is a very structured and convenient format.
|
||||
All those random file formats created to store application data can
|
||||
all be replaced with XML. One parser for everything.
|
||||
|
||||
The best place for the complete, correct, and quite frankly hard to
|
||||
read spec is at <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
||||
http://www.w3.org/TR/2004/REC-xml-20040204/</a>. An intro to XML
|
||||
(that I really like) can be found at
|
||||
<a href="http://skew.org/xml/tutorial/">http://skew.org/xml/tutorial</a>.
|
||||
|
||||
There are different ways to access and interact with XML data.
|
||||
TinyXML uses a Document Object Model (DOM), meaning the XML data is parsed
|
||||
into a C++ objects that can be browsed and manipulated, and then
|
||||
written to disk or another output stream. You can also construct an XML document
|
||||
from scratch with C++ objects and write this to disk or another output
|
||||
stream.
|
||||
|
||||
TinyXML is designed to be easy and fast to learn. It is two headers
|
||||
and four cpp files. Simply add these to your project and off you go.
|
||||
There is an example file - xmltest.cpp - to get you started.
|
||||
|
||||
TinyXML is released under the ZLib license,
|
||||
so you can use it in open source or commercial code. The details
|
||||
of the license are at the top of every source file.
|
||||
|
||||
TinyXML attempts to be a flexible parser, but with truly correct and
|
||||
compliant XML output. TinyXML should compile on any reasonably C++
|
||||
compliant system. It does not rely on exceptions or RTTI. It can be
|
||||
compiled with or without STL support. TinyXML fully supports
|
||||
the UTF-8 encoding, and the first 64k character entities.
|
||||
|
||||
|
||||
<h2> What it doesn't do. </h2>
|
||||
|
||||
TinyXML doesn't parse or use DTDs (Document Type Definitions) or XSLs
|
||||
(eXtensible Stylesheet Language.) There are other parsers out there
|
||||
(check out www.sourceforge.org, search for XML) that are much more fully
|
||||
featured. But they are also much bigger, take longer to set up in
|
||||
your project, have a higher learning curve, and often have a more
|
||||
restrictive license. If you are working with browsers or have more
|
||||
complete XML needs, TinyXML is not the parser for you.
|
||||
|
||||
The following DTD syntax will not parse at this time in TinyXML:
|
||||
|
||||
@verbatim
|
||||
<!DOCTYPE Archiv [
|
||||
<!ELEMENT Comment (#PCDATA)>
|
||||
]>
|
||||
@endverbatim
|
||||
|
||||
because TinyXML sees this as a !DOCTYPE node with an illegally
|
||||
embedded !ELEMENT node. This may be addressed in the future.
|
||||
|
||||
<h2> Tutorials. </h2>
|
||||
|
||||
For the impatient, here is a tutorial to get you going. A great way to get started,
|
||||
but it is worth your time to read this (very short) manual completely.
|
||||
|
||||
- @subpage tutorial0
|
||||
|
||||
<h2> Code Status. </h2>
|
||||
|
||||
TinyXML is mature, tested code. It is very stable. If you find
|
||||
bugs, please file a bug report on the sourceforge web site
|
||||
(www.sourceforge.net/projects/tinyxml). We'll get them straightened
|
||||
out as soon as possible.
|
||||
|
||||
There are some areas of improvement; please check sourceforge if you are
|
||||
interested in working on TinyXML.
|
||||
|
||||
<h2> Related Projects </h2>
|
||||
|
||||
TinyXML projects you may find useful! (Descriptions provided by the projects.)
|
||||
|
||||
<ul>
|
||||
<li> <b>TinyXPath</b> (http://tinyxpath.sourceforge.net). TinyXPath is a small footprint
|
||||
XPath syntax decoder, written in C++.</li>
|
||||
<li> <b>TinyXML++</b> (http://code.google.com/p/ticpp/). TinyXML++ is a completely new
|
||||
interface to TinyXML that uses MANY of the C++ strengths. Templates,
|
||||
exceptions, and much better error handling.</li>
|
||||
</ul>
|
||||
|
||||
<h2> Features </h2>
|
||||
|
||||
<h3> Using STL </h3>
|
||||
|
||||
TinyXML can be compiled to use or not use STL. When using STL, TinyXML
|
||||
uses the std::string class, and fully supports std::istream, std::ostream,
|
||||
operator<<, and operator>>. Many API methods have both 'const char*' and
|
||||
'const std::string&' forms.
|
||||
|
||||
When STL support is compiled out, no STL files are included whatsoever. All
|
||||
the string classes are implemented by TinyXML itself. API methods
|
||||
all use the 'const char*' form for input.
|
||||
|
||||
Use the compile time #define:
|
||||
|
||||
TIXML_USE_STL
|
||||
|
||||
to compile one version or the other. This can be passed by the compiler,
|
||||
or set as the first line of "tinyxml.h".
|
||||
|
||||
Note: If compiling the test code in Linux, setting the environment
|
||||
variable TINYXML_USE_STL=YES/NO will control STL compilation. In the
|
||||
Windows project file, STL and non STL targets are provided. In your project,
|
||||
It's probably easiest to add the line "#define TIXML_USE_STL" as the first
|
||||
line of tinyxml.h.
|
||||
|
||||
<h3> UTF-8 </h3>
|
||||
|
||||
TinyXML supports UTF-8 allowing to manipulate XML files in any language. TinyXML
|
||||
also supports "legacy mode" - the encoding used before UTF-8 support and
|
||||
probably best described as "extended ascii".
|
||||
|
||||
Normally, TinyXML will try to detect the correct encoding and use it. However,
|
||||
by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXML
|
||||
can be forced to always use one encoding.
|
||||
|
||||
TinyXML will assume Legacy Mode until one of the following occurs:
|
||||
<ol>
|
||||
<li> If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf)
|
||||
begin the file or data stream, TinyXML will read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has an encoding="UTF-8", then
|
||||
TinyXML will read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has no encoding specified, then TinyXML will
|
||||
read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has an encoding="something else", then TinyXML
|
||||
will read it as Legacy Mode. In legacy mode, TinyXML will work as it did before. It's
|
||||
not clear what that mode does exactly, but old content should keep working.</li>
|
||||
<li> Until one of the above criteria is met, TinyXML runs in Legacy Mode.</li>
|
||||
</ol>
|
||||
|
||||
What happens if the encoding is incorrectly set or detected? TinyXML will try
|
||||
to read and pass through text seen as improperly encoded. You may get some strange results or
|
||||
mangled characters. You may want to force TinyXML to the correct mode.
|
||||
|
||||
You may force TinyXML to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or
|
||||
LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all
|
||||
the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may
|
||||
force it to TIXML_ENCODING_UTF8 with the same technique.
|
||||
|
||||
For English users, using English XML, UTF-8 is the same as low-ASCII. You
|
||||
don't need to be aware of UTF-8 or change your code in any way. You can think
|
||||
of UTF-8 as a "superset" of ASCII.
|
||||
|
||||
UTF-8 is not a double byte format - but it is a standard encoding of Unicode!
|
||||
TinyXML does not use or directly support wchar, TCHAR, or Microsoft's _UNICODE at this time.
|
||||
It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding
|
||||
of unicode. This is a source of confusion.
|
||||
|
||||
For "high-ascii" languages - everything not English, pretty much - TinyXML can
|
||||
handle all languages, at the same time, as long as the XML is encoded
|
||||
in UTF-8. That can be a little tricky, older programs and operating systems
|
||||
tend to use the "default" or "traditional" code page. Many apps (and almost all
|
||||
modern ones) can output UTF-8, but older or stubborn (or just broken) ones
|
||||
still output text in the default code page.
|
||||
|
||||
For example, Japanese systems traditionally use SHIFT-JIS encoding.
|
||||
Text encoded as SHIFT-JIS can not be read by TinyXML.
|
||||
A good text editor can import SHIFT-JIS and then save as UTF-8.
|
||||
|
||||
The <a href="http://skew.org/xml/tutorial/">Skew.org link</a> does a great
|
||||
job covering the encoding issue.
|
||||
|
||||
The test file "utf8test.xml" is an XML containing English, Spanish, Russian,
|
||||
and Simplified Chinese. (Hopefully they are translated correctly). The file
|
||||
"utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that
|
||||
if you don't have the correct fonts (Simplified Chinese or Russian) on your
|
||||
system, you won't see output that matches the GIF file even if you can parse
|
||||
it correctly. Also note that (at least on my Windows machine) console output
|
||||
is in a Western code page, so that Print() or printf() cannot correctly display
|
||||
the file. This is not a bug in TinyXML - just an OS issue. No data is lost or
|
||||
destroyed by TinyXML. The console just doesn't render UTF-8.
|
||||
|
||||
|
||||
<h3> Entities </h3>
|
||||
TinyXML recognizes the pre-defined "character entities", meaning special
|
||||
characters. Namely:
|
||||
|
||||
@verbatim
|
||||
& &
|
||||
< <
|
||||
> >
|
||||
" "
|
||||
' '
|
||||
@endverbatim
|
||||
|
||||
These are recognized when the XML document is read, and translated to there
|
||||
UTF-8 equivalents. For instance, text with the XML of:
|
||||
|
||||
@verbatim
|
||||
Far & Away
|
||||
@endverbatim
|
||||
|
||||
will have the Value() of "Far & Away" when queried from the TiXmlText object,
|
||||
and will be written back to the XML stream/file as an ampersand. Older versions
|
||||
of TinyXML "preserved" character entities, but the newer versions will translate
|
||||
them into characters.
|
||||
|
||||
Additionally, any character can be specified by its Unicode code point:
|
||||
The syntax " " or " " are both to the non-breaking space characher.
|
||||
|
||||
<h3> Printing </h3>
|
||||
TinyXML can print output in several different ways that all have strengths and limitations.
|
||||
|
||||
- Print( FILE* ). Output to a std-C stream, which includes all C files as well as stdout.
|
||||
- "Pretty prints", but you don't have control over printing options.
|
||||
- The output is streamed directly to the FILE object, so there is no memory overhead
|
||||
in the TinyXML code.
|
||||
- used by Print() and SaveFile()
|
||||
|
||||
- operator<<. Output to a c++ stream.
|
||||
- Integrates with standart C++ iostreams.
|
||||
- Outputs in "network printing" mode without line breaks. Good for network transmission
|
||||
and moving XML between C++ objects, but hard for a human to read.
|
||||
|
||||
- TiXmlPrinter. Output to a std::string or memory buffer.
|
||||
- API is less concise
|
||||
- Future printing options will be put here.
|
||||
- Printing may change slightly in future versions as it is refined and expanded.
|
||||
|
||||
<h3> Streams </h3>
|
||||
With TIXML_USE_STL on TinyXML supports C++ streams (operator <<,>>) streams as well
|
||||
as C (FILE*) streams. There are some differences that you may need to be aware of.
|
||||
|
||||
C style output:
|
||||
- based on FILE*
|
||||
- the Print() and SaveFile() methods
|
||||
|
||||
Generates formatted output, with plenty of white space, intended to be as
|
||||
human-readable as possible. They are very fast, and tolerant of ill formed
|
||||
XML documents. For example, an XML document that contains 2 root elements
|
||||
and 2 declarations, will still print.
|
||||
|
||||
C style input:
|
||||
- based on FILE*
|
||||
- the Parse() and LoadFile() methods
|
||||
|
||||
A fast, tolerant read. Use whenever you don't need the C++ streams.
|
||||
|
||||
C++ style output:
|
||||
- based on std::ostream
|
||||
- operator<<
|
||||
|
||||
Generates condensed output, intended for network transmission rather than
|
||||
readability. Depending on your system's implementation of the ostream class,
|
||||
these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML:
|
||||
a document should contain the correct one root element. Additional root level
|
||||
elements will not be streamed out.
|
||||
|
||||
C++ style input:
|
||||
- based on std::istream
|
||||
- operator>>
|
||||
|
||||
Reads XML from a stream, making it useful for network transmission. The tricky
|
||||
part is knowing when the XML document is complete, since there will almost
|
||||
certainly be other data in the stream. TinyXML will assume the XML data is
|
||||
complete after it reads the root element. Put another way, documents that
|
||||
are ill-constructed with more than one root element will not read correctly.
|
||||
Also note that operator>> is somewhat slower than Parse, due to both
|
||||
implementation of the STL and limitations of TinyXML.
|
||||
|
||||
<h3> White space </h3>
|
||||
The world simply does not agree on whether white space should be kept, or condensed.
|
||||
For example, pretend the '_' is a space, and look at "Hello____world". HTML, and
|
||||
at least some XML parsers, will interpret this as "Hello_world". They condense white
|
||||
space. Some XML parsers do not, and will leave it as "Hello____world". (Remember
|
||||
to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become
|
||||
Hello___world.
|
||||
|
||||
It's an issue that hasn't been resolved to my satisfaction. TinyXML supports the
|
||||
first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior.
|
||||
The default is to condense white space.
|
||||
|
||||
If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool )
|
||||
before making any calls to Parse XML data, and I don't recommend changing it after
|
||||
it has been set.
|
||||
|
||||
|
||||
<h3> Handles </h3>
|
||||
|
||||
Where browsing an XML document in a robust way, it is important to check
|
||||
for null returns from method calls. An error safe implementation can
|
||||
generate a lot of code like:
|
||||
|
||||
@verbatim
|
||||
TiXmlElement* root = document.FirstChildElement( "Document" );
|
||||
if ( root )
|
||||
{
|
||||
TiXmlElement* element = root->FirstChildElement( "Element" );
|
||||
if ( element )
|
||||
{
|
||||
TiXmlElement* child = element->FirstChildElement( "Child" );
|
||||
if ( child )
|
||||
{
|
||||
TiXmlElement* child2 = child->NextSiblingElement( "Child" );
|
||||
if ( child2 )
|
||||
{
|
||||
// Finally do something useful.
|
||||
@endverbatim
|
||||
|
||||
Handles have been introduced to clean this up. Using the TiXmlHandle class,
|
||||
the previous code reduces to:
|
||||
|
||||
@verbatim
|
||||
TiXmlHandle docHandle( &document );
|
||||
TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
|
||||
if ( child2 )
|
||||
{
|
||||
// do something useful
|
||||
@endverbatim
|
||||
|
||||
Which is much easier to deal with. See TiXmlHandle for more information.
|
||||
|
||||
|
||||
<h3> Row and Column tracking </h3>
|
||||
Being able to track nodes and attributes back to their origin location
|
||||
in source files can be very important for some applications. Additionally,
|
||||
knowing where parsing errors occured in the original source can be very
|
||||
time saving.
|
||||
|
||||
TinyXML can tracks the row and column origin of all nodes and attributes
|
||||
in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return
|
||||
the origin of the node in the source text. The correct tabs can be
|
||||
configured in TiXmlDocument::SetTabSize().
|
||||
|
||||
|
||||
<h2> Using and Installing </h2>
|
||||
|
||||
To Compile and Run xmltest:
|
||||
|
||||
A Linux Makefile and a Windows Visual C++ .dsw file is provided.
|
||||
Simply compile and run. It will write the file demotest.xml to your
|
||||
disk and generate output on the screen. It also tests walking the
|
||||
DOM by printing out the number of nodes found using different
|
||||
techniques.
|
||||
|
||||
The Linux makefile is very generic and runs on many systems - it
|
||||
is currently tested on mingw and
|
||||
MacOSX. You do not need to run 'make depend'. The dependecies have been
|
||||
hard coded.
|
||||
|
||||
<h3>Windows project file for VC6</h3>
|
||||
<ul>
|
||||
<li>tinyxml: tinyxml library, non-STL </li>
|
||||
<li>tinyxmlSTL: tinyxml library, STL </li>
|
||||
<li>tinyXmlTest: test app, non-STL </li>
|
||||
<li>tinyXmlTestSTL: test app, STL </li>
|
||||
</ul>
|
||||
|
||||
<h3>Makefile</h3>
|
||||
At the top of the makefile you can set:
|
||||
|
||||
PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in
|
||||
the makefile.
|
||||
|
||||
In the tinyxml directory, type "make clean" then "make". The executable
|
||||
file 'xmltest' will be created.
|
||||
|
||||
|
||||
|
||||
<h3>To Use in an Application:</h3>
|
||||
|
||||
Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your
|
||||
project or make file. That's it! It should compile on any reasonably
|
||||
compliant C++ system. You do not need to enable exceptions or
|
||||
RTTI for TinyXML.
|
||||
|
||||
|
||||
<h2> How TinyXML works. </h2>
|
||||
|
||||
An example is probably the best way to go. Take:
|
||||
@verbatim
|
||||
<?xml version="1.0" standalone=no>
|
||||
<!-- Our to do list data -->
|
||||
<ToDo>
|
||||
<Item priority="1"> Go to the <bold>Toy store!</bold></Item>
|
||||
<Item priority="2"> Do bills</Item>
|
||||
</ToDo>
|
||||
@endverbatim
|
||||
|
||||
Its not much of a To Do list, but it will do. To read this file
|
||||
(say "demo.xml") you would create a document, and parse it in:
|
||||
@verbatim
|
||||
TiXmlDocument doc( "demo.xml" );
|
||||
doc.LoadFile();
|
||||
@endverbatim
|
||||
|
||||
And its ready to go. Now lets look at some lines and how they
|
||||
relate to the DOM.
|
||||
|
||||
@verbatim
|
||||
<?xml version="1.0" standalone=no>
|
||||
@endverbatim
|
||||
|
||||
The first line is a declaration, and gets turned into the
|
||||
TiXmlDeclaration class. It will be the first child of the
|
||||
document node.
|
||||
|
||||
This is the only directive/special tag parsed by by TinyXML.
|
||||
Generally directive tags are stored in TiXmlUnknown so the
|
||||
commands wont be lost when it is saved back to disk.
|
||||
|
||||
@verbatim
|
||||
<!-- Our to do list data -->
|
||||
@endverbatim
|
||||
|
||||
A comment. Will become a TiXmlComment object.
|
||||
|
||||
@verbatim
|
||||
<ToDo>
|
||||
@endverbatim
|
||||
|
||||
The "ToDo" tag defines a TiXmlElement object. This one does not have
|
||||
any attributes, but does contain 2 other elements.
|
||||
|
||||
@verbatim
|
||||
<Item priority="1">
|
||||
@endverbatim
|
||||
|
||||
Creates another TiXmlElement which is a child of the "ToDo" element.
|
||||
This element has 1 attribute, with the name "priority" and the value
|
||||
"1".
|
||||
|
||||
@verbatim
|
||||
Go to the
|
||||
@endverbatim
|
||||
|
||||
A TiXmlText. This is a leaf node and cannot contain other nodes.
|
||||
It is a child of the "Item" TiXmlElement.
|
||||
|
||||
@verbatim
|
||||
<bold>
|
||||
@endverbatim
|
||||
|
||||
|
||||
Another TiXmlElement, this one a child of the "Item" element.
|
||||
|
||||
Etc.
|
||||
|
||||
Looking at the entire object tree, you end up with:
|
||||
@verbatim
|
||||
TiXmlDocument "demo.xml"
|
||||
TiXmlDeclaration "version='1.0'" "standalone=no"
|
||||
TiXmlComment " Our to do list data"
|
||||
TiXmlElement "ToDo"
|
||||
TiXmlElement "Item" Attribtutes: priority = 1
|
||||
TiXmlText "Go to the "
|
||||
TiXmlElement "bold"
|
||||
TiXmlText "Toy store!"
|
||||
TiXmlElement "Item" Attributes: priority=2
|
||||
TiXmlText "Do bills"
|
||||
@endverbatim
|
||||
|
||||
<h2> Documentation </h2>
|
||||
|
||||
The documentation is build with Doxygen, using the 'dox'
|
||||
configuration file.
|
||||
|
||||
<h2> License </h2>
|
||||
|
||||
TinyXML is released under the zlib license:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
<h2> References </h2>
|
||||
|
||||
The World Wide Web Consortium is the definitive standard body for
|
||||
XML, and there web pages contain huge amounts of information.
|
||||
|
||||
The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
||||
http://www.w3.org/TR/2004/REC-xml-20040204/</a>
|
||||
|
||||
I also recommend "XML Pocket Reference" by Robert Eckstein and published by
|
||||
OReilly...the book that got the whole thing started.
|
||||
|
||||
<h2> Contributors, Contacts, and a Brief History </h2>
|
||||
|
||||
Thanks very much to everyone who sends suggestions, bugs, ideas, and
|
||||
encouragement. It all helps, and makes this project fun. A special thanks
|
||||
to the contributors on the web pages that keep it lively.
|
||||
|
||||
So many people have sent in bugs and ideas, that rather than list here
|
||||
we try to give credit due in the "changes.txt" file.
|
||||
|
||||
TinyXML was originally written by Lee Thomason. (Often the "I" still
|
||||
in the documentation.) Lee reviews changes and releases new versions,
|
||||
with the help of Yves Berquin, Andrew Ellerton, and the tinyXml community.
|
||||
|
||||
We appreciate your suggestions, and would love to know if you
|
||||
use TinyXML. Hopefully you will enjoy it and find it useful.
|
||||
Please post questions, comments, file bugs, or contact us at:
|
||||
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
Lee Thomason, Yves Berquin, Andrew Ellerton
|
||||
*/
|
|
@ -1,92 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="tinyXmlTest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=tinyXmlTest - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyXmlTest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyXmlTest.mak" CFG="tinyXmlTest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tinyXmlTest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "tinyXmlTest - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tinyXmlTest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "tinyXmlTest___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "tinyXmlTest___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "tinyXmlTest___Win32_Release"
|
||||
# PROP Intermediate_Dir "tinyXmlTest___Win32_Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ./Release/tinyxml.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "tinyXmlTest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "tinyXmlTest___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "tinyXmlTest___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "tinyXmlTest___Win32_Debug"
|
||||
# PROP Intermediate_Dir "tinyXmlTest___Win32_Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TUNE" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ./Debug/tinyxmld.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tinyXmlTest - Win32 Release"
|
||||
# Name "tinyXmlTest - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltest.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,227 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="tinyXmlTest"
|
||||
ProjectGUID="{34719950-09E8-457E-BE23-8F1CE3A1F1F6}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\tinyXmlTest___Win32_Debug"
|
||||
IntermediateDirectory=".\tinyXmlTest___Win32_Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\tinyXmlTest___Win32_Debug/tinyXmlTest.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TUNE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.pch"
|
||||
AssemblerListingLocation=".\tinyXmlTest___Win32_Debug/"
|
||||
ObjectFile=".\tinyXmlTest___Win32_Debug/"
|
||||
ProgramDataBaseFileName=".\tinyXmlTest___Win32_Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="./Debug/tinyxmld.lib"
|
||||
OutputFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\tinyXmlTest___Win32_Debug/tinyXmlTest.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\tinyXmlTest___Win32_Release"
|
||||
IntermediateDirectory=".\tinyXmlTest___Win32_Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\tinyXmlTest___Win32_Release/tinyXmlTest.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.pch"
|
||||
AssemblerListingLocation=".\tinyXmlTest___Win32_Release/"
|
||||
ObjectFile=".\tinyXmlTest___Win32_Release/"
|
||||
ProgramDataBaseFileName=".\tinyXmlTest___Win32_Release/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="./Release/tinyxml.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\tinyXmlTest___Win32_Release/tinyXmlTest.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="xmltest.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,92 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="tinyXmlTestSTL" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=tinyXmlTestSTL - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyXmlTestSTL.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyXmlTestSTL.mak" CFG="tinyXmlTestSTL - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tinyXmlTestSTL - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "tinyXmlTestSTL - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tinyXmlTestSTL - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "tinyXmlTestSTL___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "tinyXmlTestSTL___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "tinyXmlTestSTL___Win32_Release"
|
||||
# PROP Intermediate_Dir "tinyXmlTestSTL___Win32_Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ./Release_STL/tinyxml_stl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "tinyXmlTestSTL - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "tinyXmlTestSTL___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "tinyXmlTestSTL___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "tinyXmlTestSTL___Win32_Debug"
|
||||
# PROP Intermediate_Dir "tinyXmlTestSTL___Win32_Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TIXML_USE_STL" /D "TUNE" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 ./Debug_STL/tinyxmld_stl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tinyXmlTestSTL - Win32 Release"
|
||||
# Name "tinyXmlTestSTL - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltest.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,226 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="tinyXmlTestSTL"
|
||||
ProjectGUID="{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\tinyXmlTestSTL___Win32_Debug"
|
||||
IntermediateDirectory=".\tinyXmlTestSTL___Win32_Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TIXML_USE_STL;TUNE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.pch"
|
||||
AssemblerListingLocation=".\tinyXmlTestSTL___Win32_Debug/"
|
||||
ObjectFile=".\tinyXmlTestSTL___Win32_Debug/"
|
||||
ProgramDataBaseFileName=".\tinyXmlTestSTL___Win32_Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="./Debug_STL/tinyxmld_stl.lib"
|
||||
OutputFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\tinyXmlTestSTL___Win32_Release"
|
||||
IntermediateDirectory=".\tinyXmlTestSTL___Win32_Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TIXML_USE_STL;_CRT_SECURE_NO_WARNINGS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.pch"
|
||||
AssemblerListingLocation=".\tinyXmlTestSTL___Win32_Release/"
|
||||
ObjectFile=".\tinyXmlTestSTL___Win32_Release/"
|
||||
ProgramDataBaseFileName=".\tinyXmlTestSTL___Win32_Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="./Release_STL/tinyxml_stl.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="xmltest.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original file by Yves Berquin.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TIXML_USE_STL
|
||||
|
||||
#include "tinystr.h"
|
||||
|
||||
// Error value for find primitive
|
||||
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
|
||||
|
||||
|
||||
// Null rep.
|
||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||
|
||||
|
||||
void TiXmlString::reserve (size_type cap)
|
||||
{
|
||||
if (cap > capacity())
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(length(), cap);
|
||||
memcpy(tmp.start(), data(), length());
|
||||
swap(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::assign(const char* str, size_type len)
|
||||
{
|
||||
size_type cap = capacity();
|
||||
if (len > cap || cap > 3*(len + 8))
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(len);
|
||||
memcpy(tmp.start(), str, len);
|
||||
swap(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(start(), str, len);
|
||||
set_size(len);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::append(const char* str, size_type len)
|
||||
{
|
||||
size_type newsize = length() + len;
|
||||
if (newsize > capacity())
|
||||
{
|
||||
reserve (newsize + capacity());
|
||||
}
|
||||
memmove(finish(), str, len);
|
||||
set_size(newsize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.reserve(a.length() + b.length());
|
||||
tmp += a;
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
|
||||
tmp.reserve(a.length() + b_len);
|
||||
tmp += a;
|
||||
tmp.append(b, b_len);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
|
||||
tmp.reserve(a_len + b.length());
|
||||
tmp.append(a, a_len);
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
#endif // TIXML_USE_STL
|
|
@ -1,319 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original file by Yves Berquin.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
|
||||
*
|
||||
* - completely rewritten. compact, clean, and fast implementation.
|
||||
* - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
|
||||
* - fixed reserve() to work as per specification.
|
||||
* - fixed buggy compares operator==(), operator<(), and operator>()
|
||||
* - fixed operator+=() to take a const ref argument, following spec.
|
||||
* - added "copy" constructor with length, and most compare operators.
|
||||
* - added swap(), clear(), size(), capacity(), operator+().
|
||||
*/
|
||||
|
||||
#ifndef TIXML_USE_STL
|
||||
|
||||
#ifndef TIXML_STRING_INCLUDED
|
||||
#define TIXML_STRING_INCLUDED
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The support for explicit isn't that universal, and it isn't really
|
||||
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||
used. Be nice to old compilers and macro it here:
|
||||
*/
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||
// Microsoft visual studio, version 6 and higher.
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||
// GCC version 3 and higher.s
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#else
|
||||
#define TIXML_EXPLICIT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
TiXmlString is an emulation of a subset of the std::string template.
|
||||
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||
Only the member functions relevant to the TinyXML project have been implemented.
|
||||
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||
*/
|
||||
class TiXmlString
|
||||
{
|
||||
public :
|
||||
// The size type used
|
||||
typedef size_t size_type;
|
||||
|
||||
// Error value for find primitive
|
||||
static const size_type npos; // = -1;
|
||||
|
||||
|
||||
// TiXmlString empty constructor
|
||||
TiXmlString () : rep_(&nullrep_)
|
||||
{
|
||||
}
|
||||
|
||||
// TiXmlString copy constructor
|
||||
TiXmlString ( const TiXmlString & copy) : rep_(0)
|
||||
{
|
||||
init(copy.length());
|
||||
memcpy(start(), copy.data(), length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
|
||||
{
|
||||
init( static_cast<size_type>( strlen(copy) ));
|
||||
memcpy(start(), copy, length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
|
||||
{
|
||||
init(len);
|
||||
memcpy(start(), str, len);
|
||||
}
|
||||
|
||||
// TiXmlString destructor
|
||||
~TiXmlString ()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
// = operator
|
||||
TiXmlString& operator = (const char * copy)
|
||||
{
|
||||
return assign( copy, (size_type)strlen(copy));
|
||||
}
|
||||
|
||||
// = operator
|
||||
TiXmlString& operator = (const TiXmlString & copy)
|
||||
{
|
||||
return assign(copy.start(), copy.length());
|
||||
}
|
||||
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const char * suffix)
|
||||
{
|
||||
return append(suffix, static_cast<size_type>( strlen(suffix) ));
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (char single)
|
||||
{
|
||||
return append(&single, 1);
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const TiXmlString & suffix)
|
||||
{
|
||||
return append(suffix.data(), suffix.length());
|
||||
}
|
||||
|
||||
|
||||
// Convert a TiXmlString into a null-terminated char *
|
||||
const char * c_str () const { return rep_->str; }
|
||||
|
||||
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||
const char * data () const { return rep_->str; }
|
||||
|
||||
// Return the length of a TiXmlString
|
||||
size_type length () const { return rep_->size; }
|
||||
|
||||
// Alias for length()
|
||||
size_type size () const { return rep_->size; }
|
||||
|
||||
// Checks if a TiXmlString is empty
|
||||
bool empty () const { return rep_->size == 0; }
|
||||
|
||||
// Return capacity of string
|
||||
size_type capacity () const { return rep_->capacity; }
|
||||
|
||||
|
||||
// single char extraction
|
||||
const char& at (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// [] operator
|
||||
char& operator [] (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// find a char in a string. Return TiXmlString::npos if not found
|
||||
size_type find (char lookup) const
|
||||
{
|
||||
return find(lookup, 0);
|
||||
}
|
||||
|
||||
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||
size_type find (char tofind, size_type offset) const
|
||||
{
|
||||
if (offset >= length()) return npos;
|
||||
|
||||
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == tofind) return static_cast< size_type >( p - c_str() );
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
void clear ()
|
||||
{
|
||||
//Lee:
|
||||
//The original was just too strange, though correct:
|
||||
// TiXmlString().swap(*this);
|
||||
//Instead use the quit & re-init:
|
||||
quit();
|
||||
init(0,0);
|
||||
}
|
||||
|
||||
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||
*/
|
||||
void reserve (size_type cap);
|
||||
|
||||
TiXmlString& assign (const char* str, size_type len);
|
||||
|
||||
TiXmlString& append (const char* str, size_type len);
|
||||
|
||||
void swap (TiXmlString& other)
|
||||
{
|
||||
Rep* r = rep_;
|
||||
rep_ = other.rep_;
|
||||
other.rep_ = r;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void init(size_type sz) { init(sz, sz); }
|
||||
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
|
||||
char* start() const { return rep_->str; }
|
||||
char* finish() const { return rep_->str + rep_->size; }
|
||||
|
||||
struct Rep
|
||||
{
|
||||
size_type size, capacity;
|
||||
char str[1];
|
||||
};
|
||||
|
||||
void init(size_type sz, size_type cap)
|
||||
{
|
||||
if (cap)
|
||||
{
|
||||
// Lee: the original form:
|
||||
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||
// doesn't work in some cases of new being overloaded. Switching
|
||||
// to the normal allocation, although use an 'int' for systems
|
||||
// that are overly picky about structure alignment.
|
||||
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||
|
||||
rep_->str[ rep_->size = sz ] = '\0';
|
||||
rep_->capacity = cap;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep_ = &nullrep_;
|
||||
}
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
if (rep_ != &nullrep_)
|
||||
{
|
||||
// The rep_ is really an array of ints. (see the allocator, above).
|
||||
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||
delete [] ( reinterpret_cast<int*>( rep_ ) );
|
||||
}
|
||||
}
|
||||
|
||||
Rep * rep_;
|
||||
static Rep nullrep_;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return ( a.length() == b.length() ) // optimization on some platforms
|
||||
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
|
||||
}
|
||||
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
|
||||
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
|
||||
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
|
||||
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
|
||||
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
|
||||
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b);
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b);
|
||||
|
||||
|
||||
/*
|
||||
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||
Only the operators that we need for TinyXML have been developped.
|
||||
*/
|
||||
class TiXmlOutStream : public TiXmlString
|
||||
{
|
||||
public :
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const TiXmlString & in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const char * in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
#endif // TIXML_STRING_INCLUDED
|
||||
#endif // TIXML_USE_STL
|
File diff suppressed because it is too large
Load Diff
|
@ -1,71 +0,0 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "tinyXmlTest"=.\tinyXmlTest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name tinyxml
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "tinyXmlTestSTL"=.\tinyXmlTestSTL.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name tinyxmlSTL
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "tinyxml"=.\tinyxml_lib.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "tinyxmlSTL"=.\tinyxmlSTL.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,44 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C++ Express 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTest", "tinyXmlTest.vcproj", "{34719950-09E8-457E-BE23-8F1CE3A1F1F6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C406DAEC-0886-4771-8DEA-9D7329B46CC1} = {C406DAEC-0886-4771-8DEA-9D7329B46CC1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXmlTestSTL", "tinyXmlTestSTL.vcproj", "{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{A3A84737-5017-4577-B8A2-79429A25B8B6} = {A3A84737-5017-4577-B8A2-79429A25B8B6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml_lib.vcproj", "{C406DAEC-0886-4771-8DEA-9D7329B46CC1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxmlSTL", "tinyxmlSTL.vcproj", "{A3A84737-5017-4577-B8A2-79429A25B8B6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{34719950-09E8-457E-BE23-8F1CE3A1F1F6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{34719950-09E8-457E-BE23-8F1CE3A1F1F6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{34719950-09E8-457E-BE23-8F1CE3A1F1F6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{34719950-09E8-457E-BE23-8F1CE3A1F1F6}.Release|Win32.Build.0 = Release|Win32
|
||||
{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{53ED5965-5BCA-47B5-9EB0-EDD20882F22F}.Release|Win32.Build.0 = Release|Win32
|
||||
{C406DAEC-0886-4771-8DEA-9D7329B46CC1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C406DAEC-0886-4771-8DEA-9D7329B46CC1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C406DAEC-0886-4771-8DEA-9D7329B46CC1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C406DAEC-0886-4771-8DEA-9D7329B46CC1}.Release|Win32.Build.0 = Release|Win32
|
||||
{A3A84737-5017-4577-B8A2-79429A25B8B6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{A3A84737-5017-4577-B8A2-79429A25B8B6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{A3A84737-5017-4577-B8A2-79429A25B8B6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{A3A84737-5017-4577-B8A2-79429A25B8B6}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,126 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="tinyxmlSTL" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=tinyxmlSTL - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyxmlSTL.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyxmlSTL.mak" CFG="tinyxmlSTL - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tinyxmlSTL - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "tinyxmlSTL - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tinyxmlSTL - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "tinyxmlSTL___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "tinyxmlSTL___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_STL"
|
||||
# PROP Intermediate_Dir "Release_STL"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "TIXML_USE_STL" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release_STL\tinyxml_STL.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "tinyxmlSTL - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "tinyxmlSTL___Win32_Debug0"
|
||||
# PROP BASE Intermediate_Dir "tinyxmlSTL___Win32_Debug0"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_STL"
|
||||
# PROP Intermediate_Dir "Debug_STL"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "TIXML_USE_STL" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug_STL\tinyxmld_STL.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tinyxmlSTL - Win32 Release"
|
||||
# Name "tinyxmlSTL - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlerror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlparser.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\changes.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,278 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="tinyxmlSTL"
|
||||
ProjectGUID="{A3A84737-5017-4577-B8A2-79429A25B8B6}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug_STL"
|
||||
IntermediateDirectory=".\Debug_STL"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;TIXML_USE_STL;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug_STL/tinyxmlSTL.pch"
|
||||
AssemblerListingLocation=".\Debug_STL/"
|
||||
ObjectFile=".\Debug_STL/"
|
||||
ProgramDataBaseFileName=".\Debug_STL/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Debug_STL\tinyxmld_STL.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\Debug_STL/tinyxmlSTL.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release_STL"
|
||||
IntermediateDirectory=".\Release_STL"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TIXML_USE_STL"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\Release_STL/tinyxmlSTL.pch"
|
||||
AssemblerListingLocation=".\Release_STL/"
|
||||
ObjectFile=".\Release_STL/"
|
||||
ProgramDataBaseFileName=".\Release_STL/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Release_STL\tinyxml_STL.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\Release_STL/tinyxmlSTL.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="tinystr.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxml.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxmlerror.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxmlparser.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="tinystr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxml.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="changes.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="readme.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,130 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="tinyxml" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=tinyxml - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyxml_lib.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "tinyxml_lib.mak" CFG="tinyxml - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "tinyxml - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "tinyxml - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "tinyxml - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release\tinyxml.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "tinyxml - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\tinyxmld.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "tinyxml - Win32 Release"
|
||||
# Name "tinyxml - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlerror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxmlparser.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinystr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tinyxml.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\changes.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tutorial_gettingStarted.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,283 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="tinyxml"
|
||||
ProjectGUID="{C406DAEC-0886-4771-8DEA-9D7329B46CC1}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\Release/tinyxml_lib.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1031"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Release\tinyxml.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\Release/tinyxml_lib.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug/tinyxml_lib.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1031"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Debug\tinyxmld.lib"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
SuppressStartupBanner="true"
|
||||
OutputFile=".\Debug/tinyxml_lib.bsc"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath="tinystr.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxml.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxmlerror.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxmlparser.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="tinystr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tinyxml.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="changes.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="readme.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tutorial_gettingStarted.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
// The goal of the seperate error file is to make the first
|
||||
// step towards localization. tinyxml (currently) only supports
|
||||
// english error messages, but the could now be translated.
|
||||
//
|
||||
// It also cleans up the code a bit.
|
||||
//
|
||||
|
||||
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
|
||||
{
|
||||
"No error",
|
||||
"Error",
|
||||
"Failed to open file",
|
||||
"Memory allocation failed.",
|
||||
"Error parsing Element.",
|
||||
"Failed to read Element name",
|
||||
"Error reading Element value.",
|
||||
"Error reading Attributes.",
|
||||
"Error: empty tag.",
|
||||
"Error reading end tag.",
|
||||
"Error parsing Unknown.",
|
||||
"Error parsing Comment.",
|
||||
"Error parsing Declaration.",
|
||||
"Error document empty.",
|
||||
"Error null (0) or unexpected EOF found in input stream.",
|
||||
"Error parsing CDATA.",
|
||||
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
|
||||
};
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document>
|
||||
<English name="name" value="value">The world has many languages</English>
|
||||
<Russian name="название(имя)" value="ценность">Мир имеет много языков</Russian>
|
||||
<Spanish name="el nombre" value="el valor">el mundo tiene muchos idiomas</Spanish>
|
||||
<SimplifiedChinese name="名字" value="价值">世界有很多语言</SimplifiedChinese>
|
||||
<Русский название="name" ценность="value"><имеет></Русский>
|
||||
<汉语 名字="name" 价值="value">世界有很多语言</汉语>
|
||||
<Heavy>"Mëtæl!"</Heavy>
|
||||
<ä>Umlaut Element</ä>
|
||||
</document>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<document>
|
||||
<English name="name" value="value">The world has many languages</English>
|
||||
<Russian name="название(имя)" value="ценность">Мир имеет много языков</Russian>
|
||||
<Spanish name="el nombre" value="el valor">el mundo tiene muchos idiomas</Spanish>
|
||||
<SimplifiedChinese name="名字" value="价值">世界有很多语言</SimplifiedChinese>
|
||||
<Русский название="name" ценность="value"><имеет></Русский>
|
||||
<汉语 名字="name" 价值="value">世界有很多语言</汉语>
|
||||
<Heavy>"Mëtæl!"</Heavy>
|
||||
<ä>Umlaut Element</ä>
|
||||
</document>
|
File diff suppressed because it is too large
Load Diff
|
@ -135,7 +135,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
|||
aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space
|
||||
aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes
|
||||
aiProcess_ValidateDataStructure | aiProcess_ImproveCacheLocality
|
||||
| aiProcess_RemoveRedundantMaterials | aiProcess_SortByPType | aiProcess_FindDegenerates |
|
||||
| aiProcess_RemoveRedundantMaterials | aiProcess_SortByPType |
|
||||
aiProcess_FindInvalidData); // validate the output data structure
|
||||
|
||||
// get the end time of zje operation, calculate delta t
|
||||
|
|
|
@ -1354,6 +1354,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="IRRMesh"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\code\IRRMeshLoader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\IRRMeshLoader.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="PostProcess"
|
||||
|
@ -1568,8 +1580,116 @@
|
|||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="TinyXML"
|
||||
Name="irrXML"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\CXMLReaderImpl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\fast_atof.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\heapsort.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrArray.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrString.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrXML.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
BasicRuntimeChecks="0"
|
||||
SmallerTypeCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
BasicRuntimeChecks="0"
|
||||
SmallerTypeCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release_DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
BasicRuntimeChecks="0"
|
||||
SmallerTypeCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release_DLL|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug_DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
BasicRuntimeChecks="0"
|
||||
SmallerTypeCheck="false"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug_DLL|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrXML.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\code\irrXML\irrXMLWrapper.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
Loading…
Reference in New Issue