PDA

View Full Version : Parsing of Text files in Qt



shailesh
21st April 2006, 06:10
Hi guys,

I want to parse a text file in Qt. Can anybody give me some suggestions, how to proceed? I mean some good technichs....

Thanks in advance.

Regards,
Shail.

drow
21st April 2006, 07:50
Hi,
Can you give more information?:confused:
Your file is a ascii file or xml file? Is a Configuration or input/output file?
If the file is a ascii file You can use a c++ command.
If the file is a xml file You can use QtDom and QtSax class

sorry for my english:crying:

bye

jpn
21st April 2006, 08:03
What kind of text file is that?

- For XML files, see QtXml module (http://doc.trolltech.com/4.1/qtxml.html). (DOM -> QDomDocument, SAX -> QXmlSimpleReader)
- For classic INI files, see QSettings (http://doc.trolltech.com/4.1/qsettings.html) and this thread (http://www.qtcentre.org/forum/showthread.php?t=1705&post=#4).

fullmetalcoder
21st April 2006, 15:35
homemade file formats will bring more complication : you'll have to craft a routine to translate ASCII or binary data to program-readable data. This is achieved by operating with QIODevice(s) such as QTextStream and the on the data the read in file, either line by line or everything at the same time.

If you're curious enough have a look at the project parser in DevQt : converts a *.pro into a complex data structures that take care of scopes, variables and operators.