CrystalSpace

Public API Reference

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

Utilities


Modules

 Containers

Classes

class  csAnsiParser
 Helper to parse a string for ANSI codes. More...
class  csBitmaskToString
 Small helper to get a "pretty" string for a combination of bit masks. More...
struct  csCtoW
 Helper class to convert char* (UTF-8 encoded )to wchar_t* strings for use as function parameters. More...
struct  csEndianSwap4
struct  csEndianSwap8
class  csFmtDefaultReader< T >
 Standard format string source for csPrintfFormatter. More...
class  csFmtDefaultWriter< T >
 Standard formatted string destination for csPrintfFormatter. More...
struct  csOptionDescription
 Configuration option description. More...
class  csPrintfFormatter< Twriter, Treader >
 Templated class for printf()-style string formatting. More...
class  csUnicodeTransform
 Contains functions to convert between several UTF encodings. More...
struct  csVariant
 Variant, means that type of contained data is set at runtime. More...
struct  csWtoC
 Helper class to convert wchar_t* to char* (UTF-8 encoded) strings for use as function parameters. More...
struct  iCommandLineParser
 A utility class that makes it easier to parse the command line. More...
struct  iCommandLineParser
 A utility class that makes it easier to parse the command line. More...
struct  iConfigFile
 Configuration file interface. More...
struct  iConfigFile
 Configuration file interface. More...
struct  iConfigIterator
 Iterator which allows sequential access to configuration information contained in an iConfigFile object. More...
struct  iConfigIterator
 Iterator which allows sequential access to configuration information contained in an iConfigFile object. More...
struct  iConfigManager
 The configuration manager is used to make a number of iConfigFile object appear like a single object. More...
struct  iConfigManager
 The configuration manager is used to make a number of iConfigFile object appear like a single object. More...
struct  iDataBuffer
 The iDataBuffer interface can be used to exchange buffers with abstract data between plugins. More...
struct  iDataBuffer
 The iDataBuffer interface can be used to exchange buffers with abstract data between plugins. More...
struct  iObject
 This interface is an SCF interface for encapsulating csObject. More...
struct  iObjectIterator
 This is an iterator for child objects of a csObject. More...
struct  iObjectIterator
 This is an iterator for child objects of a csObject. More...
struct  iObjectNameChangeListener
 A callback that you can implement to get notified of name changes in an iObject. More...
struct  iPluginConfig
 Interface to a configurator object. More...
struct  iString
 This is a SCF-compatible interface for csString. More...
struct  iString
 This is a SCF-compatible interface for csString. More...
struct  iStringArray
 This is an SCF-compatible interface for csStringArray. More...
struct  iStringArray
 This is an SCF-compatible interface for csStringArray. More...
struct  iStringSet
 The string set is a collection of unique strings. More...
struct  iStringSet
 The string set is a collection of unique strings. More...

Defines

#define CS_BITMASKTOSTR_MASK_TABLE_BEGIN(tableName)   static const csBitmaskToString::MaskNames tableName[] = {
 Helper macro to begin a bitmask-to-name table suitable for csBitmaskToString::GetStr();.
#define CS_BITMASKTOSTR_MASK_TABLE_DEFINE(def)   {def, #def},
 Helper macro to add an entry to a bitmask-to-name table that is a #define.
#define CS_BITMASKTOSTR_MASK_TABLE_END
 Helper macro to enf a bitmask-to-name table.
#define CS_GET_CHILD_OBJECT(object, Interface)
 You can use this macro to get a child object from a csObject.
#define CS_GET_FIRST_NAMED_CHILD_OBJECT(object, Interface, name)
 This is the same as CS_GET_CHILD_OBJECT, but stops at the first object with the given name, even if it does not implement the requested interface.
#define CS_GET_NAMED_CHILD_OBJECT(object, Interface, name)
 You can use this macro to get a child object with the given name and interface from a csObject.
#define CS_UC_MAX_MAPPED   3
 A complex mapping (uppercase, lowercase, fold) for a Unicode code point expands to at maximum this number of code points.
#define CS_UC_MAX_UTF16_ENCODED   2
 An Unicode code point as UTF16 is at maximum encoded to this number of code units.
#define CS_UC_MAX_UTF32_ENCODED   1
 An Unicode code point as UTF32 is at maximum encoded to this number of code units.
#define CS_UC_MAX_UTF8_ENCODED   4
 An Unicode code point as UTF8 is at maximum encoded to this number of code units.
#define csQroundSure(x)   (int ((x) + ((x < 0) ? -0.5 : +0.5)))

