Duckcpp 2.1.0
Duckcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
dcpp::nub Namespace Reference

Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace. More...

Classes

class  aabbox3d
 Axis aligned bounding box in 3d dimensional space. More...
 
class  array
 Self reallocating template array (like stl vector) with additional features. More...
 
class  basic_string
 Very simple string class with some useful features. More...
 
class  dimension2d
 Specifies a 2 dimensional size. More...
 
union  FloatIntUnion32
 
class  irrAllocator
 Very simple allocator implementation, containers using it can be used across dll boundaries. More...
 
class  irrAllocatorFast
 Fast allocator, only to be used in containers inside the same memory heap. More...
 
class  line2d
 2D line between two points with intersection methods. More...
 
class  line3d
 3D line between two points with intersection methods. More...
 
class  list
 Doubly linked list template. More...
 
class  map
 map template for associative arrays using a red-black tree More...
 
class  plane3d
 Template plane class with some intersection testing methods. More...
 
class  PMatrix4
 4x4 matrix. Mostly used as transformation matrix for 3d calculations. More...
 
class  quaternion
 Quaternion class for representing rotations. More...
 
class  rect
 Rectangle template. More...
 
class  triangle3d
 3d triangle template class for doing collision detection and other things. More...
 
class  vector2d
 2d vector template class with lots of operators and methods. More...
 
class  vector3d
 3d vector template class with lots of operators and methods. More...
 

Typedefs

using vector3df = vector3d< dcpp::float32_kt >
 using type alias for a dcpp::float32_kt 3d vector.
 
using vector3di = vector3d< dcpp::int32_kt >
 using type alias for an integer 3d vector.
 
using vector2df = vector2d< dcpp::float32_kt >
 using type alias for dcpp::float32_kt 2d vector.
 
using vector2di = vector2d< dcpp::int32_kt >
 using type alias for integer 2d vector.
 
using triangle3df = triangle3d< dcpp::float32_kt >
 using type alias for a dcpp::float32_kt 3d triangle.
 
using triangle3di = triangle3d< dcpp::int32_kt >
 using type alias for an integer 3d triangle.
 
using rectf = rect< dcpp::float32_kt >
 Rectangle with float values.
 
using recti = rect< dcpp::int32_kt >
 Rectangle with int values.
 
using position2df = vector2d< dcpp::float32_kt >
 
using position2di = vector2d< dcpp::int32_kt >
 
using plane3df = plane3d< dcpp::float32_kt >
 using type alias for a dcpp::float32_kt 3d plane.
 
using plane3di = plane3d< dcpp::int32_kt >
 using type alias for an integer 3d plane.
 
using matrix4 = PMatrix4< dcpp::float32_kt >
 using type alias for dcpp::float32_kt matrix
 
using line3df = line3d< dcpp::float32_kt >
 using type alias for an dcpp::float32_kt line.
 
using line3di = line3d< dcpp::int32_kt >
 using type alias for an integer line.
 
using line2df = line2d< dcpp::float32_kt >
 using type alias for an dcpp::float32_kt line.
 
using line2di = line2d< dcpp::int32_kt >
 using type alias for an integer line.
 
using string = dcpp::nub::basic_string< dcpp::char_kt >
 using type alias for character strings. Forward declaration.
 
using wstring = dcpp::nub::basic_string< wchar_t >
 using type alias for wide character strings. Forward declaration.
 
