neo::core Namespace Reference


Detailed Description

The core engine sub-namespace holds the core engine class and other base classes essential to all the subsystems of the engine, such as containers (arrays, hashtable, balanced trees, any), smart pointers and sorters, as well as type utility metaclasses, string utility classes and methods, and other generic utility classes and methods.


Classes

class  Activator
 Object with active/inactive state management. More...
class  Any
 Generic container for objects of any type. More...
class  Array
 Basic resizable array storage. More...
class  AVLTreeNode
 Node in AVL tree container. More...
class  AVLTreeIterator
 AVL tree iterator. More...
class  AVLTree
 Balanced binary tree container. More...
class  Config
 Configuration repository. More...
class  Core
 Core engine singleton object More...
class  GlobalObject
 Global object. More...
class  Exception
 Base exception class for all engine exceptions. More...
class  NotImplementedException
 Unimplemented method exception. More...
class  InvalidValueException
 Invalid value in method call exception. More...
class  InvalidMethodException
 Invalid method call exception. More...
class  UnreachableCodeException
 Unreachable code exception. More...
class  SystemException
 System exception. More...
class  HashString
 Hashed string. More...
class  HashTableNode
 Hash table node. More...
class  HashTableIterator
 Hash table iterator. More...
class  HashTable
 Hash table. More...
class  ListNode
 Node in list. More...
class  ListIter
 Sequential list iterator. More...
class  ListConstIter
 Sequential list const iterator. More...
class  List
 Basic double-linked list. More...
class  LocaleDictionary
 Dictionary for a single locale. More...
class  Locale
 Locale definition. More...
class  LocalizationManager
 Localization manager. More...
class  Pointer
 Smart pointer. More...
class  ScopedPointer
 Scoped pointer. More...
class  ScopedArray
 Scoped array pointer. More...
class  ProfileBlock
 Data for a profile block. More...
class  ProfileManager
 Profile manager. More...
class  Queue
 Basic queue storage. More...
class  RadixSort
 Radix sorter for primitive types. More...
class  Random
 Mersenne Twister random number generator. More...
class  RefCount
 Reference counted object base class. More...
class  RefCountDebugger
 Reference count debugger. More...
class  Resource
 Loadable named resource base class. More...
class  ResourceManager
 Resource manager More...
class  SingletonBase
 Singleton strawman class More...
class  Singleton
 Singleton base class More...
class  StackTraceData
 Stack trace data. More...
class  Timer
 Timer object providing platform-independent high-precision timing methods More...
class  TypeTraits
 Type traits. More...
class  TypeMoreTraits
 Extended type traits. More...
class  TypeInfo
 Extended type information. More...
class  StringUTF8
 UTF-8 string. More...
class  StringUTF16
 UTF-16 string. More...
class  StringUTF32
 UTF-32 string. More...
class  Noncopyable
 Traits class to enforce non-copyable types. More...
class  Comparator
 Comparator function object. More...

Enumerations

enum  Architecture { ARCHITECTURE_X86 = 0, ARCHITECTURE_X86_64 = 1, ARCHITECTURE_PPC = 2 }
 Architecture identifiers. More...
enum  Byteorder { BYTEORDER_LITTLEENDIAN = 0, BYTEORDER_BIGENDIAN = 1 }
 Machine byte order identifiers. More...
enum  CPUCaps {
  CPUCAPS_MMX = 0x00000001, CPUCAPS_FXSR = 0x00000002, CPUCAPS_SSE = 0x00000004, CPUCAPS_SSE2 = 0x00000008,
  CPUCAPS_3DNOW = 0x00000010, CPUCAPS_3DNOWEX = 0x00000020, CPUCAPS_ALTIVEC = 0x00000040, CPUCAPS_SSE3 = 0x00000080
}
 CPU capabilities. More...
enum  Platform { PLATFORM_WINDOWS, PLATFORM_LINUX, PLATFORM_MACOSX }
 Platform identifiers. More...
