Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TLString::SData Struct Reference

Internally used by TLString to store/share strings. More...

#include <tlstring.h>

Collaboration diagram for TLString::SData:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void DownSizeIfNeeded (size_t s)
void _EnsureSize (size_t s)
void _DoTightenSize ()
void EnsureSize (size_t s)
void TightenSize ()
 SData (const char *str)
 SData (const char *str, size_t len)
 SData (const SData &s)
 SData (size_t ensure_size)
 Create internal data with at least passed size.

 ~SData ()
 Destroy internal data freeing the string memory.


Static Public Member Functions

size_t RoundUp (size_t s)
 Round up for allocation: next higher 8 byte boundary.

size_t GrowRoundUp (size_t s)

Public Attributes

AtomicInt refcnt
 used for reference counting

char * str
 NUL-terminated string is stored here.

size_t len
 length of string; s[l]=NUL.

size_t asize
 amount of memory allocated under str[].


Detailed Description

Internally used by TLString to store/share strings.

Definition at line 62 of file tlstring.h.


Constructor & Destructor Documentation

TLString::SData::SData const char *  str  ) 
 

Create internal data and store passed string (!=NULL) in there. Created with ref count 1!

Definition at line 77 of file tlstring.cc.

References asize, len, RoundUp(), and str.

TLString::SData::SData const char *  str,
size_t  len
 

Definition at line 86 of file tlstring.cc.

References asize, len, RoundUp(), and str.

TLString::SData::SData const SData s  ) 
 

Create internal data by _copying_ passed data. Created with ref count 1!

Definition at line 95 of file tlstring.cc.

References asize, len, RoundUp(), and str.

TLString::SData::SData size_t  ensure_size  ) 
 

Create internal data with at least passed size.

Definition at line 104 of file tlstring.cc.

References asize, GrowRoundUp(), len, and str.

TLString::SData::~SData  )  [inline]
 

Destroy internal data freeing the string memory.

Definition at line 110 of file tlstring.h.

References FREE(), and str.


Member Function Documentation

void TLString::SData::_DoTightenSize  ) 
 

For internal use only.

Internally used by TightenSize().

Definition at line 50 of file tlstring.cc.

References asize, Assert, len, REALLOC(), refcnt, str, and AtomicInt::val().

Referenced by TightenSize().

void TLString::SData::_EnsureSize size_t  s  ) 
 

For internal use only.

Internally used by EnsureSize().

Definition at line 33 of file tlstring.cc.

References asize, Assert, GrowRoundUp(), REALLOC(), refcnt, str, and AtomicInt::val().

Referenced by TLString::append(), EnsureSize(), and TLString::prepend().

void TLString::SData::DownSizeIfNeeded size_t  s  ) 
 

Make allocated chunk smaller if too much memory is allocated. Only call if refcnt=1.

Definition at line 60 of file tlstring.cc.

References asize, Assert, GrowRoundUp(), REALLOC(), refcnt, str, and AtomicInt::val().

Referenced by TLString::ParseString(), TLString::skip(), and TLString::trunc().

void TLString::SData::EnsureSize size_t  s  )  [inline]
 

Make sure that the passed amount of data can be stored. Only call if refcnt=1.

Definition at line 92 of file tlstring.h.

References _EnsureSize(), and asize.

Referenced by TLString::vsprintf().

size_t TLString::SData::GrowRoundUp size_t  s  )  [inline, static]
 

Size of growing string; Call when re-allocating the pointer, so allocat a bit too much so that we probably need not realloc the next time.

Definition at line 78 of file tlstring.h.

References RoundUp().

Referenced by _EnsureSize(), DownSizeIfNeeded(), and SData().

size_t TLString::SData::RoundUp size_t  s  )  [inline, static]
 

Round up for allocation: next higher 8 byte boundary.

Definition at line 70 of file tlstring.h.

Referenced by GrowRoundUp(), and SData().

void TLString::SData::TightenSize  )  [inline]
 

Make sure the size is as small as possible. Only call if refcnt=1.

Definition at line 97 of file tlstring.h.

References _DoTightenSize(), asize, and len.

Referenced by TLString::TightenSize().


Member Data Documentation

size_t TLString::SData::asize
 

amount of memory allocated under str[].

Definition at line 67 of file tlstring.h.

Referenced by _DoTightenSize(), _EnsureSize(), DownSizeIfNeeded(), EnsureSize(), TLString::ParseString(), SData(), TightenSize(), TLString::TightenSize(), and TLString::vsprintf().

size_t TLString::SData::len
 

length of string; s[l]=NUL.

Definition at line 66 of file tlstring.h.

Referenced by _DoTightenSize(), TLString::append(), TLString::compare(), TLString::find(), TLString::index(), TLString::length(), TLString::operator[](), TLString::ParseString(), TLString::prepend(), TLString::rfind(), TLString::rindex(), SData(), TLString::skip(), TightenSize(), TLString::TLString(), TLString::trunc(), TLString::vsprintf(), and TLString::zero().

AtomicInt TLString::SData::refcnt
 

used for reference counting

Definition at line 64 of file tlstring.h.

Referenced by TLString::_aqref(), TLString::_aqrefN(), TLString::_deref(), TLString::_derefN(), TLString::_detachN(), _DoTightenSize(), _EnsureSize(), DownSizeIfNeeded(), TLString::skip(), TLString::TightenSize(), TLString::trunc(), TLString::vsprintf(), and TLString::zero().

char* TLString::SData::str
 

NUL-terminated string is stored here.

Definition at line 65 of file tlstring.h.

Referenced by _DoTightenSize(), _EnsureSize(), TLString::append(), TLString::compare(), DownSizeIfNeeded(), TLString::find(), TLString::index(), TLString::operator[](), TLString::ParseString(), TLString::prepend(), TLString::rfind(), TLString::rindex(), SData(), TLString::skip(), TLString::str(), TLString::TLString(), TLString::trunc(), TLString::vsprintf(), TLString::zero(), and ~SData().


The documentation for this struct was generated from the following files:
Generated on Sat Feb 19 22:35:53 2005 for Ray by doxygen 1.3.5