uLib  User mode C/C++ extended API library for Win32 programmers.
StringCache Class Reference

#include <uLib/StrFunc.h>

Inheritance diagram for StringCache:
WordList

Detailed Description

StringCache ia a pre-allocated string cache class.

Memory is chunk-wise allocated on demand by DupStr(), and freed by the d'tor.
StringCache is intended for memory-efficient string lists, f.ex. keyword tables,
and therefore doesn't support Unicode strings.
The Storage buffer is maintained such that it can be used for multi-string operations.

You can use MultiSzCount() if you need a count of strings in Storage.

Definition at line 704 of file StrFunc.h.

Public Data

char * Storage
 

Public Functions

 StringCache (UINT InitSize=4096, UINT ChunkSize=4096)
 
 ~StringCache ()
 
char * DupStr (char *Str)
 
void Reset ()
 
void Free ()
 
int StorageSize ()
 
int StorageUsed ()
 

Protected Member Functions

bool GrowStorage ()
 

Protected Attributes

UINT StgSize
 
UINT StgUsed
 
UINT StgChunk
 

Constructor & Destructor Documentation

◆ StringCache()

StringCache::StringCache ( UINT  InitSize = 4096,
UINT  ChunkSize = 4096 
)

Use ChunkSize strategically to minimize reallocation and slack.

Parameters
InitSizeSize of initial memory block to allocate (rounded up to nearest ChunkSize).
ChunkSizeSize of memory block to add per (re)allocation.

Definition at line 1558 of file StrFunc.cpp.

◆ ~StringCache()

StringCache::~StringCache ( )

The d'tor frees allocated Storage memory.

Definition at line 1572 of file StrFunc.cpp.

Member Function Documentation

◆ DupStr()

char * StringCache::DupStr ( char *  Str)

Copy Str into next available Storage.

Definition at line 1616 of file StrFunc.cpp.

◆ Reset()

void StringCache::Reset ( )

Un-use all memory.. No deallocation.

Definition at line 1577 of file StrFunc.cpp.

◆ Free()

void StringCache::Free ( )

Deallocate all memory.

Definition at line 1582 of file StrFunc.cpp.

◆ StorageSize()

int StringCache::StorageSize ( )
inline

Definition at line 731 of file StrFunc.h.

◆ StorageUsed()

int StringCache::StorageUsed ( )
inline

Definition at line 732 of file StrFunc.h.

◆ GrowStorage()

bool StringCache::GrowStorage ( )
protected

Definition at line 1588 of file StrFunc.cpp.

Member Data Documentation

◆ Storage

char* StringCache::Storage

Multi-string content buffer. Treat as R/O.

Definition at line 706 of file StrFunc.h.

◆ StgSize

UINT StringCache::StgSize
protected

Definition at line 735 of file StrFunc.h.

◆ StgUsed

UINT StringCache::StgUsed
protected

Definition at line 735 of file StrFunc.h.

◆ StgChunk

UINT StringCache::StgChunk
protected

Definition at line 735 of file StrFunc.h.


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