enum  ResourceType
 Built-in resource types Resource type identifiers for built-in resource types in the engine.

Functions

void swap (Any &lval, Any &rval)
 Swap any containers.
template<typename T>
void swap (Array< T > &lval, Array< T > &rval)
 Swap arrays.
template<typename T, typename Key, typename Cmp>
AVLTree< T, Cmp >::iterator searchBestFit (AVLTree< T, Cmp > &tree, const Key &key)
 Search tree with generic key for best fit.
template<typename T, typename Cmp>
void swap (AVLTree< T, Cmp > &lval, AVLTree< T, Cmp > &rval)
 Swap trees.
void swap (Config &lval, Config &rval)
 Swap config repositories.
template<class T>
swapByteorder (const T &val)
 Swap byte order.
template<typename T>
unsigned int hash (const T &val, size_t len=0)
 Hash value.
template<typename Key, typename T, typename Cmp>
void swap (HashTable< Key, T, Cmp > &lval, HashTable< Key, T, Cmp > &rval)
 Swap hash tables.
template<typename T>
void swap (List< T > &lval, List< T > &rval)
 Swap lists.
void beginProfile (const HashString &name)
 Begin a profiling block.
void endProfile ()
 End a profiling block.
template<typename T>
void swap (Queue< T > &lval, Queue< T > &rval)
 Swap queues.
std::string getStackTrace (int skip=0, int depth=0, const std::string &prefix="")
 Get stack trace Get strack trace as string, skipping specified number of frames and prefixing each line with given string.
void getStackTraceData (int skip, int depth, StackTraceData &data)
 Get stack trace Get stack trace as data for later conversion to string.
std::string getStackTraceFromData (StackTraceData &data, const std::string &prefix="")
 Get stack trace Get stack trace from data.
std::string::size_type explode (const std::string &str, const std::string &separators, Array< std::string > *p_result, bool allowempty=false)
 Tokenize a string.
size_t explode (char *p_str, const char *p_separators, Array< char * > *p_result, bool allowempty=false)
 Tokenize a string.
std::string strip (const std::string &str, const std::string &delimiters=" \t\n\r")
 Strip string.
std::string replace (const std::string &str, const std::string &key, const std::string &newkey, bool repeat=false)
 Replace all occurances in string.
void split (const std::string &str, const std::string &separators, std::string &left, std::string &right, bool allowempty=false)
 Split a string.
std::string merge (const core::Array< const char * > &strings, const std::string &separators)
 Merge strings.
std::string merge (const core::Array< std::string > &strings, const std::string &separators)
 Merge strings.
int toInteger (const std::string &str)
 Convert string to integer.
unsigned int toIntegerUnsigned (const std::string &str)
 Convert string to unsigned integer.
float toFloat (const std::string &str)
 Convert string to float.
std::string toString (int val, bool hex=false, bool showbase=false, unsigned int width=0, char padding= ' ')
 Convert integer to string.
std::string toString (unsigned int val, bool hex=false, bool showbase=false, unsigned int width=0, char padding= ' ')
 Convert unsigned integer to string.
std::string toString (int64_t val, bool hex=false, bool showbase=false, unsigned int width=0, char padding= ' ')
 Convert integer to string.
std::string toString (uint64_t val, bool hex=false, bool showbase=false, unsigned int width=0, char padding= ' ')
 Convert unsigned integer to string.
std::string toString (float val, bool fixed=false, unsigned int precision=0, unsigned int width=0, char padding= ' ')
 Convert float to string.
std::string timeToString (time_t time)
 Convert timestamp to string.
std::string encodeBase64 (const unsigned char *p_arr, unsigned int size)
 Encode data as base64.
void decodeBase64 (const std::string &data, unsigned char *p_arr, unsigned int *p_size)
 Decode data as base64.
