Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » CParser enhancements
CParser enhancements [message #25752] Wed, 10 March 2010 16:30 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
First a short question: is there a class like MemStream, but which owns it's memory, grows with every Put and has a capacity. Basically a Vector<char> but with all the PutNN variants so I can add ints and doubles to it?

I couldn't find any and I'll implement one latter Today.

Now, for the real subject: I've attached some little enhancements to CParser. Basically just support for getting the column. It is 1 based. There is also a GetCharSpaces function, which should maybe have a better name.

Also, I'll need a CParser with optional space skipping which does not skip over end lines. So after a Spaces(), Char('\n') can be true. I'll inherit from CParser and override Spaces0 after I get nightly build with this patch.

I have a strange deja vu about this path, like I already posted it. I hope it's not a double post Laughing.
  • Attachment: Parser.h
    (Size: 4.24KB, Downloaded 214 times)
  • Attachment: parser.cpp
    (Size: 9.56KB, Downloaded 204 times)
Re: CParser enhancements [message #25755 is a reply to message #25752] Wed, 10 March 2010 16:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 10 March 2010 10:30

First a short question: is there a class like MemStream, but which owns it's memory, grows with every Put and has a capacity. Basically a Vector<char> but with all the PutNN variants so I can add ints and doubles to it?



StringStream. Frankly, it is very common, used much more frequently than MemStream.

Mirek
Re: CParser enhancements [message #25756 is a reply to message #25752] Wed, 10 March 2010 16:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 10 March 2010 10:30


Also, I'll need a CParser with optional space skipping which does not skip over end lines. So after a Spaces(), Char('\n') can be true. I'll inherit from CParser and override Spaces0 after I get nightly build with this patch.


You can switch whitespace skipping off, then manage them yourself as you wish...

Mirek
Re: CParser enhancements [message #25757 is a reply to message #25756] Wed, 10 March 2010 16:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I do not like the implementation, it is very expensive. Also, tabs are not implemented correctly.

(And now, as I am the one unsatisfied, I have to do it myself Wink

Mirek
Re: CParser enhancements [message #25759 is a reply to message #25757] Wed, 10 March 2010 17:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
luzr wrote on Wed, 10 March 2010 10:50


(And now, as I am the one unsatisfied, I have to do it myself Wink



Which I did.

Mirek
Re: CParser enhancements [message #25760 is a reply to message #25759] Wed, 10 March 2010 17:58 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Fine by me!

The new implementation seems faster when GetColumn is used very rarely, but I think it will be considerably slower when I use it at every symbol (which I do when doing "debug mode builds").

I'll try it out.

Thank you!
Re: CParser enhancements [message #25761 is a reply to message #25760] Wed, 10 March 2010 19:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 10 March 2010 11:58

Fine by me!

The new implementation seems faster when GetColumn is used very rarely, but I think it will be considerably slower when I use it at every symbol (which I do when doing "debug mode builds").

I'll try it out.

Thank you!


Actually, the primary motivation was to remove all those column increments spread through the code - I am afraid it was too error-prone.

Mirek
Re: CParser enhancements [message #25781 is a reply to message #25761] Thu, 11 March 2010 15:14 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I'm following you example of the pointer difference, but on a function by function basis (like ReadId), to avoid all those increments.

I'll fork CParser for now into RParser. Anwyay, the addition of column info is IMO a welcome addition to the handy little CParser.
Previous Topic: FindFile::IsExecutable() [Feature request]
Next Topic: charset conversion
Goto Forum:
  


Current Time: Mon Apr 29 12:18:18 CEST 2024

Total time taken to generate the page: 0.02216 seconds