Re: pseudo-specs for a String class

From: Kinkie <gkinkie_at_gmail.com>
Date: Sun, 31 Aug 2008 22:40:43 +0200

On Sun, Aug 31, 2008 at 6:00 PM, Adrian Chadd <adrian_at_squid-cache.org> wrote:
> Do you really want to provide a 'consume' interface for a low-level
> representation of memory?
>
> I think trying to replace MemBuf with this new buffer is a bit silly.
> Sure, use it -in- MemBuf, along with all the other places that buffers
> are used.
>
> What about strtok()? Why would you want to tokenise data?

I'd like it to be used
- everywhere MemBuf is used
- everywhere a char* is used for a string
- strtok, strchr, strstr, etc to be used in the HTTP parser

All of the above with increased efficiency both in terms callers' LOC
and performance.

Given:
KBuf src="GET http://some.url/ HTTP/1.0\r\nHost: some.url\r\n\r\n"
KBuf out;

The following are expected to be equivalent:
====
u_int32_t pos=src.index('\n');
out=src.substr(0,pos);
src=src.substr(pos,-1); //to end-of-string
====
out=src.consume(src.index('\n'));
====
out=src.nextToken('\n');
====

-- 
 /kinkie
Received on Sun Aug 31 2008 - 20:40:45 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 01 2008 - 12:00:06 MDT