template<class Derived, class Base>
ptrdiff_t castPointerOffset ()
 Calculate pointer offsets.
template<class Derived, class Base>
ptrdiff_t castPointerOffset (Derived *p_ptr)
 Calculate pointer offsets.
void swap (StringUTF8 &lval, StringUTF8 &rval)
 Swap strings.
void swap (StringUTF16 &lval, StringUTF16 &rval)
 Swap strings.
void swap (StringUTF32 &lval, StringUTF32 &rval)
 Swap strings.
StringUTF16 operator+ (const StringUTF16 &lhs, const StringUTF16 &rhs)
 Concatenate strings in UTF-16 format.
bool operator== (const StringUTF8 &lhs, const StringUTF8 &rhs)
 Compare strings in UTF-8 format.
bool operator== (const StringUTF16 &lhs, const StringUTF16 &rhs)
 Compare strings in UTF-16 format.


Enumeration Type Documentation

enum neo::core::Architecture

Identifiers for all architectures the engine supports. For compile-time selection of architecture, use the NEO_ARCH_X86, NEO_ARCH_X86_64 or NEO_ARCH_PPC preprocessor macros.

Enumerator:
ARCHITECTURE_X86  x86 (Classic 32-bit Intel-compatible CPUs)
ARCHITECTURE_X86_64  x86-64 (x86 with 64-bit extensions, like Athlon64)
ARCHITECTURE_PPC  PowerPC

enum neo::core::Byteorder

Identifiers for machine byte orders. For compile-time selection of byte order, use the NEO_ARCH_BYTEORDER_LITTLEENDIAN and NEO_ARCH_BYTEORDER_BIGENDIAN preprocessor macros.

Enumerator:
BYTEORDER_LITTLEENDIAN  Little endian
BYTEORDER_BIGENDIAN  Big endian

enum neo::core::CPUCaps

Identifiers for various CPU capabilities detected and used by the engine

Enumerator:
CPUCAPS_MMX  MMX
CPUCAPS_FXSR  FXSR
CPUCAPS_SSE  SSE
CPUCAPS_SSE2  SSE2
CPUCAPS_3DNOW  3DNow!
CPUCAPS_3DNOWEX  3DNowEx!
CPUCAPS_ALTIVEC  Altivec unit
CPUCAPS_SSE3  SSE3

enum neo::core::Platform

Platform identifiers. For compile-time platform selection, use the NEO_PLATFORM_WINDOWS, NEO_PLATFORM_LINUX and NEO_PLATFORM_MACOSX preprocessor macros

Enumerator:
PLATFORM_WINDOWS  Windows
PLATFORM_LINUX  Linux
PLATFORM_MACOSX  MacOS X


Function Documentation

void neo::core::swap ( Any &  lval,
Any &  rval 
) [inline]

Swap contents of two any containers

Parameters:
lval First container
rval Second container

template<typename T>
void neo::core::swap ( Array< T > &  lval,
Array< T > &  rval 
) [inline]

Swap two arrays of same type.

Parameters:
lval First array
rval Second array

template<typename T, typename Key, typename Cmp>
AVLTree< T, Cmp >::iterator neo::core::searchBestFit ( AVLTree< T, Cmp > &  tree,
const Key &  key 
)

Search the given tree for the object best matching the given key, which is of a generic type and does not have to be related to the tree stored type. The best matching object will be the smallest object which is equal to or larger than the given key.

The search utilizes a comparator type implementing "equal" and "less" methods