Typedefs

typedef unsigned long csStringID
 An identifier for a string.
typedef uint16 utf16_char
 A single char in a UTF16 encoded string.
typedef uint32 utf32_char
 A single char in a UTF32 encoded string.
typedef uint8 utf8_char
 A single char in a UTF8 encoded string.

Enumerations

enum  { csUcMapSimple = (1 << 0) }
 Flags influencing the behaviour of MapToUpper, MapToLower and MapToFold. More...
enum  csDocumentNodeType {
  CS_NODE_DOCUMENT = 1, CS_NODE_ELEMENT, CS_NODE_COMMENT, CS_NODE_UNKNOWN,
  CS_NODE_TEXT, CS_NODE_DECLARATION
}
 Possible node types for iDocumentNode. More...
enum  csVariantType {
  CSVAR_LONG, CSVAR_BOOL, CSVAR_CMD, CSVAR_FLOAT,
  CSVAR_STRING
}
 Types that can be contained within a variant. More...

Functions

int cs_asprintf (char **, const char *,...)
 Portable implementation of asprintf().
int cs_snprintf (char *buf, size_t bufSize, const char *format,...)
 Portable implementation of snprintf().
int cs_vasprintf (char **, const char *, va_list)
 Portable implementation of vasprintf().
int cs_vsnprintf (char *, size_t, const char *, va_list)
 Portable implementation of vsnprintf().
static float csBigEndianFloat (float f)
 Convert a big-endian floating-point number to machine format.
static uint32 csBigEndianLong (uint32 l)
 Convert a long from big-endian to machine format.
static uint64 csBigEndianLongLong (uint64 l)
 Convert a longlong from big-endian to machine format.
static uint16 csBigEndianShort (uint16 s)
 Convert a short from big-endian to machine format.
static int64 csDoubleToLongLong (double d)
 Convert a double to a cross-platform 64-bit format (no endianess adjustments!).
char * csExpandName (const char *iName)
 Expand a filename if it contains shortcuts.
int csFindNearestPowerOf2 (int n)
 Finds the smallest number that is a power of two and is larger or equal to n.
void csFindReplace (char *dest, const char *src, const char *search, const char *replace, int max)
 Given src and dest, which are already allocated, copy source to dest.
static int32 csFloatToLong (float f)
 Convert a float to a cross-platform 32-bit format (no endianess adjustments!).
bool csGlobMatches (const char *fName, const char *fMask)
 Perform shell-like filename globbing (pattern matching).
bool csIsPowerOf2 (int n)
 Returns true if n is a power of two.
static float csLittleEndianFloat (float f)
 Convert a little-endian floating-point number to machine format.
static uint32 csLittleEndianLong (uint32 l)
 Convert a long from little-endian to machine format.
static uint64 csLittleEndianLongLong (uint64 l)
 Convert a longlong from little-endian to machine format.
static uint16 csLittleEndianShort (uint16 s)
 Convert a short from little-endian to machine format.
static int csLog2 (int n)
 Find the log2 of 32bit argument.
static double csLongLongToDouble (int64 i)
 Convert a 64-bit cross-platform double to native format (no endianess adjustments!).
static float csLongToFloat (int32 l)
 Convert a 32-bit cross-platform float to native format (no endianess adjustments!).
void csReplaceAll (char *dest, const char *src, const char *search, const char *replace, int max)
 Given src and dest, which are already allocated, copy source to dest.
void csSplitPath (const char *iPathName, char *oPath, size_t iPathSize, char *oName, size_t iNameSize)
 Split a pathname into separate path and name.
int csStrCaseCmp (char const *str1, char const *str2)
 Perform case-insensitive string comparison.
int csStrNCaseCmp (char const *str1, char const *str2, size_t n)
 Perform case-insensitive string comparison of the first n characters of str1 and str2.
char * csStrNew (const wchar_t *s)
 Allocate a new char [] and copy an UTF-8 version of the string into the newly allocated storage.
char * csStrNew (const char *s)
 Allocate a new char [] and copy the string into the newly allocated storage.
wchar_tcsStrNewW (const char *s)
 Allocate a new widechar [] and copy the string converted from UTF-8 into the newly allocated storage.
wchar_tcsStrNewW (const wchar_t *s)
 Allocate a new widechar [] and the string into the newly allocated storage.

Variables

csStringID const csInvalidStringID = (csStringID) ~0
 An invalid csStringID.

Notes about string formatting in CrystalSpace

printf()-style formatting in CrystalSpace is usually backed by csPrintfFormatter<>, thus you can generally expect consistent behaviour for string formatting, across all platforms supported by CS.

