Grabbing, Converting + Storing XML Data

Started by
16 comments, last by Zahlman 14 years, 11 months ago
Quote:
If the OP were using some form of scripting or otherwise data-driving the behavior of the code itself, that would be one thing and might necessitate the need to define and change types in data.

That was my plan for the future hence why I decided to put it in now rather than rewrite it all later.
Not sure what to do now, but tinyXML shouldn't fail at that method, I don't see the problem.
Advertisement
I'm still getting unresolved external symbol errors which tell me nothing, not even trying to get the type anymore:
#pragma once#include <stdio.h>#include <boost/variant.hpp>#include <map>#include "tinyxml.h"#define SETTINGSFILE "./GameSettings.xml"class XMLParser{private:	TiXmlDocument doc;	TiXmlElement* root;public:	char * Filename;	XMLParser(char * filename) 	{		this->Filename = filename;		this->doc = TiXmlDocument(this->Filename);		doc.LoadFile();		root = doc.FirstChildElement();	}	TiXmlElement* GetRoot()	{		return root;	}		TiXmlHandle GetRootHandle()	{		return TiXmlHandle(root);	}};class GameSettings{private:	XMLParser* xml;public:	std::map<std::string, std::string> Values;	GameSettings()	{		xml = NULL; xml = new XMLParser(SETTINGSFILE);		TiXmlHandle root = xml->GetRootHandle();		TiXmlElement* elmnt = root.FirstChildElement().Element();		for(elmnt; elmnt; elmnt = elmnt->NextSiblingElement() )		{			std::string name, value; int type = 0;			value = std::string(elmnt->GetText());			name = std::string(elmnt->Value());			Values[name] = value;		}		int done = 1;	}	std::string Get(std::string element_name)	{			}	int GetInt(std::string element_name)	{	}	float GetFloat(std::string elment_name)	{	}	bool GetBool(std::string element_name)	{		// possibly provide checks for 0 or 1		return GetInt(element_name);	}};/*class GameSettings{GameSettings(){}};*/


And the errors:
Error	2	error LNK2019: unresolved external symbol "public: char const * __thiscall TiXmlElement::GetText(void)const " (?GetText@TiXmlElement@@QBEPBDXZ) referenced in function "public: __thiscall GameSettings::GameSettings(void)" (??0GameSettings@@QAE@XZ)	Game.obj	Physics SandboxError	3	error LNK2019: unresolved external symbol "public: class TiXmlHandle __thiscall TiXmlHandle::FirstChildElement(void)const " (?FirstChildElement@TiXmlHandle@@QBE?AV1@XZ) referenced in function "public: __thiscall GameSettings::GameSettings(void)" (??0GameSettings@@QAE@XZ)	Game.obj	Physics SandboxError	4	error LNK2019: unresolved external symbol "public: class TiXmlElement const * __thiscall TiXmlNode::NextSiblingElement(void)const " (?NextSiblingElement@TiXmlNode@@QBEPBVTiXmlElement@@XZ) referenced in function "public: class TiXmlElement * __thiscall TiXmlNode::NextSiblingElement(void)" (?NextSiblingElement@TiXmlNode@@QAEPAVTiXmlElement@@XZ)	Game.obj	Physics SandboxError	5	error LNK2019: unresolved external symbol "public: bool __thiscall TiXmlDocument::LoadFile(enum TiXmlEncoding)" (?LoadFile@TiXmlDocument@@QAE_NW4TiXmlEncoding@@@Z) referenced in function "public: __thiscall XMLParser::XMLParser(char *)" (??0XMLParser@@QAE@PAD@Z)	Game.obj	Physics SandboxError	6	error LNK2019: unresolved external symbol "public: void __thiscall TiXmlDocument::operator=(class TiXmlDocument const &)" (??4TiXmlDocument@@QAEXABV0@@Z) referenced in function "public: __thiscall XMLParser::XMLParser(char *)" (??0XMLParser@@QAE@PAD@Z)	Game.obj	Physics SandboxError	7	error LNK2019: unresolved external symbol "public: __thiscall TiXmlDocument::TiXmlDocument(char const *)" (??0TiXmlDocument@@QAE@PBD@Z) referenced in function "public: __thiscall XMLParser::XMLParser(char *)" (??0XMLParser@@QAE@PAD@Z)	Game.obj	Physics SandboxError	8	error LNK2019: unresolved external symbol "public: __thiscall TiXmlDocument::TiXmlDocument(void)" (??0TiXmlDocument@@QAE@XZ) referenced in function "public: __thiscall XMLParser::XMLParser(char *)" (??0XMLParser@@QAE@PAD@Z)	Game.obj	Physics SandboxError	9	error LNK2019: unresolved external symbol "public: class TiXmlElement const * __thiscall TiXmlNode::FirstChildElement(void)const " (?FirstChildElement@TiXmlNode@@QBEPBVTiXmlElement@@XZ) referenced in function "public: class TiXmlElement * __thiscall TiXmlNode::FirstChildElement(void)" (?FirstChildElement@TiXmlNode@@QAEPAVTiXmlElement@@XZ)	Game.obj	Physics SandboxError	10	error LNK2019: unresolved external symbol "public: virtual __thiscall TiXmlNode::~TiXmlNode(void)" (??1TiXmlNode@@UAE@XZ) referenced in function "public: virtual __thiscall TiXmlDocument::~TiXmlDocument(void)" (??1TiXmlDocument@@UAE@XZ)	Game.obj	Physics SandboxError	11	error LNK2001: unresolved external symbol "public: virtual void __thiscall TiXmlDocument::Print(struct _iobuf *,int)const " (?Print@TiXmlDocument@@UBEXPAU_iobuf@@H@Z)	Game.obj	Physics SandboxError	12	error LNK2001: unresolved external symbol "public: virtual char const * __thiscall TiXmlDocument::Parse(char const *,class TiXmlParsingData *,enum TiXmlEncoding)" (?Parse@TiXmlDocument@@UAEPBDPBDPAVTiXmlParsingData@@W4TiXmlEncoding@@@Z)	Game.obj	Physics SandboxError	13	error LNK2001: unresolved external symbol "protected: virtual class TiXmlNode * __thiscall TiXmlDocument::Clone(void)const " (?Clone@TiXmlDocument@@MBEPAVTiXmlNode@@XZ)	Game.obj	Physics SandboxError	14	error LNK2001: unresolved external symbol "public: virtual bool __thiscall TiXmlDocument::Accept(class TiXmlVisitor *)const " (?Accept@TiXmlDocument@@UBE_NPAVTiXmlVisitor@@@Z)	Game.obj	Physics SandboxError	15	error LNK2001: unresolved external symbol "private: static struct TiXmlString::Rep TiXmlString::nullrep_" (?nullrep_@TiXmlString@@0URep@1@A)	Game.obj	Physics SandboxError	16	fatal error LNK1120: 14 unresolved externals	C:\Users\Administrator\Documents\Visual Studio 2008\Projects\Physics Sandbox\Debug\Physics Sandbox.exe	Physics Sandbox



What is that? :S

Thanks.
Are you including the following CPP files in your project:

tinystr.cpp
tinyxml.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp

?
Quote:Original post by Zipster
Are you including the following CPP files in your project:

tinystr.cpp
tinyxml.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp

?


Didn't make a difference and the documentation says I only need:
#include "tinyxml.h"

thanks.
int screenWidth;
Settings.Get_Screen_Width(screenWidth);
Quote:Original post by alexgeek
Didn't make a difference and the documentation says I only need:
#include "tinyxml.h"

It means that to use the functionality in a source file, you only need that line. But the other .cpp files must be part of your project or available to the linker.

Are you including the .lib? I'm not sure if tinyXML uses a .lib file or the source directly, but, often times a linker error like that one occurs because the program has the header file, and thus the signature of the function, but it cannot find the definition of the function. If it can't find the signature you will often get 'invalid type' errors, where as when it has found the signature and not the definition you will often get linking errors.

I would say that you either need to include the source files or include the .lib file if tinyXML includes one.
Quote:Original post by Kylotan
Quote:Original post by alexgeek
Didn't make a difference and the documentation says I only need:
#include "tinyxml.h"

It means that to use the functionality in a source file, you only need that line. But the other .cpp files must be part of your project or available to the linker.


You might also want to read this.

This topic is closed to new replies.

Advertisement