using inttofloat = union { dcpp::uint32_kt u
 
using dimension2df = dimension2d< dcpp::float32_kt >
 using type alias for an dcpp::float32_kt dimension.
 
using dimension2du = dimension2d< dcpp::uint32_kt >
 using type alias for an unsigned integer dimension.
 
using dimension2di = dimension2d< dcpp::int32_kt >
 using type alias for an integer dimension.
 
using aabbox3df = aabbox3d< dcpp::float32_kt >
 using type alias for a dcpp::float32_kt 3d bounding box.
 
using aabbox3di = aabbox3d< dcpp::int32_kt >
 using type alias for an integer 3d bounding box.
 

Enumerations

enum  EIntersectionRelation3D {
  ISREL3D_FRONT = 0 , ISREL3D_BACK , ISREL3D_PLANAR , ISREL3D_SPANNING ,
  ISREL3D_CLIPPED
}
 Enumeration for intersection relations of 3d objects.
 
enum  eLocaleID { DCPP_LOCALE_ANSI = 0 , DCPP_LOCALE_GERMAN = 1 }
 
enum  eAllocStrategy { ALLOC_STRATEGY_SAFE = 0 , ALLOC_STRATEGY_DOUBLE = 1 , ALLOC_STRATEGY_SQRT = 2 }
 defines an allocation strategy (used only by dcpp::array so far)
 

Functions

template<class S , class T >
vector3d< Toperator* (const S scalar, const vector3d< T > &vector)
 Function multiplying a scalar and a vector component-wise.
 
template<class S , class T >
vector2d< Toperator* (const S scalar, const vector2d< T > &vector)
 
template<class T >
PMatrix4< Toperator* (const T scalar, const PMatrix4< T > &mat)
 
dcpp::int32_kt isdigit (dcpp::int32_kt c)
 some standard function ( to remove dependencies )
 
DUCKCPP_API void utf8ToWchar (const char *in, wchar_t *out, const dcpp::uint64_kt len)
 Convert this utf-8-encoded string to the platform's wchar.
 
DUCKCPP_API void wcharToUtf8 (const wchar_t *in, char *out, const dcpp::uint64_kt len)
 Convert this wchar string to utf-8.
 
dcpp::float32_kt radToDeg (dcpp::float32_kt radians)
 Utility function to convert a radian value to degrees.
 
dcpp::float64_kt radToDeg (dcpp::float64_kt radians)
 Utility function to convert a radian value to degrees.
 
dcpp::float32_kt degToRad (dcpp::float32_kt degrees)
 Utility function to convert a degrees value to radians.
 
dcpp::float64_kt degToRad (dcpp::float64_kt degrees)
 Utility function to convert a degrees value to radians.
 
template<class T >
const Tmin_ (const T &a, const T &b)
 returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
 
template<class T >
const Tmin_ (const T &a, const T &b, const T &c)
 returns minimum of three values. Own implementation to get rid of the STL (VS6 problems)
 
template<class T >
const Tmax_ (const T &a, const T &b)
 returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
 
template<class T >
const Tmax_ (const T &a, const T &b, const T &c)
 returns maximum of three values. Own implementation to get rid of the STL (VS6 problems)
 
template<class T >
T abs_ (const T &a)
 returns abs of two values. Own implementation to get rid of STL (VS6 problems)
 
template<class T >
T lerp (const T &a, const T &b, const dcpp::float32_kt t)
 
template<class T >
const T clamp (const T &value, const T &low, const T &high)
 clamps a value between low and high
 
template<class T1 , class T2 >
void swap (T1 &a, T2 &b)
 swaps the content of the passed parameters
 
template<class T >
T roundingError ()
 
template<>
dcpp::float32_kt roundingError ()
 
template<>
dcpp::float64_kt roundingError ()
 
template<>
dcpp::int32_kt roundingError ()
 
template<>
dcpp::uint32_kt roundingError ()
 
template<class T >
T relativeErrorFactor ()
 
template<>
dcpp::float32_kt relativeErrorFactor ()
 
template<>
dcpp::float64_kt relativeErrorFactor ()
 
template<class T >
bool equals (const T a, const T b, const T tolerance=roundingError< T >())
 returns if a equals b, taking possible rounding errors into account
 
template<class T >
bool equalsRelative (const T a, const T b, const T factor=relativeErrorFactor< T >())
 
bool equalsByUlp (dcpp::float32_kt a, dcpp::float32_kt b, int maxUlpDiff)
 We compare the difference in ULP's (spacing between floating-point numbers, aka ULP=1 means there exists no float between).
 
bool iszero (const dcpp::float64_kt a, const dcpp::float64_kt tolerance=ROUNDING_ERROR_Float64)
 returns if a equals zero, taking rounding errors into account
 
bool iszero (const dcpp::float32_kt a, const dcpp::float32_kt tolerance=ROUNDING_ERROR_Float32)
 returns if a equals zero, taking rounding errors into account
 
bool isnotzero (const dcpp::float32_kt a, const dcpp::float32_kt tolerance=ROUNDING_ERROR_Float32)
 returns if a equals not zero, taking rounding errors into account
 
bool iszero (const dcpp::int32_kt a, const dcpp::int32_kt tolerance=0)
 returns if a equals zero, taking rounding errors into account
 
bool iszero (const dcpp::uint32_kt a, const dcpp::uint32_kt tolerance=0)
 returns if a equals zero, taking rounding errors into account
 
dcpp::int32_kt int32_min (dcpp::int32_kt a, dcpp::int32_kt b)
 
dcpp::int32_kt int32_max (dcpp::int32_kt a, dcpp::int32_kt b)
 
dcpp::int32_kt int32_clamp (dcpp::int32_kt value, dcpp::int32_kt low, dcpp::int32_kt high)
 
dcpp::uint32_kt IR (dcpp::float32_kt x)
 
dcpp::float32_kt FR (dcpp::uint32_kt x)
 Floating-point representation of an integer value.
 
dcpp::float32_kt FR (dcpp::int32_kt x)
 
REALINLINE dcpp::uint32_kt if_c_a_else_b (const dcpp::int32_kt condition, const dcpp::uint32_kt a, const dcpp::uint32_kt b)
 conditional set based on mask and arithmetic shift
 
REALINLINE dcpp::uint16_kt if_c_a_else_b (const dcpp::int16_kt condition, const dcpp::uint16_kt a, const dcpp::uint16_kt b)
 conditional set based on mask and arithmetic shift
 
REALINLINE dcpp::uint32_kt if_c_a_else_0 (const dcpp::int32_kt condition, const dcpp::uint32_kt a)
 conditional set based on mask and arithmetic shift
 
REALINLINE void setbit_cond (dcpp::uint32_kt &state, dcpp::int32_kt condition, dcpp::uint32_kt mask)
 
dcpp::float32_kt round_ (dcpp::float32_kt x)
 
REALINLINE dcpp::float32_kt squareroot (const dcpp::float32_kt f)
 
REALINLINE dcpp::float64_kt squareroot (const dcpp::float64_kt f)
 
REALINLINE dcpp::int32_kt squareroot (const dcpp::int32_kt f)
 
REALINLINE dcpp::float64_kt reciprocal_squareroot (const dcpp::float64_kt x)
 
REALINLINE dcpp::float32_kt reciprocal_squareroot (const dcpp::float32_kt f)
 
REALINLINE dcpp::int32_kt reciprocal_squareroot (const dcpp::int32_kt x)
 
REALINLINE dcpp::float32_kt reciprocal (const dcpp::float32_kt f)
 
REALINLINE dcpp::float64_kt reciprocal (const dcpp::float64_kt f)
 
REALINLINE dcpp::float32_kt reciprocal_approxim (const dcpp::float32_kt f)
 
REALINLINE dcpp::int32_kt floor32 (dcpp::float32_kt x)
 
REALINLINE dcpp::int32_kt ceil32 (dcpp::float32_kt x)
 
REALINLINE dcpp::int32_kt round32 (dcpp::float32_kt x)
 
dcpp::float32_kt Float32_max3 (const dcpp::float32_kt a, const dcpp::float32_kt b, const dcpp::float32_kt c)
 
dcpp::float32_kt Float32_min3 (const dcpp::float32_kt a, const dcpp::float32_kt b, const dcpp::float32_kt c)
 
dcpp::float32_kt fract (dcpp::float32_kt x)
 
template<class T >
void heapsink (T *array, dcpp::int32_kt element, dcpp::int32_kt max)
 Sinks an element into the heap.
 
template<class T >
void heapsort (T *array_, dcpp::int32_kt size)
 Sorts an array with size 'size' using heapsort.
 
dcpp::uint32_kt strtoul10 (const char *in, const char **out=0)
 Convert a simple string of base 10 digits into an unsigned 32 bit integer.
 
dcpp::int32_kt strtol10 (const char *in, const char **out=0)
 Convert a simple string of base 10 digits into a signed 32 bit integer.
 
dcpp::uint32_kt ctoul16 (char in)
 Convert a hex-encoded character to an unsigned integer.
 
dcpp::uint32_kt strtoul16 (const char *in, const char **out=0)
 Convert a simple string of base 16 digits into an unsigned 32 bit integer.
 
dcpp::uint32_kt strtoul8 (const char *in, const char **out=0)
 Convert a simple string of base 8 digits into an unsigned 32 bit integer.
 
dcpp::uint32_kt strtoul_prefix (const char *in, const char **out=0)
 Convert a C-style prefixed string (hex, oct, integer) into an unsigned 32 bit integer.
 
dcpp::float32_kt strtof10 (const char *in, const char **out=0)
 Converts a sequence of digits into a whole positive floating point value.
 
const charfast_atof_move (const char *in, dcpp::float32_kt &result)
 Provides a fast function for converting a string into a float.
 
float fast_atof (const char *floatAsString, const char **out=0)
 Convert a string to a floating point number.
 
dcpp::int32_kt isFileExtension (const dcpp::io::path &filename, const dcpp::io::path &ext0, const dcpp::io::path &ext1, const dcpp::io::path &ext2)
 search if a filename has a proper extension
 
bool hasFileExtension (const dcpp::io::path &filename, const dcpp::io::path &ext0, const dcpp::io::path &ext1="", const dcpp::io::path &ext2="")
 search if a filename has a proper extension
 
dcpp::io::pathcutFilenameExtension (dcpp::io::path &dest, const dcpp::io::path &source)
 cut the filename extension from a source file path and store it in a dest file path
 
dcpp::io::pathgetFileNameExtension (dcpp::io::path &dest, const dcpp::io::path &source)
 get the filename extension from a file path
 
dcpp::io::pathdeletePathFromFilename (dcpp::io::path &filename)
 delete path from filename
 
dcpp::io::pathdeletePathFromPath (dcpp::io::path &filename, dcpp::int32_kt pathCount)
 trim paths
 
dcpp::int32_kt isInSameDirectory (const dcpp::io::path &path, const dcpp::io::path &file)
 
dcpp::int32_kt isspace (dcpp::int32_kt c)
 
dcpp::int32_kt isupper (dcpp::int32_kt c)
 

Variables

DUCKCPP_API const matrix4 IdentityMatrix
 global const identity matrix
 
const dcpp::int32_kt ROUNDING_ERROR_INT32 = 0
 Rounding error constant often used when comparing dcpp::float32_kt values.
 
const dcpp::float32_kt ROUNDING_ERROR_Float32 = 0.000001f
 
const dcpp::float64_kt ROUNDING_ERROR_Float64 = 0.00000001
 
const dcpp::float32_kt PI = 3.14159265359f
 Constant for PI.
 
const dcpp::float32_kt RECIPROCAL_PI = 1.0f/PI
 Constant for reciprocal of PI.
 
const dcpp::float32_kt HALF_PI = PI/2.0f
 Constant for half of PI.
 
const dcpp::float64_kt PI64 = 3.1415926535897932384626433832795028841971693993751
 Constant for 64bit PI.
 
const dcpp::float64_kt RECIPROCAL_PI64 = 1.0/PI64
 Constant for 64bit reciprocal of PI.
 
const dcpp::float32_kt DEGTORAD = PI / 180.0f
 32bit Constant for converting from degrees to radians
 
const dcpp::float32_kt RADTODEG = 180.0f / PI
 32bit constant for converting from radians to degrees (formally known as GRAD_PI)
 
const dcpp::float64_kt DEGTORAD64 = PI64 / 180.0
 64bit constant for converting from degrees to radians (formally known as GRAD_PI2)
 
const dcpp::float64_kt RADTODEG64 = 180.0 / PI64
 64bit constant for converting from radians to degrees
 
dcpp::int32_kt s
 
dcpp::float32_kt f
 
DUCKCPP_API dcpp::nub::string LOCALE_DECIMAL_POINTS
 
const float fast_atof_table [17]
 

Detailed Description

Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.

Typedef Documentation

◆ dimension2di

using type alias for an integer dimension.

There are few cases where negative dimensions make sense. Please consider using dimension2du instead.

◆ position2df

Deprecated:
position2d is now a synonym for vector2d, but vector2d should be used directly.

◆ position2di

Deprecated:
position2d is now a synonym for vector2d, but vector2d should be used directly.

Function Documentation

◆ ctoul16()

dcpp::uint32_kt dcpp::nub::ctoul16 ( char  in)
inline

Convert a hex-encoded character to an unsigned integer.

Parameters
[in]inThe digit to convert. Only digits 0 to 9 and chars A-F,a-f will be considered.
Returns
The unsigned integer value of the digit. 0xffffffff if the input is not hex

◆ degToRad() [1/2]

dcpp::float32_kt dcpp::nub::degToRad ( dcpp::float32_kt  degrees)
inline

Utility function to convert a degrees value to radians.

Provided as it can be clearer to write degToRad(X) than DEGTORAD * X

Parameters
degreesThe degrees value to convert to radians.

◆ degToRad() [2/2]

dcpp::float64_kt dcpp::nub::degToRad ( dcpp::float64_kt  degrees)
inline

Utility function to convert a degrees value to radians.

Provided as it can be clearer to write degToRad(X) than DEGTORAD * X

Parameters
degreesThe degrees value to convert to radians.

◆ equalsRelative()

template<class T >
bool dcpp::nub::equalsRelative ( const T  a,
const T  b,
const T  factor = relativeErrorFactor<T>() 
)
inline

returns if a equals b, taking relative error in form of factor this particular function does not involve any division.

◆ fast_atof()

float dcpp::nub::fast_atof ( const char floatAsString,
const char **  out = 0 
)
inline

Convert a string to a floating point number.

Parameters
floatAsStringThe string to convert.
outOptional pointer to the first character in the string that wasn't used to create the float value.
Returns
Float value parsed from the input string

◆ fast_atof_move()

const char * dcpp::nub::fast_atof_move ( const char in,
dcpp::float32_kt result 
)
inline

Provides a fast function for converting a string into a float.

This is not guaranteed to be as accurate as atof(), but is approximately 6 to 8 times as fast.

Parameters
[in]inThe string to convert.
[out]resultThe resultant float will be written here.
Returns
Pointer to the first character in the string that wasn't used to create the float value.

◆ IR()

dcpp::uint32_kt dcpp::nub::IR ( dcpp::float32_kt  x)
inline

code is taken from IceFPU Integer representation of a floating-point value.

◆ isInSameDirectory()

dcpp::int32_kt dcpp::nub::isInSameDirectory ( const dcpp::io::path path,
const dcpp::io::path file 
)
inline

looks if file is in the same directory of path. returns offset of directory. 0 means in same directory. 1 means file is direct child of path

◆ lerp()

template<class T >
T dcpp::nub::lerp ( const T a,
const T b,
const dcpp::float32_kt  t 
)
inline

returns linear interpolation of a and b with ratio t

Returns
: a if t==0, b if t==1, and the linear interpolation else

◆ radToDeg() [1/2]

dcpp::float32_kt dcpp::nub::radToDeg ( dcpp::float32_kt  radians)
inline

Utility function to convert a radian value to degrees.

Provided as it can be clearer to write radToDeg(X) than RADTODEG * X

Parameters
radiansThe radians value to convert to degrees.

◆ radToDeg() [2/2]

dcpp::float64_kt dcpp::nub::radToDeg ( dcpp::float64_kt  radians)
inline

Utility function to convert a radian value to degrees.

Provided as it can be clearer to write radToDeg(X) than RADTODEG * X

Parameters
radiansThe radians value to convert to degrees.

◆ strtof10()

dcpp::float32_kt dcpp::nub::strtof10 ( const char in,
const char **  out = 0 
)
inline

Converts a sequence of digits into a whole positive floating point value.

Only digits 0 to 9 are parsed. Parsing stops at any other character, including sign characters or a decimal point.

Parameters
inthe sequence of digits to convert.
out(optional) will be set to point at the first non-converted character.
Returns
The whole positive floating point representation of the digit sequence.

◆ strtol10()

dcpp::int32_kt dcpp::nub::strtol10 ( const char in,
const char **  out = 0 
)
inline

Convert a simple string of base 10 digits into a signed 32 bit integer.

Parameters
[in]inThe string of digits to convert. Only a leading - or + followed by digits 0 to 9 will be considered. Parsing stops at the first non-digit.
[out]out(optional) If provided, it will be set to point at the first character not used in the calculation.
Returns
The signed integer value of the digits. If the string specifies too many digits to encode in an dcpp::int32_kt then +INT_MAX or -INT_MAX will be returned.

◆ strtoul10()

dcpp::uint32_kt dcpp::nub::strtoul10 ( const char in,
const char **  out = 0 
)
inline

Convert a simple string of base 10 digits into an unsigned 32 bit integer.

Parameters
[in]inThe string of digits to convert. No leading chars are allowed, only digits 0 to 9. Parsing stops at the first non-digit.
[out]out(optional) If provided, it will be set to point at the first character not used in the calculation.
Returns
The unsigned integer value of the digits. If the string specifies too many digits to encode in an dcpp::uint32_kt then INT_MAX will be returned.

◆ strtoul16()

dcpp::uint32_kt dcpp::nub::strtoul16 ( const char in,
const char **  out = 0 
)
inline

Convert a simple string of base 16 digits into an unsigned 32 bit integer.

Parameters
[in]inThe string of digits to convert. No leading chars are allowed, only digits 0 to 9 and chars A-F,a-f are allowed. Parsing stops at the first illegal char.
[out]out(optional) If provided, it will be set to point at the first character not used in the calculation.
Returns
The unsigned integer value of the digits. If the string specifies too many digits to encode in an dcpp::uint32_kt then INT_MAX will be returned.

◆ strtoul8()

dcpp::uint32_kt dcpp::nub::strtoul8 ( const char in,
const char **  out = 0 
)
inline

Convert a simple string of base 8 digits into an unsigned 32 bit integer.

Parameters
[in]inThe string of digits to convert. No leading chars are allowed, only digits 0 to 7 are allowed. Parsing stops at the first illegal char.
[out]out(optional) If provided, it will be set to point at the first character not used in the calculation.
Returns
The unsigned integer value of the digits. If the string specifies too many digits to encode in an dcpp::uint32_kt then INT_MAX will be returned.

◆ strtoul_prefix()

dcpp::uint32_kt dcpp::nub::strtoul_prefix ( const char in,
const char **  out = 0 
)
inline

Convert a C-style prefixed string (hex, oct, integer) into an unsigned 32 bit integer.

Parameters
[in]inThe string of digits to convert. If string starts with 0x the hex parser is used, if only leading 0 is used, oct parser is used. In all other cases, the usual unsigned parser is used.
[out]out(optional) If provided, it will be set to point at the first character not used in the calculation.
Returns
The unsigned integer value of the digits. If the string specifies too many digits to encode in an dcpp::uint32_kt then INT_MAX will be returned.

◆ utf8ToWchar()

DUCKCPP_API void dcpp::nub::utf8ToWchar ( const char in,
wchar_t out,
const dcpp::uint64_kt  len 
)

Convert this utf-8-encoded string to the platform's wchar.

The resulting string is always NULL-terminated and well-formed.

Parameters
lenThe size of the output buffer in bytes.

◆ wcharToUtf8()

DUCKCPP_API void dcpp::nub::wcharToUtf8 ( const wchar_t in,
char out,
const dcpp::uint64_kt  len 
)

Convert this wchar string to utf-8.

The resulting string is always NULL-terminated and well-formed.

Parameters
lenThe size of the output buffer in bytes.

Variable Documentation

◆ fast_atof_table

const float dcpp::nub::fast_atof_table[17]
Initial value:
= {
0.f,
0.1f,
0.01f,
0.001f,
0.0001f,
0.00001f,
0.000001f,
0.0000001f,
0.00000001f,
0.000000001f,
0.0000000001f,
0.00000000001f,
0.000000000001f,
0.0000000000001f,
0.00000000000001f,
0.000000000000001f,
0.0000000000000001f
}

◆ LOCALE_DECIMAL_POINTS

DUCKCPP_API dcpp::nub::string dcpp::nub::LOCALE_DECIMAL_POINTS
extern

Selection of characters which count as decimal point in fast_atof By default Duckcpp considers "." as the decimal point in numbers. But sometimes you might run into situations where floats were written in a local format with another decimal point like ",". Best solution is usually to fix those cases by converting the input. But if you don't have that choice you can set this to ".,". WARNING: This is not thread-safe, so don't change while there's a chance of another thread using fast_atof functions at the same time.


Duckcpp    @cppfx.xyz