PDA

View Full Version : how to parse a text file in Qt C++ for Nokia Devices?



satya@sipl
10th September 2012, 08:19
Hi All,

I do not know parsing. I need help to parse some text files. These text files are present on server. I need to parse them to pop some message according to the user selection.

The pattern is like follows:

The below quoted text represents one of the text files on the server.

How do you discover your real purpose in life? I’m not talking about your job, your daily responsibilities, or even your long-term goals. I mean the real reason why you’re here at all — the very reason you exist. (option-1)

Perhaps you’re a rather nihilistic person who doesn’t believe you have a purpose and that life has no meaning. Doesn’t matter. Not believing that you have a purpose won’t prevent you from discovering it, just as a lack of belief in gravity won’t prevent you from tripping. All that a lack of belief will do is make it take longer, so if you’re one of those people, just change the number 20 in the title of this blog entry to 40 (or 60 if you’re really stubborn). Most likely though if you don’t believe you have a purpose, then you probably won’t believe what I’m saying anyway, but even so, what’s the risk of investing an hour just in case? (option-2)

Here’s a story about Bruce Lee which sets the stage for this little exercise. A master martial artist asked Bruce to teach him everything Bruce knew about martial arts. Bruce held up two cups, both filled with liquid. “The first cup,” said Bruce, “represents all of your knowledge about martial arts. The second cup represents all of my knowledge about martial arts. If you want to fill your cup with my knowledge, you must first empty your cup of your knowledge". (option-3)

If you want to discover your true purpose in life, you must first empty your mind of all the false purposes you’ve been taught (including the idea that you may have no purpose at all). (option-4)

So how to discover your purpose in life? While there are many ways to do this, some of them fairly involved, here is one of the simplest that anyone can do. The more open you are to this process, and the more you expect it to work, the faster it will work for you. But not being open to it or having doubts about it or thinking it’s an entirely idiotic and meaningless waste of time won’t prevent it from working as long as you stick with it — again, it will just take longer to converge. (option-5)

Here we have 5 options for user. User selects the respective options and get the respective paragraph from the above text file.
After each paragraph there is a blank line to distinguish between the messages of two different option.

Anyone there who can help me on this ground?

Thank you all in advance.

ChrisW67
10th September 2012, 08:29
What have you tried? Just reading the QFile documentation gives you the skeleton, and checking for empty (or all blank) lines is a trivial QString or QRegExp exercise.