Your ship <col=yellow><var>this.name</var></col> was destroyed by <col=yellow><var>killer.name</var></col> in sector <col=yellow></var>this.sector.name</var></col>.
Parsing some simple markup and displaaying it
I was wondering what would be the best way to quickly parse a string to pull out formatting data, and then be able to format it quickly later with some sort of error handeling (eg if the format string expects a .name atribute and the object passed doesnt have that attribute). The format of the script does not have to be as describe here, just able to achive the same effect.
Eg I have that following string:
Then when a ship killed I need to pass the info to the renderer (ie the two ship objects involed) so that it can render some text from the above format string on the screen (wrapping to multiple lines correctly if it wont fit within the avaible width). The ship objects have methods like string GetName() and Sector GetSector() (and a GetName for the sector object too) for accessing the info about them.
I'm using d3d9 and d3d10 with c++ and am currently using the D3DX Font interfaces for text rendering.
Previously I was hardcoding such format stuff but then regretted it when trying to implement the large number of diffrently formatted strings for log entries and mission breifings and stuff like that.
[Edited by - Fire Lancer on June 7, 2009 1:45:11 PM]
I have no idea what programming language you're working in, but I'm going to guess C++. Have you looked into Boost.Spirit? It's a pretty powerful, yet relatively simple tool.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement