cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore Namespace Reference

Namespaces

namespace  Details

Classes

class  DateTime
 This class is used to get the current date and time. More...
class  THash
 This class is used to calculate the hash value for a given integer or character buffer. More...
class  AbstractLogStream
 This pure abstract interface class declares the protocol for log-stream implementation. More...
class  Logger
 This class implements a simple logger. More...
class  TBitField
 Container to handle specific bitfields. More...
class  TOptional
 This class is used to describe a value which is not valid until it will ge inited. More...
class  TSpan
 This class implements a view onto array data. More...
class  TStringBase
 This class is used to describe the inner data of a string. More...
class  TStringView
class  Variant
 This class can be used to store integer or float data with a dynamical binding. More...
class  TArray
 This template class implements a simple array with dynamic boundaries. More...
class  THashMap
 This class implements a hash map. More...
class  TList
 This template class implements a simple double linked list container. More...
class  TQueue
 This template class implements a simple queue ( works FIFO ). More...
class  TStaticArray
class  CsvReader
 This class implements a robust CSV reader that handles quoted fields and commas within quotes. More...
struct  FSSpace
 The file-system space info. More...
class  FileSystem
 This class provides some common OS-specific file operations. More...
class  TAsyncLoader
 This template class implements a simple loader which runs load requests asynchronously. More...
class  MemUtils
class  TDefaultAllocator
 This class implements the default allocator used by all container classes of the cppcore library. More...
class  TPoolAllocator
 This class implements a simple pool-based allocation scheme. More...
class  TScratchAllocator
 A simple scratch allocator. More...
class  TStackAllocator
 This class implements a simple stack-based allocation scheme. Initially you have to define its size. Each allocation will be done from this initially created pool and must be deallocated in LIFO order. All data will be released when the allocator will be released. This allocation scheme is fast and does no call any new-calls during the lifetime of the allocator pool. More...
class  RandomGenerator
 This class is used to wrap different random number generators. More...

Typedefs

using String = TStringBase<char>
typedef int32_t(* ComparisonFn) (const void *_lhs, const void *_rhs)
 The comparison function type.
using HashId = uint64_t
using ScratchAllocator = TScratchAllocator<char>

Functions

void tracePrint (const String &domain, const String &file, int line, const String &msg)
void debugPrint (const String &domain, const String &file, int line, const String &msg)
void infoPrint (const String &domain, const String &file, int line, const String &msg)
void warnPrint (const String &domain, const String &file, int line, const String &msg)
void errorPrint (const String &domain, const String &file, int line, const String &msg)
void fatalPrint (const String &domain, const String &file, int line, const String &msg)
template<class T>
int32_t compAscending (const void *lhs, const void *rhs)
 Compare two values in ascending order.
template<typename Ty>
int32_t compDescending (const void *_lhs, const void *_rhs)
 Compare two values in descending order.
template<class T>
void swap (T &v1, T &v2)
 Swaps two POD values.
void swap (uint8_t &lhs, uint8_t &rhs)
 Swaps two uint8 values.
void swap (void *v1, void *v2, size_t stride)
 Swaps two POD values bitwise.
void quicksortImpl (void *pivot, void *_data, size_t num, size_t stride, ComparisonFn func)
 Implements the quicksort algorithm.
void quicksort (void *_data, size_t num, size_t stride, ComparisonFn func)
 Implements the quicksort algorithm.
bool isSorted (const void *data, size_t num, size_t stride, ComparisonFn func)
 Checks if the data is sorted.
int32_t binSearchImpl (const void *key, const void *data, size_t num, size_t stride, ComparisonFn func)
 Implements a binary search algorithm.
template<class T>
int32_t binSearch (const T &key, const void *array, size_t num, ComparisonFn func)
 Implements a binary search algorithm.
template<class TIt>
size_t distance (TIt begin, TIt end)
 Function to calulate the distance between two iterators.
template<class T>
void ContainerClear (T &ctr, void(*DeleterFunc)(T &)=nullptr)
template<class T>
size_t align (size_t n)
 Will calculate the alignment for the given size.
static bool mersenne_twister_vector_init (unsigned int *seedPoints, size_t len)
static bool mersenne_twister_vector_update (unsigned int *const p)
unsigned int mersenne_twister ()

Variables

static constexpr unsigned int N = 624
static constexpr unsigned int M = 397

Typedef Documentation

◆ ComparisonFn

typedef int32_t(* cppcore::ComparisonFn) (const void *_lhs, const void *_rhs)

The comparison function type.

Definition at line 30 of file Sort.h.

◆ HashId

using cppcore::HashId = uint64_t

Definition at line 110 of file CPPCoreCommon.h.

◆ ScratchAllocator

Definition at line 152 of file TScratchAllocator.h.

◆ String

Definition at line 34 of file Logger.h.

Function Documentation

◆ align()

template<class T>
size_t cppcore::align ( size_t n)
inline

Will calculate the alignment for the given size.

Parameters
[in]sizehe requested size.
Returns
The aligned size.

Definition at line 36 of file MemUtils.h.

Referenced by cppcore::MemUtils::alignPtr(), and cppcore::MemUtils::isAligned().

◆ binSearch()

template<class T>
int32_t cppcore::binSearch ( const T & key,
const void * array,
size_t num,
ComparisonFn func )
inline

Implements a binary search algorithm.

Template Parameters
TThe type of the value
Parameters
keyThe key to search for
arrayThe data to search in
numThe number of elements to search
funcThe comparison function
Returns
The index of the key if found, otherwise ~index

Definition at line 187 of file Sort.h.

References binSearchImpl().

◆ binSearchImpl()

int32_t cppcore::binSearchImpl ( const void * key,
const void * data,
size_t num,
size_t stride,
ComparisonFn func )
inline

