Logo Search packages:      
Sourcecode: wvstreams version File versions

WvString Class Reference

#include <wvstring.h>

Inheritance diagram for WvString:


List of all members.

Detailed Description

WvString is an implementation of a simple and efficient printable-string class. It leaves out many of the notational conveniences provided by other string classes, because they waste too much CPU time and space.

It does the one thing really missing from char* strings, that is, dynamic buffer management.

When you copy one WvString to another, it does _not_ duplicate the buffer; it just creates another pointer to it. To really duplicate the buffer, call the unique() member function.

To change the contents of a WvString, you need to run its edit() member function, which executes unique() and then returns a char* pointer to the WvString contents.

The most annoying side-effect of this implementation is that if you construct a WvString from a char* buffer or static string, WvString won't duplicate it. Usually this is okay and much faster (for example, if you just want to print a static string). However, if you construct a WvString from a dynamic variable, changing the dynamic variable will change the WvString unless you run unique() or edit(). Worse still, deleting the dynamic variable will make WvString act unpredictably.

But it does cut out extra dynamic memory allocation for the most common cases, and it almost always avoids manual 'new' and 'delete' of string objects.

Definition at line 301 of file wvstring.h.

Public Member Functions

WvStringappend (WvStringParm s)
const char * cstr () const
char * edit ()
const WvFastStringifnull (WvStringParm defval) const
bool isnull () const
size_t len () const
int num () const
 operator const char * () const
 operator QString () const
bool operator! () const
bool operator!= (const char *s2) const
bool operator!= (WvStringParm s2) const
const char * operator+ (int i) const
const char * operator- (int i) const
bool operator< (const char *s2) const
bool operator< (WvStringParm s2) const
WvStringoperator= (const char *s2)
WvStringoperator= (const WvFastString &s2)
WvStringoperator= (int i)
bool operator== (const char *s2) const
bool operator== (WvStringParm s2) const
void setsize (size_t i)
WvStringunique ()
 WvString (const QCString &)
 WvString (const QString &)
 WvString (const char *_str)
 WvString (const WvFastString &s)
 WvString (const WvString &s)
 WvString (double i)
 WvString (unsigned long long i)
 WvString (long long i)
 WvString (unsigned long i)
 WvString (long i)
 WvString (unsigned int i)
 WvString (int i)
 WvString (unsigned short i)
 WvString (short i)

Static Public Member Functions

static void do_format (WvFastString &output, const char *format, const WvFastString *const *a)

Static Public Attributes

static const WvString empty
static const WvFastString null

Protected Member Functions

WvStringBuf * alloc (size_t size)
void copy_constructor (const WvFastString &s)
void link (WvStringBuf *_buf, const char *_str)
void newbuf (size_t size)
void unlink ()

Protected Attributes

WvStringBuf * buf
char * str

Static Protected Attributes

static WvStringBuf nullbuf = { 0, 1 }

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index