Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
tools.h File Reference

Legacy tooling inherited from the Cube engine. More...

Go to the source code of this file.

Classes

struct  databuf< T >
 
struct  stream
 

Macros

#define RESTRICT
 
#define __cdecl
 
#define _vsnprintf   vsnprintf
 
#define PATHDIV   '/'
 
#define RAD   static_cast<float>(180.0f / M_PI)
 
#define PRINTFARGS(fmt, args)
 
#define DEF_FORMAT_STRING(d, ...)
 
#define DEFV_FORMAT_STRING(d, last, fmt)
 

Typedefs

typedef unsigned char uchar
 
typedef unsigned short ushort
 
typedef unsigned int uint
 
typedef unsigned long ulong
 
typedef signed long long int llong
 
typedef unsigned long long int ullong
 
typedef char string[maxstrlen]
 
typedef databuf< char > charbuf
 
typedef databuf< uchar > ucharbuf
 

Functions

template<class T >
max (T a, T b)
 
template<class T >
max (T a, T b, T c)
 
template<class T >
min (T a, T b)
 
template<class T >
min (T a, T b, T c)
 
int BITSCAN (uint mask)
 
int randomint (int x)
 
float randomfloat (int x)
 
float detrnd (uint s, int x)
 
void vformatstring (char *d, const char *fmt, va_list v, int len)
 
template<size_t N>
void vformatstring (char(&d)[N], const char *fmt, va_list v)
 
char * copystring (char *d, const char *s, size_t len)
 
template<size_t N>
char * copystring (char(&d)[N], const char *s)
 
char * concatstring (char *d, const char *s, size_t len)
 
template<size_t N>
char * concatstring (char(&d)[N], const char *s)
 
void nformatstring (char *d, int len, const char *fmt,...) PRINTFARGS(3
 
template<size_t N>
void formatstring (char(&d)[N], const char *fmt,...) PRINTFARGS(2
 
template<size_t N>
void void formatstring (char(&d)[N], const char *fmt,...)
 
template<size_t N>
void concformatstring (char(&d)[N], const char *fmt,...) PRINTFARGS(2
 
template<size_t N>
void void concformatstring (char(&d)[N], const char *fmt,...)
 
char * tempformatstring (const char *fmt,...) PRINTFARGS(1
 
bool matchstring (std::string_view s, size_t len, std::string_view d)
 
char * newstring (size_t l)
 
char * newstring (const char *s, size_t l)
 
char * newstring (const char *s)
 
char * newconcatstring (const char *s, const char *t)
 
uint memhash (const void *ptr, int len)
 
template<class T >
endianswap (T n)
 
template<>
uint endianswap< uint > (uint n)
 
template<>
int endianswap< int > (int n)
 
char * path (char *s)
 
std::string path (std::string s)
 
char * copypath (const char *s)
 
const char * sethomedir (const char *dir)
 
const char * findfile (const char *filename, const char *mode)
 
void initzipcmds ()
 Initializes zip Cubescript commands.
 
streamopenrawfile (const char *filename, const char *mode)
 
streamopenzipfile (const char *filename, const char *mode)
 
streamopenfile (const char *filename, const char *mode)
 
streamopengzfile (const char *filename, const char *mode, stream *file=nullptr, int level=Z_BEST_COMPRESSION)
 
template<class T >
void putint_ (T &p, int n)
 
template<class T >
void putuint_ (T &p, int n)
 
void putint (std::vector< uchar > &p, int n)
 
template<typename T >
void vectorput (std::vector< uint8_t > &buf, const T &data)
 
void vectorput (std::vector< uint8_t > &buf, const uint8_t *data, size_t size)
 
template<class T >
void sendstring_ (const char *t, T &p)
 
template<class T >
void putfloat_ (T &p, float f)
 
void putint (ucharbuf &p, int n)
 
int getint (ucharbuf &p)
 
void putuint (ucharbuf &p, int n)
 
int getuint (ucharbuf &p)
 
void putfloat (ucharbuf &p, float f)
 
float getfloat (ucharbuf &p)
 
void sendstring (const char *t, ucharbuf &p)
 
void getstring (char *t, ucharbuf &p, size_t len)
 
template<size_t N>
void getstring (char(&t)[N], ucharbuf &p)
 
void filtertext (char *dst, const char *src, bool whitespace, bool forcespace, size_t len)
 
template<size_t N>
void filtertext (char(&dst)[N], const char *src, bool whitespace=true, bool forcespace=false)
 

Variables

constexpr double SQRT2 = 1.4142135623731
 
constexpr double SQRT3 = 1.73205080756888
 
const int maxstrlen = 260
 
string homedir
 

Detailed Description

Legacy tooling inherited from the Cube engine.

This file contains a collection of deprecated, standalone tooling that replicates some standard library functionality. It is highly recommended that the std library equivalents of these utilities are used in their place.

Macro Definition Documentation

◆ DEF_FORMAT_STRING

#define DEF_FORMAT_STRING ( d,
... )
Value:
string d; formatstring(d, __VA_ARGS__)

◆ DEFV_FORMAT_STRING

#define DEFV_FORMAT_STRING ( d,
last,
fmt )
Value:
string d; { va_list ap; va_start(ap, last); vformatstring(d, fmt, ap); va_end(ap); }

Function Documentation

◆ initzipcmds()

void initzipcmds ( )
extern

Initializes zip Cubescript commands.

addzip

removezip