Note that the key must order the tree items in the same order as the comparison between items do as when inserting nodes into the tree, or you will not get the correct results. For example, if storing pointers to compound objects in the tree with specialized methods for comparison, and forgetting to implement comparator methods for comparing with a key of unsigned int type, the search will compare the pointer addresses with the key yielding strange results. Example of correct usage:

 struct Foo {
 int _val;
 static inline bool equal( Foo* const& p_lhs, Foo* const& p_rhs ) { return p_lhs->_val == p_rhs->_val; }
 static inline bool less( Foo* const& p_lhs, Foo* const& p_rhs ) { return p_lhs->_val < p_rhs->_val; }
 static inline bool lessequal( Foo* const& p_lhs, Foo* const& p_rhs ) { return p_lhs->_val <= p_rhs->_val; }
 static inline bool equal( Foo* const& p_lhs, const int& val ) { return p_lhs->_val == val; }
 static inline bool less( Foo* const& p_lhs, const int& val ) { return p_lhs->_val < val; }
 static inline bool lessequal( Foo* const& p_lhs, const int& val ) { return p_lhs->_val <= val; }
 }
 AVLTree< Foo*, Foo > tree;
 // ..insert items in tree
 AVLTree< Foo*, Foo >::iterator pp_node = searchBestFit( tree, 10 );
 // pp_node will now point to the Foo item with the _val equal to 10 or the
 // Foo item with the smallest _val greater than 10

Parameters:
tree The tree to search
key Key
Returns:
Iterator of best matching object. If no matching object was found, end of the tree is returned

template<typename T, typename Cmp>
void neo::core::swap ( AVLTree< T, Cmp > &  lval,
AVLTree< T, Cmp > &  rval 
) [inline]

Swap two AVL trees of same type.

Parameters:
lval First tree
rval Second tree

void neo::core::swap ( Config &  lval,
Config &  rval 
) [inline]

Swap contents of two configuration repositories

Parameters:
lval First container
rval Second container

template<class T>
T neo::core::swapByteorder ( const T &  val  )  [inline]

Swap the byte order of object

Parameters:
val Value
Returns:
Value in swapped byte order

template<typename T>
unsigned int neo::core::hash ( const T &  val,
size_t  len = 0 
) [inline]

Calculate object hash value. The engine provides specializations for hashing strings (both C-style and std::string), as well as a default fallback implementation.

Parameters:
val Value to hash
len Optional length of value, zero if not applicable
Returns:
Hash

template<typename Key, typename T, typename Cmp>
void neo::core::swap ( HashTable< Key, T, Cmp > &  lval,
HashTable< Key, T, Cmp > &  rval 
) [inline]

Swap two hash tables of same type.

Parameters:
lval First hashtable
rval Second hashtable

template<typename T>
void neo::core::swap ( List< T > &  lval,
List< T > &  rval 
) [inline]

Swap two lists of same type.

Parameters:
lval First list
rval Second list

void neo::core::beginProfile ( const HashString &  name  )  [inline]

Begin a profiling block which will be a child of the last begun block, or a root block if there was no previous block active

Parameters:
name Block name

void neo::core::endProfile (  )  [inline]

End the current profiling block and make parent block (if any) the current active block

template<typename T>
void neo::core::swap ( Queue< T > &  lval,
Queue< T > &  rval 
) [inline]

Swap two queues of same type.

Parameters:
lval First queue
rval Second queue

std::string neo::core::getStackTrace ( int  skip = 0,
int  depth = 0,
const std::string &  prefix = "" 
)

Parameters:
skip Number of frames to skip
depth Number of frames to include (0 - unlimited)
prefix String to prefix each line with
Returns:
Stack trace string

void neo::core::getStackTraceData ( int  skip,
int  depth,
StackTraceData &  data 
)

Parameters:
skip Number of frames to skip
depth Number of frames to include (0 - unlimited)
data Data object

std::string neo::core::getStackTraceFromData ( StackTraceData &  data,
const std::string &  prefix = "" 
)

Parameters:
data Data object
prefix Prefix string appended to each line
Returns:
Stack trace string

std::string::size_type neo::core::explode ( const std::string &  str,
const std::string &  separators,
Array< std::string > *  p_result,
bool  allowempty = false 
)

