Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Parsing a generic data file

From: Pavel Lepin <p.lepin@-------.--->
To: NULL
Date: 12/14/2007 9:39:00 AM


Jasper <notaround@d...> wrote in
<2p-dnWHym_54YPzaRVnyvAA@p...>:
> I have a structured data file of the general form shown
> below. I dont have any definition of the data. Basically
> it looks like it is hierarchical, token/data pairs defined
> by brackets and square brackets.
> 
> I would like to parse this out into some sort of data
> object(s) in C++  so that I can gain programmatic access
> to the variables.
> 
> My app is C++ so the solution must be the same. Also it
> must be very lightweight and *very* fast as I must decode
> multiple pages in realtime.

Well, representing data like that in XML is not a problem in
itself, even if you cannot define a more strict schema than
just free-form key/value pairs. The problem is that you're
probably not very likely to get the extreme performance you
seem to want with a canned parser. DOM parsers,
specifically, would be way too cumbersome for your needs.
So it's likely to boil down to either writing your own
streaming parser, or using a streaming parser like expat or
any random SAX parser out there for maximum performance,
and even then you might not get what you need.

> Would adapting an XML parser to do this be a possible
> solution?

Not enough data. Try it, profile it, there's no other way to
know.

> Any pointers/ideas/references/code snippets/observations
> appreciated.

You might want to look into S-expressions as well. You'll
save on overhead, and I believe there are some quite fast
S-expression parsers written in C and C++ out there.

-- 
...also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent