Just a quick question:
Does anyone know of a library that will format data into an XML file?
[code]
<wall y="12" width="24"/>
<wall x="-12" width="24" angle="90"/>
<wall y="-12" width="24" angle="180"/>
<wall x="12" width="24" angle="270"/>
[/code]
for example I would open a file then call a function and pass in the name wall, y=12, width = 24 and have the program put this into an xml file, which keeping the nesting correct, as a full file might look like this:
[code]
<park name="backyard" width="24" height="24" startx="0" starty="-5" startz="0">
<obsticles>
<wall y="12" width="24"/>
<wall x="-12" width="24" angle="90"/>
<wall y="-12" width="24" angle="180"/>
<wall x="12" width="24" angle="270"/>
<ramp x="5" y="3" width="3" height="3" depth="1.5" angle="90" style="1" icon="YES" shadow="YES"/>
</obsticles>
</park>
[/code]
boost::serialisation? You might also have to use boost::archive with it.
(the only "real" experience with XML de/serialization I have is NSArchiver :( )
I'll just post [url=http://ticpp.googlecode.com/svn/docs/ticpp.html]this link[/url] in this thread.
I haven't worked with it yet, but I read about TinyXML somewhere.
don't use xml.
Yes, TinyXML is able to load/save DOM-objects from/to XML-files.
[QUOTE=ioc;17300425]don't use xml.[/QUOTE]
Care to elaborate much?
[QUOTE=ioc;17300425]don't use xml.[/QUOTE]
What a stupid thing to say.
You don't even know what kind of data he wants to store using XML (Apart from the [I]very[/I] brief examples in the OP which might not even be related). XML is great for the right type of data.
I know you are looking for a library... but it wouldn't actually be that hard to do it yourself?
You could make the library. If kept simple and bug free it could be quite popular eh?
That's a good point, it'd be good practice too.
@ioc
I'm making a level editor for a iPhone game that uses XML for it's level layout. I don't have a choice.
Thanks Zeeky, I'll have a look into this, might also be helpful for parsing existing files
Anyone got any good ideas on creating an infinitely (theortically) branched tree? I was thinking of using vectors, but I can't think of a way of implementing it to allow vectors within vectors within vectors and so on and even if I did I suppose it would be very inefficient.
[QUOTE=r4nk_;17300520]What a stupid thing to say.
You don't even know what kind of data he wants to store using XML (Apart from the [I]very[/I] brief examples in the OP which might not even be related). XML is great for the right type of data.[/QUOTE]
I'm disappointed in you. you couldn't spot the obvious troll.
[QUOTE=Mattz333;17300757]That's a good point, it'd be good practice too.
@ioc
I'm making a level editor for a iPhone game that uses XML for it's level layout. I don't have a choice.
Thanks Zeeky, I'll have a look into this, might also be helpful for parsing existing files
Anyone got any good ideas on creating an infinitely (theortically) branched tree? I was thinking of using vectors, but I can't think of a way of implementing it to allow vectors within vectors within vectors and so on and even if I did I suppose it would be very inefficient.[/QUOTE]
Is it that skating game you showed me?
[QUOTE=r4nk_;17300520]What a stupid thing to say.
You don't even know what kind of data he wants to store using XML (Apart from the [I]very[/I] brief examples in the OP which might not even be related). XML is great for the right type of data.[/QUOTE]
it doesn't even matter what type of data is going to be stored, you should never use xml for anything. there are many things everyone [url=http://code.google.com/apis/protocolbuffers/]should use[/url] [url=http://www.json.org/]over xml[/url].
[editline]05:08PM[/editline]
[QUOTE=efeX;17303987]I'm disappointed in you. you couldn't spot the obvious troll.[/QUOTE]
:rolleyes:
you should never use xml for anything.
:smugdog:
[QUOTE=nos217;17320794]Is it that skating game you showed me?[/QUOTE]
Yeah, I've decided I want to rewrite the level editor i made into a much more modular system.
[QUOTE=Jallen;17300686]I know you are looking for a library... but it wouldn't actually be that hard to do it yourself?
You could make the library. If kept simple and bug free it could be quite popular eh?[/QUOTE]
Thats what I do. XML libraries are always about 10x more complex than writing something yourself.
[QUOTE=Mattz333;17300757]
Anyone got any good ideas on creating an infinitely (theortically) branched tree? I was thinking of using vectors, but I can't think of a way of implementing it to allow vectors within vectors within vectors and so on and even if I did I suppose it would be very inefficient.[/QUOTE]
Possible general design
structure Branch {
list of Branch
}
Each branch holds a new list of branches.
Now I'm getting a really strange segfault. I've got a struct that contains a data item, which is just 2 strings, tag and value. I've got a vector that will hold all these data items but in my code that adds a data item I get a segfault.
[code]
Branch::ITEM* Branch::addData(std::string Tag, std::string Value)
{
std::cout<<"Generating item\n";
Branch::ITEM* newitem;
std::cout<< "Value = " << Value << std::endl;
newitem->value = Value;
std::cout<<"Tag = " << Tag << std::endl;
newitem->tag = Tag;
std::cout<<"Pushing to vector\n";
ITEMS.push_back(newitem);
}
[/code]
I get the segfault on value being assigned to the parameter, though the assign on the tag works fine. What could be going wrong?
You never allocate newitem.
[code]
Branch::ITEM* Branch::addData(std::string Tag, std::string Value)
{
std::cout<<"Generating item\n";
Branch::ITEM* newitem = new Branch::ITEM; // <<<<<<< THIS
std::cout<< "Value = " << Value << std::endl;
newitem->value = Value;
std::cout<<"Tag = " << Tag << std::endl;
newitem->tag = Tag;
std::cout<<"Pushing to vector\n";
ITEMS.push_back(newitem);
}
[/code]
Make sure you allocate memory to that pointer before using it, otherwise you will be writing on random memory (which the OS will not allow)
Ah yeah, stupid mistake :p
This will be nice :D.
uh, what nos?
The map maker?
[editline]05:58PM[/editline]
The game is pretty cool.
I've been working on an XML builder, allowing me to build trees and add data to them. I've just finished the print function that prints it to the console. It shouldn't be too hard to convert the function to writing to a file.
If anyone wants the source I'll post it, it's quite a nice system and almost every function will return a pointer to the branch created which can then be used later on to edit the data of a branch.
[img]http://img17.imageshack.us/img17/1691/xmlout.png[/img]
Looking very cool. Keep it up!
I imagine that designing a XML parser / coder is actually pretty darn hard.
Sorry, you need to Log In to post a reply to this thread.