Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Namespaces | Macros | Typedefs | Functions
Globals.h File Reference
#include <arpa/inet.h>
#include <unistd.h>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <algorithm>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <deque>
#include <fstream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <thread>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <variant>
#include "fmt.h"
#include "StringUtils.h"
#include "LoggerSimple.h"
#include "OSSupport/CriticalSection.h"
#include "OSSupport/Event.h"
#include "OSSupport/File.h"
#include "OSSupport/StackTrace.h"
#include "Vector3.h"
Include dependency graph for Globals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  OverloadedVariantAccess< Ts >
 You can use this struct to use in std::visit example: std::visit( OverloadedVariantAccess { [&] (cFirstType & a_FirstTypeObject) { // Your code to handle cFirstType }, [&] (cSecondType & a_SecondTypeObject) { // YourCode to handle cSecondType }, ... More...
 
class  SizeChecker< T, Size >
 

Namespaces

 cpp20
 

Macros

#define ARRAYCOUNT(X)   (sizeof(X) / sizeof(*(X)))
 Evaluates to the number of elements in an array (compile-time!) More...
 
#define ASSERT(x)   ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))
 
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
 
#define FAST_FLOOR_DIV(x, div)   (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div))
 Faster than (int)floorf((float)x / (float)div) More...
 
#define KiB   * 1024
 Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") More...
 
#define MiB   * 1024 * 1024
 
#define PLATFORM_CRYPTOGRAPHY   0
 
#define TOLUA_TEMPLATE_BIND(x)
 
#define UNREACHABLE(x)   ( FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__), std::abort(), 0)
 
#define UNUSED   UNUSED_VAR
 
#define UNUSED_VAR(X)   (void)(X)
 
#define VERIFY(x)   (!!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))
 

Typedefs

typedef unsigned char Byte
 
typedef Byte ColourID
 
using ContiguousByteBuffer = std::basic_string< std::byte >
 
using ContiguousByteBufferView = std::basic_string_view< std::byte >
 
using cTickTime = std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >>
 
using cTickTimeLong = std::chrono::duration< signed long long int, cTickTime::period >
 
typedef signed short Int16
 
typedef signed int Int32
 
typedef signed long long Int64
 
typedef signed char Int8
 
typedef unsigned short UInt16
 
typedef unsigned int UInt32
 
typedef unsigned long long UInt64
 
typedef unsigned char UInt8
 

Functions

template<typename C = int, typename T >
std::enable_if< std::is_arithmetic< T >::value, C >::type CeilC (T a_Value)
 Ceils a value, then casts it to C (an int by default). More...
 
template<typename T >
Clamp (T a_Value, T a_Min, T a_Max)
 Clamp X to the specified range. More...
 
template<typename C = int, typename T >
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC (T a_Value)
 Floors a value, then casts it to C (an int by default). More...
 
template<class T >
std::enable_if_t<!std::is_array_v< T >, std::unique_ptr< T > > cpp20::make_unique_for_overwrite ()
 
template<class T >
std::enable_if_t< std::is_array_v< T > &&(std::extent_v< T >==0), std::unique_ptr< T > > cpp20::make_unique_for_overwrite (std::size_t a_Size)
 
template<class... Ts>
 OverloadedVariantAccess (Ts...) -> OverloadedVariantAccess< Ts... >
 
template<typename T >
auto ToUnsigned (T a_Val)
 

Macro Definition Documentation

◆ ARRAYCOUNT

#define ARRAYCOUNT (   X)    (sizeof(X) / sizeof(*(X)))

Evaluates to the number of elements in an array (compile-time!)

Definition at line 228 of file Globals.h.

◆ ASSERT

#define ASSERT (   x)    ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))

Definition at line 273 of file Globals.h.

◆ DISALLOW_COPY_AND_ASSIGN

#define DISALLOW_COPY_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName &) = delete; \
TypeName & operator =(const TypeName &) = delete

Definition at line 59 of file Globals.h.

◆ FAST_FLOOR_DIV

#define FAST_FLOOR_DIV (   x,
  div 
)    (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div))

Faster than (int)floorf((float)x / (float)div)

Definition at line 235 of file Globals.h.

◆ KiB

#define KiB   * 1024

Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)")

Definition at line 231 of file Globals.h.

◆ MiB

#define MiB   * 1024 * 1024

Definition at line 232 of file Globals.h.

◆ PLATFORM_CRYPTOGRAPHY

#define PLATFORM_CRYPTOGRAPHY   0

Definition at line 97 of file Globals.h.

◆ TOLUA_TEMPLATE_BIND

#define TOLUA_TEMPLATE_BIND (   x)

Definition at line 376 of file Globals.h.

◆ UNREACHABLE

#define UNREACHABLE (   x)    ( FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__), std::abort(), 0)

Definition at line 285 of file Globals.h.

◆ UNUSED

#define UNUSED   UNUSED_VAR

Definition at line 72 of file Globals.h.

◆ UNUSED_VAR

#define UNUSED_VAR (   X)    (void)(X)

Definition at line 65 of file Globals.h.

◆ VERIFY

#define VERIFY (   x)    (!!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), std::abort(), 0))

Definition at line 277 of file Globals.h.

Typedef Documentation

◆ Byte

typedef unsigned char Byte

Definition at line 158 of file Globals.h.

◆ ColourID

typedef Byte ColourID

Definition at line 159 of file Globals.h.

◆ ContiguousByteBuffer

using ContiguousByteBuffer = std::basic_string<std::byte>

Definition at line 372 of file Globals.h.

◆ ContiguousByteBufferView

using ContiguousByteBufferView = std::basic_string_view<std::byte>

Definition at line 373 of file Globals.h.

◆ cTickTime

using cTickTime = std::chrono::duration<signed int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50> >>

Definition at line 361 of file Globals.h.

◆ cTickTimeLong

using cTickTimeLong = std::chrono::duration<signed long long int, cTickTime::period>

Definition at line 364 of file Globals.h.

◆ Int16

typedef signed short Int16

Definition at line 150 of file Globals.h.

◆ Int32

typedef signed int Int32

Definition at line 149 of file Globals.h.

◆ Int64

typedef signed long long Int64

Definition at line 148 of file Globals.h.

◆ Int8

typedef signed char Int8

Definition at line 151 of file Globals.h.

◆ UInt16

typedef unsigned short UInt16

Definition at line 155 of file Globals.h.

◆ UInt32

typedef unsigned int UInt32

Definition at line 154 of file Globals.h.

◆ UInt64

typedef unsigned long long UInt64

Definition at line 153 of file Globals.h.

◆ UInt8

typedef unsigned char UInt8

Definition at line 156 of file Globals.h.

Function Documentation

◆ CeilC()

template<typename C = int, typename T >
std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC ( a_Value)

Ceils a value, then casts it to C (an int by default).

Definition at line 351 of file Globals.h.

◆ Clamp()

template<typename T >
T Clamp ( a_Value,
a_Min,
a_Max 
)

Clamp X to the specified range.

Definition at line 333 of file Globals.h.

◆ FloorC()

template<typename C = int, typename T >
std::enable_if<std::is_arithmetic<T>::value, C>::type FloorC ( a_Value)

Floors a value, then casts it to C (an int by default).

Definition at line 344 of file Globals.h.

◆ OverloadedVariantAccess()

template<class... Ts>
OverloadedVariantAccess ( Ts...  ) -> OverloadedVariantAccess< Ts... >

◆ ToUnsigned()

template<typename T >
auto ToUnsigned ( a_Val)

Definition at line 384 of file Globals.h.