Tokenize a string using the given separators, storing the resulting token strings in the given array. If the allowempty flag is not set, separators at beginning and end of the input string will be ignored without generating empty tokens, and consecutive separators will be treated as one separation (no empty tokens are generated). If the flag is set, each separator char will yield a token, even if it is empty.

For example, a call to explode with input string ": :test:explode: :method::" with separators " :" will generate an array with three tokens, "test" "explode" "method"

Parameters:
str String to tokenize
separators Token delimiters
p_result Pointer to array receiving resulting tokens
allowempty Allow empty tokens flag
Returns:
Number of tokens

size_t neo::core::explode ( char *  p_str,
const char *  p_separators,
Array< char * > *  p_result,
bool  allowempty = false 
)

Tokenize a string. Modifies string argument!

See also:
explode(const std::string&,const std::string&)
Parameters:
p_str String to tokenize, null-terminated string
p_separators Token delimiters, null-terminated string
p_result Pointer to array receiving resulting tokens as null-terminated strings
allowempty Allow empty tokens flag
Returns:
Number of tokens

std::string neo::core::strip ( const std::string &  str,
const std::string &  delimiters = " \t\n\r" 
)

String leading and ending delimiter characters from the given string, returning the stripped string.

For example, a call to strip with string " : test :: strip: :" with delimiters " :" will generate the stripped string "test :: strip".

Parameters:
str Input string
delimiters Characters to strip from start and end of string, default to whitespace (space, tabs and newlines)
Returns:
Stripped string

std::string neo::core::replace ( const std::string &  str,
const std::string &  key,
const std::string &  newkey,
bool  repeat = false 
)

Replace all occurrences of key with newkey in the given string, optionally repeating replace from the last found position if the repeat flag is set.

Repeating is safe in the sense it detects if the replacment introduces an infinite extension of the string, like replacing "foo" with "foobar".

For example, a call to replace with string "test repreplacelace method", key "replace", newkey "rep" and repeat flag set will yield the string "test reprep method".

Parameters:
str String
key Key to search for
newkey New key to replace with
repeat Repeat search from last found position each time if true
Returns:
New string

void neo::core::split ( const std::string &  str,
const std::string &  separators,
std::string &  left,
std::string &  right,
bool  allowempty = false 
)

Split a string into two tokens using the first occurrence of the given separators, except for leading separators that will be ignored unless the allowempty flag is set.

For example, a call to split with input string ": :test: :split::" with separators " :" and allowempty flag not set will generate the left string "test" and the right string "split::"

Parameters:
str String to split
separators Token delimiters
left String receiving left substring
right String receiving right substring
allowempty Allow empty token flag

std::string neo::core::merge ( const core::Array< const char * > &  strings,
const std::string &  separators 
)

Merge array of string to single string with given separators (see merge method for std::string)

Parameters:
strings Array of strings
separators String to insert between strings

std::string neo::core::merge ( const core::Array< std::string > &  strings,
const std::string &  separators 
)

Merge strings by inserting separator string between them, returning the merged string.

For example, a call to merge with strings "test" "merge" "strings" with separator string "::" will result in a final merged string "test::merge::strings"

Parameters:
strings Array of strings
separators String to insert between strings

int neo::core::toInteger ( const std::string &  str  ) 

Convert string to integer. If the string begins with a 0x prefix the number will be treated as a hexadecimal number

Parameters:
str String
Returns:
Integer value, 0 if error

unsigned int neo::core::toIntegerUnsigned ( const std::string &  str  ) 

Convert string to unsigned integer. If the string begins with a 0x prefix the number will be treated as a hexadecimal number

Parameters:
str String
Returns:
Integer value, 0 if error

float neo::core::toFloat ( const std::string &  str  ) 

Parameters:
str String
Returns:
Float value, NaN if error

std::string neo::core::toString ( int  val,
bool  hex = false,
bool  showbase = false,
unsigned int  width = 0,
char  padding = ' ' 
)