The format specifiers supported by csPrintfFormatter<> are basically the same as supported by glibc. Some notable aspects are summed up here.


Define Documentation

#define CS_BITMASKTOSTR_MASK_TABLE_BEGIN tableName   )     static const csBitmaskToString::MaskNames tableName[] = {
 

Helper macro to begin a bitmask-to-name table suitable for csBitmaskToString::GetStr();.

Definition at line 84 of file bitmasktostr.h.

#define CS_BITMASKTOSTR_MASK_TABLE_DEFINE def   )     {def, #def},
 

Helper macro to add an entry to a bitmask-to-name table that is a #define.

Definition at line 90 of file bitmasktostr.h.

#define CS_BITMASKTOSTR_MASK_TABLE_END
 

Value:

{0, 0}                                                \
  }
Helper macro to enf a bitmask-to-name table.

Definition at line 93 of file bitmasktostr.h.

#define CS_GET_CHILD_OBJECT object,
Interface   ) 
 

Value:

scfQueryInterfaceSafe<Interface>((object)->GetChild(               \
    scfInterfaceTraits<Interface>::GetID(),                          \
    scfInterfaceTraits<Interface>::GetVersion()))
You can use this macro to get a child object from a csObject.

The returned object will be IncRef'ed. This version requires a correctly set-up interface ID variable.

Definition at line 37 of file object.h.

#define CS_GET_FIRST_NAMED_CHILD_OBJECT object,
Interface,
name   ) 
 

Value:

scfQueryInterfaceSafe<Interface>((object)->GetChild(               \
    scfInterfaceTraits<Interface>::GetID(),                          \
    scfInterfaceTraits<Interface>::GetVersion(),                     \
    name, true))
This is the same as CS_GET_CHILD_OBJECT, but stops at the first object with the given name, even if it does not implement the requested interface.

Definition at line 56 of file object.h.

#define CS_GET_NAMED_CHILD_OBJECT object,
Interface,
name   ) 
 

Value:

scfQueryInterfaceSafe<Interface>((object)->GetChild(               \
    scfInterfaceTraits<Interface>::GetID(),                          \
    scfInterfaceTraits<Interface>::GetVersion(),                     \
    name))
You can use this macro to get a child object with the given name and interface from a csObject.

The returned object will be IncRef'ed.

Definition at line 46 of file object.h.

#define CS_UC_MAX_MAPPED   3
 

A complex mapping (uppercase, lowercase, fold) for a Unicode code point expands to at maximum this number of code points.

Definition at line 50 of file csuctransform.h.

#define CS_UC_MAX_UTF16_ENCODED   2
 

An Unicode code point as UTF16 is at maximum encoded to this number of code units.

Definition at line 40 of file csuctransform.h.

#define CS_UC_MAX_UTF32_ENCODED   1
 

An Unicode code point as UTF32 is at maximum encoded to this number of code units.

Definition at line 45 of file csuctransform.h.

#define CS_UC_MAX_UTF8_ENCODED   4
 

An Unicode code point as UTF8 is at maximum encoded to this number of code units.

Definition at line 35 of file csuctransform.h.


Typedef Documentation

typedef unsigned long csStringID
 

An identifier for a string.

This identifier is equivalent to the contents of a string: If two strings have the same content, they have get the same identifier. If they have different content, they get different identifiers.

Definition at line 36 of file strset.h.

typedef uint16 utf16_char
 

A single char in a UTF16 encoded string.

Definition at line 42 of file csunicode.h.

typedef uint32 utf32_char
 

A single char in a UTF32 encoded string.

Definition at line 44 of file csunicode.h.

typedef uint8 utf8_char
 

A single char in a UTF8 encoded string.

Definition at line 40 of file csunicode.h.


Enumeration Type Documentation

anonymous enum
 

Flags influencing the behaviour of MapToUpper, MapToLower and MapToFold.

Enumerator:
csUcMapSimple  Force 'simple' mappings, that is, at most one code point is returned.

The default 'complex' mappings can return more than one code point in some cases.

See also:
CS_UC_MAX_MAPPED

Definition at line 55 of file csuctransform.h.

enum csDocumentNodeType
 

Possible node types for iDocumentNode.

Enumerator:
CS_NODE_DOCUMENT  Document.
CS_NODE_ELEMENT  Element.
CS_NODE_COMMENT  Comment.
CS_NODE_UNKNOWN  Unknown type.
CS_NODE_TEXT  Text.
CS_NODE_DECLARATION  Declaration.

