jubilant-funicular
Namespaces | Classes | Typedefs | Functions | Variables
nta::utils Namespace Reference

Namespace for classes/functionality not necessarily specific to game/opengl development. More...

Namespaces

 check
 

Classes

struct  Formatter
 Specialize this struct to use custom types with format. More...
 
struct  Formatter< bool >
 
struct  Formatter< glm::ivec2 >
 
struct  Formatter< glm::ivec3 >
 
struct  Formatter< glm::ivec4 >
 
struct  Formatter< glm::vec2 >
 
struct  Formatter< glm::vec3 >
 
struct  Formatter< glm::vec4 >
 
struct  Formatter< Option< T > >
 
struct  Formatter< SlotMapKey< IndexType, GenType > >
 
struct  Formatter< T, typename std::enable_if_t< can_cout< T > > >
 Specialization for types you can cout. More...
 
class  IDFactory
 Class for generating unique (integral) IDs. More...
 
class  IDFactory< GenIndex< IndexType, GenType > >
 
struct  LinkedNode
 A generic linked list. More...
 
class  Option
 
class  Semaphore
 
class  SlotMap
 
struct  SlotMapKey
 A generational index. More...
 
class  StaticVector
 
class  ThreadPool
 Collection of threads for running scheduled functions. More...
 

Typedefs

typedef ::utils::Json Json
 
typedef ::utils::JsonObject JsonObject
 
typedef ::utils::JsonArray JsonArray
 
typedef ::utils::JsonNumType JsonNumType
 
typedef ::utils::JsonNum JsonNum
 
typedef ::utils::JsonValueType JsonValueType
 
typedef ::utils::Path Path
 
template<typename IndexType , typename GenType >
using GenIndex = SlotMapKey< IndexType, GenType >
 
template<typename T >
using is_defined = decltype(is_defined_impl(std::declval< T * >()))
 
typedef ::utils::TypeInfo TypeInfo
 
typedef ::utils::TypeMap TypeMap
 
template<typename T , typename TAG >
using Wrapper = ::utils::Wrapper< T, TAG >
 

Functions

template<typename... Args>
std::string format (const std::string &fmt, Args &&... args)
 
std::string format_helper (std::string &sofar, const std::string &fmt)
 
template<typename T , typename... Args>
std::string format_helper (std::string &sofar, const std::string &fmt, const T &arg0, Args &&... args)
 
template<typename... Args>
std::ostream & print (const std::string &fmt, Args &&... args)
 
template<typename... Args>
std::ostream & println (const std::string &fmt, Args &&... args)
 
template<typename T , typename S , typename std::enable_if_t< can_check_equality< T, S >, void * > = nullptr>
bool operator== (const Option< T > &lhs, const S &rhs)
 
template<typename T , typename S , typename std::enable_if_t< can_check_equality< T, S >, void * > = nullptr>
bool operator== (const Option< T > &lhs, const Option< S > &rhs)
 
template<typename T , typename S , typename std::enable_if_t< can_check_equality< T, S >, void * > = nullptr>
bool operator== (const T &lhs, const Option< S > &rhs)
 
template<typename T >
Option< T > make_some (const T &data)
 Replacement for calling Option<T>::some()
 
template<typename T >
Option< T > make_none ()
 Replacement for calling Option<T>::none()
 
template<typename T , std::size_t = sizeof(T)>
std::true_type is_defined_impl (T *)
 
std::false_type is_defined_impl (...)
 
bool starts_with (crstring str, crstring prefix)
 Checks if str starts with prefix.
 
bool ends_with (crstring str, crstring suffix)
 Checks if str ends with suffix.
 
std::string replace_all (crstring str, crstring o, crstring n)
 Replaces all occurences of o in str with n.
 
std::string replace_all (crstring str, const std::vector< std::vector< std::string >> &os, const std::vector< std::string > &ns)
 Replaces all occurences of any string in the ith element of os with the ith element of ns.
 
std::string trim (crstring str, crstring back_trash=" \t\n\v\f\r\0", crstring front_trash=" \t\n\v\f\r\0")
 Removes leading and trailing whitespace.
 
std::vector< std::string > split (crstring str, char delim)
 Splits a string into substrings separated by delim.
 
glm::vec2 rotate (crvec2 pt, float angle)
 Rotates a point (about the origin) by the given angle.
 
std::string read_file (const std::string_view path)
 Reads the contents of a file into a string.
 
std::size_t hash_combine (std::size_t lhs, std::size_t rhs)
 Stolen from Boost.
 
template<class T >
std::string to_string (const T &input, std::size_t precision=0)
 converts input to a std::string
 
template<class T >
bool in_range (T val, T min, T max)
 returns whether or not min <= val <= max
 

Variables

template<typename T , typename = std::void_t<>>
constexpr bool can_cout = false
 
template<typename T , typename = T, typename = std::void_t<>>
constexpr bool can_check_equality = false
 

Detailed Description

Namespace for classes/functionality not necessarily specific to game/opengl development.

Reexporting everything from utilities is dumb

Todo:
Figure out a nice sub-library solution and implement it

Class Documentation

◆ nta::utils::Formatter

struct nta::utils::Formatter

template<typename T, typename Enable = void>
struct nta::utils::Formatter< T, Enable >

Specialize this struct to use custom types with format.

Definition at line 23 of file format.h.

Function Documentation

◆ format()

template<typename... Args>
std::string nta::utils::format ( const std::string &  fmt,
Args &&...  args 
)

(Very basic) string formatting function

Use {} as a placeholder for arguments

e.g. format("Hello {}!", "World");

Definition at line 88 of file format.h.