#include <wvstring.h>
Inherits WvFastString.
Collaboration diagram for WvString:
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 297 of file wvstring.h.
Public Member Functions | |
WvString () | |
WvString (short i) | |
WvString (unsigned short i) | |
WvString (int i) | |
WvString (unsigned int i) | |
WvString (long i) | |
WvString (unsigned long i) | |
WvString (long long i) | |
WvString (unsigned long long i) | |
WvString (double i) | |
WvString (const WvString &s) | |
Magic copy constructor for "fast" char* strings. | |
WvString (const WvFastString &s) | |
WvString (const char *_str) | |
Create a WvString out of a char* string. | |
WvString (const QString &) | |
Create a WvString out of a Qt library QString. | |
WvString (const QCString &) | |
WvString (WVSTRING_FORMAT_DECL) | |
WvString & | append (WvStringParm s) |
WvString & | append (WVSTRING_FORMAT_DECL) |
WvString & | operator= (int i) |
WvString & | operator= (const WvFastString &s2) |
WvString & | operator= (const char *s2) |
WvString & | unique () |
make the buf and str pointers owned only by this WvString. | |
char * | edit () |
make the string editable, and return a non-const (char*) | |
void | setsize (size_t i) |
size_t | len () const |
bool | operator== (WvStringParm s2) const |
bool | operator== (const char *s2) const |
bool | operator!= (WvStringParm s2) const |
bool | operator!= (const char *s2) const |
bool | operator< (WvStringParm s2) const |
bool | operator< (const char *s2) const |
bool | operator! () const |
the not operator is 'true' if string is empty | |
const char * | operator+ (int i) const |
const char * | operator- (int i) const |
operator const char * () const | |
auto-convert WvString to (const char *), when needed. | |
const char * | cstr () const |
return a (const char *) for this string. | |
operator QString () const | |
return a Qt library QString containing the contents of this string. | |
int | num () const |
used to convert WvString to int, when needed. | |
bool | isnull () const |
returns true if this string is null | |
Static Public Member Functions | |
void | do_format (WvFastString &output, const char *format, const WvFastString *const *a) |
when this is called, we assume output.str == NULL; it will be filled. | |
Static Public Attributes | |
const WvString | empty |
const WvFastString | null |
Protected Member Functions | |
void | copy_constructor (const WvFastString &s) |
void | link (WvStringBuf *_buf, const char *_str) |
void | unlink () |
WvStringBuf * | alloc (size_t size) |
void | newbuf (size_t size) |
Protected Attributes | |
WvStringBuf * | buf |
char * | str |
Static Protected Attributes | |
WvStringBuf | nullbuf = { 0, 1 } |
|
Definition at line 303 of file wvstring.h. Referenced by append(). |
|
Definition at line 304 of file wvstring.h. |
|
Definition at line 305 of file wvstring.h. |
|
Definition at line 306 of file wvstring.h. |
|
Definition at line 307 of file wvstring.h. |
|
Definition at line 308 of file wvstring.h. |
|
Definition at line 309 of file wvstring.h. |
|
Definition at line 310 of file wvstring.h. |
|
Definition at line 311 of file wvstring.h. |
|
Definition at line 312 of file wvstring.h. |
|
Magic copy constructor for "fast" char* strings. When we copy from a "fast" string to a real WvString, we might need to allocate memory (equivalent to unique()) so the original char* can be safely changed or destroyed. Definition at line 320 of file wvstring.h. References copy_constructor(). |
|
Definition at line 322 of file wvstring.h. References copy_constructor(). |
|
Create a WvString out of a char* string. We always allocate memory and make a copy here. To avoid memory copies, you can (carefully) use a WvFastString. To just have quick parameter passing, use a WvStringParm instead. Definition at line 71 of file wvstring.cc. References WvFastString::link(), and unique(). |
|
Create a WvString out of a Qt library QString. You have to link with libwvqt.so if you want to use this. Definition at line 48 of file wvqtstring.cc. References WvFastString::link(), and unique(). |
|
Definition at line 57 of file wvqtstring.cc. References WvFastString::link(), and unique(). |
|
Definition at line 340 of file wvstring.h. References WVSTRING_FORMAT_CALL. |
|
Definition at line 172 of file wvstring.cc. References WvStringBuf::links, WvStringBuf::size, WVSTRING_EXTRA, and WVSTRINGBUF_SIZE. Referenced by WvFastString::newbuf(), and unique(). |
|
Definition at line 344 of file wvstring.h. References append(), WvString(), and WVSTRING_FORMAT_CALL. |
|
Definition at line 182 of file wvstring.cc. References WvString(), and WvStringParm. Referenced by append(), encode_hostname_as_DN(), WvEncoder::encodebufstr(), WvFtpStream::execute(), WvEncoder::flushstrstr(), WvUrl::operator WvString(), WvMatrix::printable(), set_name_entry(), sslcreator(), tcpcreator(), and wvtcl_escape(). |
|
Definition at line 59 of file wvstring.cc. References WvFastString::buf, WvFastString::link(), WvFastString::str, and unique(). Referenced by WvString(). |
|
return a (const char *) for this string. The typecast operator does this automatically when needed, but sometimes (especially with varargs like in printf()) that isn't convenient enough. Definition at line 245 of file wvstring.h. References WvFastString::str. Referenced by WvBackslashEncoder::_encode(), WvOggVorbisEncoder::add_comment(), WvOggVorbisEncoder::add_tag(), ascending(), WvMonikerRegistry::create(), WvFastString::do_format(), WvConfEmu::get(), WvConfigSectionEmu::get(), UniRegistryGen::get(), UniPStoreGen::get(), main(), mkdirp(), WvBdbHashBase::opendb(), WvFastString::operator QString(), WvBufBase< unsigned char >::putstr(), UniClientConn::readcmd(), WvConstStringBuffer::reset(), UniRegistryGen::set(), UniPStoreGen::set(), UniConfGen::str2int(), UniConfGremlin::test(), WvX509Mgr::unhexify(), WvStream::write(), WvGdbmHashBase::WvGdbmHashBase(), WvPamStream::WvPamStream(), wvtcl_escape(), and WvTaskMan::yield(). |
|
when this is called, we assume output.str == NULL; it will be filled.
Definition at line 365 of file wvstring.cc. References _max(), WvFastString::cstr(), pparse(), WvFastString::setsize(), and WvFastString::str. Referenced by WvFastString::WvFastString(). |
|
|
returns true if this string is null
Definition at line 262 of file wvstring.h. References WvFastString::str. Referenced by _wv_serialize(), UniClientGen::conncallback(), UniConfDaemonConn::deltacallback(), UniConfDaemonConn::do_get(), UniConfDaemonConn::execute(), UniConfGen::exists(), UniMountTreeGen::get(), UniPermGen::getgroup(), UniPermGen::getowner(), UniConfKey::init(), main(), UniClientConn::readcmd(), UniIniGen::refresh(), UniTempGen::set(), UniClientGen::set(), UniConfGen::str2int(), wvtcl_decode(), and WVTEST_MAIN(). |
|
Definition at line 196 of file wvstring.cc. References WvFastString::str. Referenced by WvLogFileBase::_make_prefix(), WvLogRcv::_make_prefix(), backslash_escape(), WvX509Mgr::decode(), nice_hostname(), WvUrl::operator WvString(), WvBufBase< unsigned char >::putstr(), WvConstStringBuffer::reset(), unique(), url_encode(), WvStream::write(), WvPamStream::WvPamStream(), wvtcl_unescape(), and WVTEST_MAIN(). |
|
Definition at line 163 of file wvstring.cc. References WvStringBuf::links, and WvFastString::str. Referenced by copy_constructor(), operator=(), WvFastString::operator=(), unique(), WvFastString::WvFastString(), and WvString(). |
|
Definition at line 202 of file wvstring.cc. References WvFastString::alloc(), WvStringBuf::data, WvStringBuf::links, and WvFastString::str. Referenced by operator=(), WvFastString::setsize(), and WvFastString::WvFastString(). |
|
used to convert WvString to int, when needed. we no longer provide a typecast, because it causes annoyance. Definition at line 258 of file wvstring.h. References WvFastString::str. Referenced by creator(), and WvIPRouteList::get_kernel(). |
|
auto-convert WvString to (const char *), when needed.
Definition at line 237 of file wvstring.h. References WvFastString::str. |
|
return a Qt library QString containing the contents of this string. You need to link to libwvqt.so if you use this. Definition at line 42 of file wvqtstring.cc. References WvFastString::cstr(). |
|
the not operator is 'true' if string is empty
Definition at line 313 of file wvstring.cc. References WvFastString::str. |
|
Definition at line 297 of file wvstring.cc. References WvFastString::str. |
|
Definition at line 276 of file wvstring.cc. References WvFastString::str, and WvStringParm. |
|
Definition at line 231 of file wvstring.h. References WvFastString::str. |
|
Definition at line 233 of file wvstring.h. References WvFastString::str. |
|
Definition at line 303 of file wvstring.cc. References WvFastString::str. |
|
Definition at line 282 of file wvstring.cc. References WvFastString::str, and WvStringParm. |
|
Definition at line 349 of file wvstring.h. References WvFastString::WvFastString(). |
|
Reimplemented from WvFastString. Definition at line 248 of file wvstring.cc. References WvFastString::buf, WvFastString::link(), WvFastString::str, unique(), and WvFastString::unlink(). |
|
Definition at line 239 of file wvstring.cc. References WvFastString::newbuf(), and WvFastString::unlink(). |
|
Definition at line 291 of file wvstring.cc. References WvFastString::str. |
|
Definition at line 270 of file wvstring.cc. References WvFastString::str, and WvStringParm. |
|
Definition at line 25 of file wvstring.cc. References WvFastString::newbuf(), and WvFastString::unlink(). Referenced by backslash_escape(), WvFastString::do_format(), WvProtoStream::Token::fill(), UniRegistryGen::get(), UniDefGen::get(), WvBufBase< unsigned char >::getstr(), hexdump_buffer(), WvX509Mgr::hexify(), UniConfKey::init(), metriculate(), nice_hostname(), UniConfKey::range(), rfc1123_date(), rfc822_date(), strcoll_join(), web_unescape(), and WvX509Mgr::WvX509Mgr(). |
|
make the buf and str pointers owned only by this WvString.
Definition at line 212 of file wvstring.cc. References WvFastString::alloc(), WvStringBuf::data, WvFastString::len(), WvFastString::link(), WvStringBuf::links, WvStringBuf::size, and WvFastString::unlink(). Referenced by copy_constructor(), edit(), main(), operator=(), UniIniGen::refresh(), WvString(), and wvtcl_getword(). |
|
Definition at line 153 of file wvstring.cc. References WvStringBuf::links. Referenced by operator=(), WvFastString::operator=(), WvFastString::setsize(), unique(), and WvFastString::~WvFastString(). |
|
Definition at line 90 of file wvstring.h. Referenced by copy_constructor(), operator=(), WvFastString::operator=(), and WvFastString::WvFastString(). |
|
|
|
Definition at line 13 of file wvstring.cc. Referenced by WvFastString::WvFastString(). |
|
Definition at line 12 of file wvstring.cc. Referenced by WvFastString::WvFastString(). |
|