Definition at line 40 of file document.h.

enum csVariantType
 

Types that can be contained within a variant.

Enumerator:
CSVAR_LONG  long
CSVAR_BOOL  bool
CSVAR_CMD  a command
CSVAR_FLOAT  float
CSVAR_STRING  string

Definition at line 29 of file pluginconfig.h.


Function Documentation

int cs_asprintf char **  ,
const char *  ,
  ...
 

Portable implementation of asprintf().

Remarks:
Like asprintf(), the string was allocated with malloc() and needs to be freed with free().
See also:
Notes about string formatting in CrystalSpace

int cs_snprintf char *  buf,
size_t  bufSize,
const char *  format,
  ...
 

Portable implementation of snprintf().

See also:
Notes about string formatting in CrystalSpace

int cs_vasprintf char **  ,
const char *  ,
va_list 
 

Portable implementation of vasprintf().

Remarks:
Like asprintf(), the string was allocated with malloc() and needs to be freed with free().
See also:
Notes about string formatting in CrystalSpace
See also:
Notes about string formatting in CrystalSpace

int cs_vsnprintf char *  ,
size_t  ,
const char *  ,
va_list 
 

Portable implementation of vsnprintf().

See also:
Notes about string formatting in CrystalSpace

static float csBigEndianFloat float  f  )  [inline, static]
 

Convert a big-endian floating-point number to machine format.

Definition at line 79 of file csendian.h.

References csEndianSwap4::b1, csEndianSwap4::b2, csEndianSwap4::b3, and csEndianSwap4::b4.

static uint32 csBigEndianLong uint32  l  )  [inline, static]
 

Convert a long from big-endian to machine format.

Definition at line 71 of file csendian.h.

Referenced by csGetBigEndianLong(), and csSetBigEndianLong().

static uint64 csBigEndianLongLong uint64  l  )  [inline, static]
 

Convert a longlong from big-endian to machine format.

Definition at line 53 of file csendian.h.

References csEndianSwap8::b1, csEndianSwap8::b2, csEndianSwap8::b3, csEndianSwap8::b4, csEndianSwap8::b5, csEndianSwap8::b6, csEndianSwap8::b7, and csEndianSwap8::b8.

static uint16 csBigEndianShort uint16  s  )  [inline, static]
 

Convert a short from big-endian to machine format.

Definition at line 75 of file csendian.h.

Referenced by csGetBigEndianShort(), and csSetBigEndianShort().

static int64 csDoubleToLongLong double  d  )  [inline, static]
 

Convert a double to a cross-platform 64-bit format (no endianess adjustments!).

Definition at line 184 of file csendian.h.

char* csExpandName const char *  iName  ) 
 

Expand a filename if it contains shortcuts.

Currently the following macros are recognised and expanded:

 '.', '~', '..', 'drive:' (on DOS/Win32/OS2)
 
The returned filename is always absolute, i.e. it always starts from root. Return a string allocated with csStrNew().

int csFindNearestPowerOf2 int  n  ) 
 

Finds the smallest number that is a power of two and is larger or equal to n.

void csFindReplace char *  dest,
const char *  src,
const char *  search,
const char *  replace,
int  max
[inline]
 

Given src and dest, which are already allocated, copy source to dest.

But, do not copy search, instead replace that with replace string. max is size in bytes of dest.

Deprecated:
Use csReplaceAll() instead.

Definition at line 209 of file util.h.

References csReplaceAll().

static int32 csFloatToLong float  f  )  [inline, static]
 

Convert a float to a cross-platform 32-bit format (no endianess adjustments!).

Definition at line 155 of file csendian.h.

References csQroundSure.

Referenced by csSetBigEndianFloat32(), and csSetLittleEndianFloat32().

bool csGlobMatches const char *  fName,
const char *  fMask
 

Perform shell-like filename globbing (pattern matching).

The special token * matches zero or more characters, and the token ? matches exactly one character. Examples: "*a*.txt", "*a?b*", "*" Character-classes [a-z] are not understood by this function.

Remarks:
If you want case-insensitive comparison, convert fName and fMask to upper- or lower-case first.

bool csIsPowerOf2 int  n  ) 
 

Returns true if n is a power of two.

static float csLittleEndianFloat float  f  )  [inline, static]
 

Convert a little-endian floating-point number to machine format.

Definition at line 124 of file csendian.h.

References csEndianSwap4::b1, csEndianSwap4::b2, csEndianSwap4::b3, and csEndianSwap4::b4.

Referenced by csConvertEndian().

