CrystalSpace

Public API Reference

iStringSet Struct Reference
[Utilities]

The string set is a collection of unique strings. More...

#include <iutil/strset.h>

Inheritance diagram for iStringSet:

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual void Clear ()=0
 Remove all stored strings.
virtual bool Contains (csStringID) const =0
 Check if the set contains a string with a particular ID.
virtual bool Contains (char const *) const =0
 Check if the set contains a particular string.
virtual bool Delete (csStringID)=0
 Remove a string with the specified ID.
virtual bool Delete (char const *)=0
 Remove specified string.
virtual void Empty ()=0
 Remove all stored strings.
virtual size_t GetSize () const =0
 Get the number of elements in the hash.
virtual bool IsEmpty () const =0
 Return true if the hash is empty.
virtual const char * Request (csStringID) const =0
 Request the string corresponding to the given ID.
virtual csStringID Request (const char *)=0
 Request the numeric ID for the given string.

Detailed Description

The string set is a collection of unique strings.

Each string has an ID number. The most important operation is to request a string, which means to return the ID for the string, adding it to the collection if not already present. This is useful when you need to work with strings but want the performance characteristics of simple numeric comparisons. Rather than performing string comparisons, you instead compare the numeric string ID's.

As a convenience, the csInitializer class creates a string set at application initialization time and inserts it into the global object registry (iObjectRegistry). To obtain a reference this shared string set (which may be desirable when modules need to share string ID's), use a code snippet similar to the following:

 iObjectRegistry* object_reg = ...;
 csRef<iStringSet> strings = CS_QUERY_REGISTRY_TAG_INTERFACE(
   object_reg, "crystalspace.shared.stringset", iStringSet);

See also:
csStringHash

csStringSet

Definition at line 62 of file strset.h.


Member Function Documentation

virtual void iStringSet::Clear (  )  [pure virtual]

Remove all stored strings.

Deprecated:
Use Empty() instead.

Implemented in csScfStringSet.

virtual bool iStringSet::Contains ( csStringID   )  const [pure virtual]

Check if the set contains a string with a particular ID.

Remarks:
This is rigidly equivalent to return Request(id) != NULL, but more idomatic.

Implemented in csScfStringSet.

virtual bool iStringSet::Contains ( char const *   )  const [pure virtual]

Check if the set contains a particular string.

Implemented in csScfStringSet.

virtual bool iStringSet::Delete ( csStringID   )  [pure virtual]

Remove a string with the specified ID.

Returns:
True if a matching string was in the set; else false.

Implemented in csScfStringSet.

virtual bool iStringSet::Delete ( char const *   )  [pure virtual]

Remove specified string.

Returns:
True if a matching string was in thet set; else false.

Implemented in csScfStringSet.

virtual void iStringSet::Empty (  )  [pure virtual]

Remove all stored strings.

When new strings are registered again, new ID values will be used; the old ID's will not be re-used.

Implemented in csScfStringSet.

virtual size_t iStringSet::GetSize (  )  const [pure virtual]

Get the number of elements in the hash.

Implemented in csScfStringSet.

virtual bool iStringSet::IsEmpty (  )  const [pure virtual]

Return true if the hash is empty.

Remarks:
Rigidly equivalent to return GetSize() == 0, but more idiomatic.

Implemented in csScfStringSet.

virtual const char* iStringSet::Request ( csStringID   )  const [pure virtual]

Request the string corresponding to the given ID.

Returns:
Null if the string * has not been requested (yet), else the string corresponding to the ID.

Implemented in csScfStringSet.

virtual csStringID iStringSet::Request ( const char *   )  [pure virtual]

Request the numeric ID for the given string.

Returns:
The ID of the string.
Remarks:
Creates a new ID if the string is not yet present in the set, else returns the previously assigned ID.

Implemented in csScfStringSet.

Referenced by CS::ShaderVarName::ShaderVarName().


The documentation for this struct was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7