OMNeT++ Simulation Library  5.6.1
cStringPool Class Reference

#include <cstringpool.h>

Description

Reference-counted storage for strings.

The purpose of this class is to allow saving memory on the storage of (largely) constant strings that occur in many instances during runtime: module names, gate names, property names, keys and values, etc.

See also
cNamedObject::cNamedObject, cNamedObject::setNamePooling()

Public Member Functions

 cStringPool (const char *poolName=nullptr)
 
 ~cStringPool ()
 
const char * get (const char *s)
 
const char * peek (const char *s) const
 
void release (const char *s)
 
void dump () const
 

Constructor & Destructor Documentation

◆ cStringPool()

cStringPool ( const char *  poolName = nullptr)

Constructor.

◆ ~cStringPool()

Destructor

Member Function Documentation

◆ get()

const char* get ( const char *  s)

Returns pointer to the pooled copy of the given string, and increments its reference count. get() and release() must occur in pairs. Passing nullptr is OK.

◆ peek()

const char* peek ( const char *  s) const

Returns pointer to the pooled copy of the given string, or nullptr. Reference count is not incremented. Passing nullptr is OK.

◆ release()

void release ( const char *  s)

The parameter must a pointer returned by get(). It decrements the reference count and frees the pooled string if it reaches zero. Passing nullptr is OK.

◆ dump()

void dump ( ) const

For debug purposes.


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