static uint32 csLittleEndianLong uint32  l  )  [inline, static]
 

Convert a long from little-endian to machine format.

Definition at line 116 of file csendian.h.

Referenced by csConvertEndian(), csGetLittleEndianLong(), and csSetLittleEndianLong().

static uint64 csLittleEndianLongLong uint64  l  )  [inline, static]
 

Convert a longlong from little-endian to machine format.

Definition at line 99 of file csendian.h.

References csEndianSwap8::b1, csEndianSwap8::b2, csEndianSwap8::b3, csEndianSwap8::b4, csEndianSwap8::b5, csEndianSwap8::b6, csEndianSwap8::b7, and csEndianSwap8::b8.

Referenced by csConvertEndian().

static uint16 csLittleEndianShort uint16  s  )  [inline, static]
 

Convert a short from little-endian to machine format.

Definition at line 120 of file csendian.h.

Referenced by csConvertEndian(), csGetLittleEndianShort(), and csSetLittleEndianShort().

static int csLog2 int  n  )  [inline, static]
 

Find the log2 of 32bit argument.

Definition at line 176 of file util.h.

Referenced by csPrintfFormatter< Twriter, Treader >::Format().

static double csLongLongToDouble int64  i  )  [inline, static]
 

Convert a 64-bit cross-platform double to native format (no endianess adjustments!).

Definition at line 196 of file csendian.h.

static float csLongToFloat int32  l  )  [inline, static]
 

Convert a 32-bit cross-platform float to native format (no endianess adjustments!).

Definition at line 166 of file csendian.h.

Referenced by csGetBigEndianFloat32(), and csGetLittleEndianFloat32().

void csReplaceAll char *  dest,
const char *  src,
const char *  search,
const char *  replace,
int  max
 

Given src and dest, which are already allocated, copy source to dest.

But, do not copy search, instead replace that with replace string. max is size in bytes of dest.

Referenced by csFindReplace().

void csSplitPath const char *  iPathName,
char *  oPath,
size_t  iPathSize,
char *  oName,
size_t  iNameSize
 

Split a pathname into separate path and name.

int csStrCaseCmp char const *  str1,
char const *  str2
 

Perform case-insensitive string comparison.

Returns a negative number if str1 is less than str2, zero if they are equal, or a positive number if str1 is greater than str2. For best portability, use function rather than strcasecmp() or stricmp().

Referenced by csStringArray::CaseInsensitiveCompare(), csStringBase::CompareNoCase(), csStringArray::FindCaseInsensitive(), CrystalSpace::DocumentHelper::NodeAttributeCompare::operator()(), and CrystalSpace::DocumentHelper::NodeNameCompare::operator()().

int csStrNCaseCmp char const *  str1,
char const *  str2,
size_t  n
 

Perform case-insensitive string comparison of the first n characters of str1 and str2.

Returns a negative number if the n-character prefix of str1 is less than str2, zero if they are equal, or a positive number if the prefix of str1 is greater than str2. For best portability, use function rather than strncasecmp() or strnicmp().

Referenced by csStringBase::CompareNoCase(), csReporterHelper::ReportV(), and csStringBase::StartsWith().

char* csStrNew const wchar_t s  ) 
 

Allocate a new char [] and copy an UTF-8 version of the string into the newly allocated storage.

char* csStrNew const char *  s  ) 
 

Allocate a new char [] and copy the string into the newly allocated storage.

This is a handy method for copying strings, in fact it is the C++ analogue of the strdup() function from string.h (strdup() is not present on some platforms). To free the pointer the caller should call delete[].

Referenced by csStringArrayElementHandler::Construct(), csPluginLoadRec::csPluginLoadRec(), csStrKey::csStrKey(), csWtoC::csWtoC(), csStringFast< LEN >::Detach(), DirectDetectionDevice::DirectDetectionDevice(), csStrKey::operator=(), csImageBase::SetName(), and csVariant::SetString().

wchar_t* csStrNewW const char *  s  ) 
 

Allocate a new widechar [] and copy the string converted from UTF-8 into the newly allocated storage.

wchar_t* csStrNewW const wchar_t s  ) 
 

Allocate a new widechar [] and the string into the newly allocated storage.

Referenced by csCtoW::csCtoW().


Variable Documentation

csStringID const csInvalidStringID = (csStringID) ~0
 

An invalid csStringID.

Definition at line 38 of file strset.h.

Referenced by csStringHash::Contains(), csGetShaderVariableFromStack(), and csSimpleRenderMesh::csSimpleRenderMesh().


Generated for Crystal Space by doxygen 1.4.4