Implements a binary search algorithm.

Parameters
keyThe key to search for
dataThe data to search in
numThe number of elements to search
strideThe stride of the data, i.e. the size of each element
funcThe comparison function
Returns
The index of the key if found, otherwise ~index

Definition at line 162 of file Sort.h.

Referenced by binSearch().

◆ compAscending()

template<class T>
int32_t cppcore::compAscending ( const void * lhs,
const void * rhs )
inline

Compare two values in ascending order.

Template Parameters
TThe type of the value
Parameters
lhsThe left hand side value
rhsThe right hand side value
Returns
-1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs

Definition at line 38 of file Sort.h.

Referenced by compDescending().

◆ compDescending()

template<typename Ty>
int32_t cppcore::compDescending ( const void * _lhs,
const void * _rhs )
inline

Compare two values in descending order.

Template Parameters
TThe type of the value
Parameters
lhsThe left hand side value
rhsThe right hand side value
Returns
-1 if lhs > rhs, 0 if lhs == rhs, 1 if lhs < rhs

Definition at line 50 of file Sort.h.

References compAscending().

◆ ContainerClear()

template<class T>
void cppcore::ContainerClear ( T & ctr,
void(* DeleterFunc )(T &) = nullptr )

Definition at line 70 of file CPPCoreCommon.h.

◆ debugPrint()

void cppcore::debugPrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 283 of file Logger.cpp.

References cppcore::Logger::debug(), and cppcore::Logger::getInstance().

◆ distance()

template<class TIt>
size_t cppcore::distance ( TIt begin,
TIt end )
inline

Function to calulate the distance between two iterators.

Template Parameters
TItThe container iterator
Parameters
beginThe first container iterator
endThe second container iterator
Returns
The distance between the two iterators.

Definition at line 36 of file TAlgorithm.h.

References distance().

Referenced by distance().

◆ errorPrint()

void cppcore::errorPrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 304 of file Logger.cpp.

References cppcore::Logger::error(), and cppcore::Logger::getInstance().

◆ fatalPrint()

void cppcore::fatalPrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 311 of file Logger.cpp.

References cppcore::Logger::fatal(), and cppcore::Logger::getInstance().

◆ infoPrint()

void cppcore::infoPrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 290 of file Logger.cpp.

References cppcore::Logger::getInstance(), and cppcore::Logger::info().

◆ isSorted()

bool cppcore::isSorted ( const void * data,
size_t num,
size_t stride,
ComparisonFn func )

Checks if the data is sorted.

Parameters
dataThe data to check
numThe number of elements to check
strideThe stride of the data, i.e. the size of each element
funcThe comparison function
Returns
true if the data is sorted, false otherwise

Definition at line 140 of file Sort.h.

◆ mersenne_twister()

unsigned int cppcore::mersenne_twister ( )

◆ mersenne_twister_vector_init()

bool cppcore::mersenne_twister_vector_init ( unsigned int * seedPoints,
size_t len )
static

Definition at line 34 of file RandomGenerator.cpp.

Referenced by mersenne_twister().

◆ mersenne_twister_vector_update()

bool cppcore::mersenne_twister_vector_update ( unsigned int *const p)
static

Definition at line 49 of file RandomGenerator.cpp.

References M, and N.

Referenced by mersenne_twister().

◆ quicksort()

void cppcore::quicksort ( void * _data,
size_t num,
size_t stride,
ComparisonFn func )
inline

Implements the quicksort algorithm.

Parameters
_dataThe data to sort
numThe number of elements to sort
strideThe stride of the data, i.e. the size of each element
funcThe comparison function

Definition at line 129 of file Sort.h.

References CPPCORE_STACK_ALLOC, and quicksortImpl().

◆ quicksortImpl()

void cppcore::quicksortImpl ( void * pivot,
void * _data,
size_t num,
size_t stride,
ComparisonFn func )
inline

Implements the quicksort algorithm.

Parameters
pivotThe pivot value to start
_dataThe data to sort
numThe number of elements to sort
strideThe stride of the data, i.e. the size of each element
funcThe comparison function

Definition at line 92 of file Sort.h.

References quicksortImpl(), and swap().

Referenced by quicksort(), and quicksortImpl().

◆ swap() [1/3]

template<class T>
void cppcore::swap ( T & v1,
T & v2 )
inline

Swaps two POD values.

Template Parameters
TThe type of the value.
Parameters
v1The first value
v2The second value

Definition at line 59 of file Sort.h.

Referenced by quicksortImpl(), and swap().

◆ swap() [2/3]

void cppcore::swap ( uint8_t & lhs,
uint8_t & rhs )
inline

Swaps two uint8 values.

Parameters
v1The first value
v2The second value

Definition at line 68 of file Sort.h.

◆ swap() [3/3]

void cppcore::swap ( void * v1,
void * v2,
size_t stride )
inline

Swaps two POD values bitwise.

Parameters
lhsThe first value
rhsThe second value

Definition at line 77 of file Sort.h.

References swap().

◆ tracePrint()

void cppcore::tracePrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 276 of file Logger.cpp.

References cppcore::Logger::getInstance(), and cppcore::Logger::trace().

◆ warnPrint()

void cppcore::warnPrint ( const String & domain,
const String & file,
int line,
const String & msg )

Definition at line 297 of file Logger.cpp.

References cppcore::Logger::getInstance(), and cppcore::Logger::warn().

Variable Documentation

◆ M

unsigned int cppcore::M = 397
staticconstexpr

Definition at line 32 of file RandomGenerator.cpp.

Referenced by mersenne_twister_vector_update().

◆ N

unsigned int cppcore::N = 624
staticconstexpr

Definition at line 31 of file RandomGenerator.cpp.

Referenced by mersenne_twister(), and mersenne_twister_vector_update().