string replacement upgrade

From: Amos Jeffries <>
Date: Tue, 08 May 2007 00:42:42 +1200

To allow for easy future updates to the string handling within squid we
adopt the std::string API as the basis for string operations.

This patch reverts the SquidString.h file to provide the main API and
hooks for any string implementation behind the API.

For Release 3.0 the old String (now SqString) will remain the default
string core. That code has been kept in this patch with some minor
modifications and bug fixes as listed below.

For Release 3.1 it is expected that a better string core will be developed.

Reasons for these changes:

The initial String implementation was incomplete and non-standard
causing some risky operations at points in the code and duplicated some
std::string provides a better known API for string handling which is
widely use amongst other string implementations beyond std::string
itself and this enables std::string or a derivative to be used in future
within squid at some future date.
String as used previously is a defined alternative to std::string in
some systems

This patch:
    - move the old String class to SqString
    - provide the well-known type of 'string' for general use
    - provides implicit conversion from char* and char[] types
    - migrate custom functions to well-known API:
        buf() -> c_str()
        clean() -> clear()
    - remove redundant functions:
        buf(char*) -> operator=(char*)
        initBuf(char*) -> operator=(char*)
        reset(char*) -> operator=(char*)
    - adds well-known API methods for safer string use:
        operator []
        operator <<
        strcmp(), strcasecmp(), etc
    - May fix bug #1088 - segmentation fault after append(char*,int)
    - Fixes several unreported char* handling bugs in String/SqString

Future work still needs to be done to unhook the core squid code from
interacting directly with several old SqString functions. Also to
complete the char* -> string conversion which appears to be incomplete
(look at all instances of c_str() in main code and see if they are
really necessary).


Received on Mon May 07 2007 - 06:42:57 MDT

This archive was generated by hypermail pre-2.1.9 : Fri Jun 01 2007 - 12:00:08 MDT