Convert an integer to a string, with optional hexadecimal base and base prefix, field width and fill character

Parameters:
val Integer value
hex Hexadecimal flag
showbase Show base prefix flag
width Field width
padding Fill character

std::string neo::core::toString ( unsigned int  val,
bool  hex = false,
bool  showbase = false,
unsigned int  width = 0,
char  padding = ' ' 
)

Convert an integer to a string, with optional hexadecimal base and base prefix, field width and fill character

Parameters:
val Integer value
hex Hexadecimal flag
showbase Show base prefix flag
width Field width
padding Fill character

std::string neo::core::toString ( int64_t  val,
bool  hex = false,
bool  showbase = false,
unsigned int  width = 0,
char  padding = ' ' 
)

Convert an integer to a string, with optional hexadecimal base and base prefix, field width and fill character

Parameters:
val Integer value
hex Hexadecimal flag
showbase Show base prefix flag
width Field width
padding Fill character

std::string neo::core::toString ( uint64_t  val,
bool  hex = false,
bool  showbase = false,
unsigned int  width = 0,
char  padding = ' ' 
)

Convert an integer to a string, with optional hexadecimal base and base prefix, field width and fill character

Parameters:
val Integer value
hex Hexadecimal flag
showbase Show base prefix flag
width Field width
padding Fill character

std::string neo::core::toString ( float  val,
bool  fixed = false,
unsigned int  precision = 0,
unsigned int  width = 0,
char  padding = ' ' 
)

Convert a float to a string, with optional fixed notation, field width, precision and fill character

Parameters:
val Float value
fixed Fixed flag
precision Precision
width Field width
padding Fill character

std::string neo::core::timeToString ( time_t  time  ) 

Get a formatted string of the given timestamp

Parameters:
time Timestamp
Returns:
String

std::string neo::core::encodeBase64 ( const unsigned char *  p_arr,
unsigned int  size 
)

Parameters:
p_arr Data array
size Size of data array in bytes
Returns:
Base64 encoded string

void neo::core::decodeBase64 ( const std::string &  data,
unsigned char *  p_arr,
unsigned int *  p_size 
)

Parameters:
data Data string in base64 format
p_arr Destination array
p_size Destination size of data array in bytes

template<class Derived, class Base>
ptrdiff_t neo::core::castPointerOffset (  )  [inline]

Calculate pointer offsets using static cast

Returns:
Offset added to a Derived* when cast to a Base*

template<class Derived, class Base>
ptrdiff_t neo::core::castPointerOffset ( Derived *  p_ptr  )  [inline]

Calculate pointer offsets using dynamic cast

Parameters:
p_ptr Pointer
Returns:
Offset added to a Derived* when cast to a Base*

void neo::core::swap ( StringUTF8 &  lval,
StringUTF8 &  rval 
) [inline]

Swap contents of two UTF-8 strings

Parameters:
lval First string
rval Second string

void neo::core::swap ( StringUTF16 &  lval,
StringUTF16 &  rval 
) [inline]

Swap contents of two UTF-16 strings

Parameters:
lval First string
rval Second string

void neo::core::swap ( StringUTF32 &  lval,
StringUTF32 &  rval 
) [inline]

Swap contents of two UTF-32 strings

Parameters:
lval First string
rval Second string

StringUTF16 neo::core::operator+ ( const StringUTF16 &  lhs,
const StringUTF16 &  rhs 
) [inline]

Parameters:
rhs First string
lhs Second string
Returns:
Concatenated string

bool neo::core::operator== ( const StringUTF8 &  lhs,
const StringUTF8 &  rhs 
)

Parameters:
rhs First string
lhs Second string
Returns:
true if equal, false if not

bool neo::core::operator== ( const StringUTF16 &  lhs,
const StringUTF16 &  rhs 
)

Parameters:
rhs First string
lhs Second string
Returns:
true if equal, false if not


Generated on Sat Feb 17 20:51:01 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1