The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
CppAddons.h File Reference
#include <type_traits>
#include <cstddef>
#include <climits>
#include <cstdint>
#include <cmath>
#include <cstring>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <chrono>
#include <thread>
#include <bitset>
#include <functional>
#include <mutex>
Include dependency graph for CppAddons.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FIntTraits< T >
 Collect diverse traits for the fixed integer type T. More...
 
class  FIntTraits< uint8_t >
 FIntTraits for uint8_t. More...
 
class  FIntTraits< uint16_t >
 FIntTraits for uint16_t. More...
 
class  FIntTraits< uint32_t >
 FIntTraits for uint32_t. More...
 
class  FIntTraits< uint64_t >
 FIntTraits for uint64_t. More...
 
class  FIntTraits< int8_t >
 FIntTraits for int8_t. More...
 
class  FIntTraits< int16_t >
 FIntTraits for int16_t. More...
 
class  FIntTraits< int32_t >
 FIntTraits for int32_t. More...
 
class  FIntTraits< int64_t >
 FIntTraits for int64_t. More...
 
class  NextIntType< NUMOFBITS >
 Provide the first signed integer type that has more than NUMOFBITS in memory. More...
 
class  NextIntType< CHAR_BIT *1 >
 NextIntType of 1 C-byte length types. More...
 
class  NextIntType< CHAR_BIT *2 >
 NextIntType of 2 C-bytes length types. More...
 
class  NextIntType< CHAR_BIT *3 >
 NextIntType of 3 C-bytes length types. More...
 
class  NextIntType< CHAR_BIT *4 >
 NextIntType of 4 C-bytes length types. More...
 
class  NextIntType< CHAR_BIT *5 >
 NextIntType of 5 C-bytes length types. More...
 
class  NextIntType< CHAR_BIT *6 >
 NextIntType of 6 C-bytes length types. More...
 
class  NextIntType< CHAR_BIT *7 >
 NextIntType of 7 C-bytes length types. More...
 
class  LongestType< T0, T1, sizet0smallerthansizet1 >
 Select the longest type in memory of two given types T0 and T1. More...
 
class  LongestType< T0, T1, true >
 Case of sizeof(T0) < sizeof(T1) More...
 
class  NaturalRange< BaseIntegerType, MAXVAL >
 An unsigned integer type that is bound-protected. More...
 
class  Interval< ELEMTYPE >
 An interval, typically numeric, either closed, opened or semi-closed. More...
 
class  IterableEnum< T >
 A generic enum for adding iteration capabilities to C++11 enum class. More...
 
class  IterableEnum< T >::Iterator
 The iterator of IterableEnum. More...
 
class  ThreadSafer< Unsafe >
 Makes an unsafe class thread-safe. More...
 
class  ThreadSafer< Unsafe >::Proxy
 A proxy to access objects in a safe manner. Not used directly. More...
 

Macros

#define BINTOSTREAM(v, n)   (std::bitset<n>{v})
 Format V in binary for feeding it to a stream, up to the bit number N-1. More...
 
#define JUSTFILENAME
 Strips FILE from entire path. More...
 
#define DEBUGPREFFIX(txt)
 Generate a string for debugging uses (see the Debugging module). More...
 
#define RUNTIMEEXCEP(txt)
 Raise a runtime exception with the given std::string TXT + additional info. More...
 
#define INTERNALERROR(txt)   RUNTIMEEXCEP("Internal error - " + txt)
 Raise a runtime exception indicating internal error. More...
 

Typedefs

using LongestUnsignedType = unsigned long long
 Longest unsigned integral type in the target machine. More...
 

Enumerations

enum class  IntervalCl : uint8_t { CLOSED , OPENED , LEFT_CLOSED , RIGHT_CLOSED }
 Kinds of closedness for intervals. More...
 

Functions

template<typename NumType >
NumType string_hex_to_num (const std::string &txt)
 Return the unsigned int. value of a number expressed in hexadecimal form. More...
 
template<typename NumType >
std::string num_to_string_hex (NumType n, bool padding=true)
 Convert an integral number to string in hexadecimal format, without preffix. More...
 
template<typename PointedType >
std::string hex_dump (const PointedType *data, size_t howmany, bool toupp=true, bool sepelems=true)
 Return a string that represents all hex codes of the pointed bytes. More...
 
LongestUnsignedType pointer_to_number (const void *p) noexcept
 Return the numerical value (address) of the given pointer. More...
 
constexpr uint8_t all_bits_set_up_to_n (uint8_t n)
 Return a byte with its (N+1) least-significant bits set (N must be in [0,7]) More...
 
template<typename T , unsigned char N = sizeof(T)*CHAR_BIT>
reverse_bits (T v)
 Reverse the bits in an integral value, up to bit number N-1. More...
 
template<typename T >
unsigned char count_bits_set (T v)
 Count the number of bits that are set in an integral value. More...
 
template<typename T , unsigned char N = sizeof(T)*CHAR_BIT>
unsigned char most_significant_bit_set (T b)
 Return the index of the MSb set in B, or the number of bits in T if none. More...
 
template<typename T , unsigned char N = sizeof(T)*CHAR_BIT>
unsigned char least_significant_bit_set (T b)
 Return the index of the LSb set in B, or the number of bits in T if none. More...
 
template<typename T >
bool more_bits_set (T b1, T b2)
 Return TRUE if B1 has the same bits set as B2 plus at least 1 more bit set. More...
 
template<typename T >
substract_bits (T b1, T b2)
 Substract bits of B2 from B1. More...
 
template<typename T >
bool new_bits_set (T b1, T b2)
 Return TRUE if B1 has some bit set that B2 has not, indepently on other bits. More...
 
template<unsigned char N>
constexpr unsigned char bits_of_constexprvalue ()
 Return the number of bits needed by a constexpr value N. More...
 
template<typename T >
unsigned char bits_of_value (T v)
 The same as bits_of_constexprvalue(v) but for any variable value. More...
 
template<class TIter , class TBody >
void for_within (TIter i_first, TIter i_last, const TBody &body)
 Iterate through consecutive values without using any value outside the range. More...
 
void pad_string (std::string &s, size_t len, bool leftorright=true, char padding='\t')
 Pad S up to LEN characters PADDING either to the left (TRUE) or right. More...
 
LongestUnsignedType utime_now (void)
 Return the current time since epoch in microseconds. More...
 

Variables

static const double PI = std::acos(-1.0)
 The PI constant. More...