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: proposal of new functions
Re: CParser: proposal of new functions [message #36262 is a reply to message #36260] Thu, 17 May 2012 11:31 Go to previous messageGo to previous message
omari is currently offline  omari
Messages: 266
Registered: March 2010
Experienced Member
Thank you all.

I post this message because i want to share this functions with others.

Here is an example of using functions Id2 () and ReadUntil ():
String name, date;

String str="request name: xxxxx \n request date: xxxxx";

CParser p(str);

if(p.Id2("request", "name"))
{
    p.PassChar(':');
    name=p.ReadUntil('\n');
}
else
if(p.Id2("request", "date"))
{
    p.PassChar(':');
    date=p.ReadUntil('\n');
}



and the function Id2() with a bit of comments:
bool CParser::Id2(const char *s1, const char *s2) 
{
    // get a copy of the object
	CParser p = *this;
    
    // if not found s1 or s2, return false, dont change any thing in our object
	if (!p.Id(s1)) return false;
	if (!p.Id(s2)) return false;
	
    // if found s1 and s2, set the internal pointer of our object (term) to: after s2
	*this = p;
	
	return true;
}



regards
omari.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: File locking and Serialization
Next Topic: ...nize class
Goto Forum:
  


Current Time: Fri May 17 00:44:22 CEST 2024

Total time taken to generate the page: 0.03386 seconds