lxgui
Namespaces | Classes | Typedefs | Enumerations | Functions
lxgui::utils Namespace Reference

Namespaces

 impl
 
 range
 
 view
 

Classes

class  exception
 Exception class. More...
 
class  periodic_timer
 A repeating timer. More...
 
class  connection
 Object representing the connection between a slot and a signal. More...
 
class  scoped_connection
 A connection that automatically disconnects when going out of scope. More...
 
class  signal
 Generic class for observing and triggering events. More...
 
class  sorted_vector
 Sorted std::vector wrapper. This class is a light alternative to std::set. Inspired from: [1] www.lafstern.org/matt/col1.pdf. More...
 
struct  empty
 Empty type, used in the implementation of utils::variant. More...
 

Typedefs

using string_vector = std::vector< std::string >
 
template<typename T >
using first_function_argument = typename impl::first_function_argument_< decltype(&std::decay_t< T >::operator())>::type
 
template<typename T >
using owner_ptr = oup::observable_sealed_ptr< T >
 
template<typename T >
using enable_observer_from_this = oup::enable_observer_from_this_sealed< T >
 
using variant = std::variant< empty, bool, std::int64_t, std::int32_t, std::int16_t, std::int8_t, std::uint64_t, std::uint32_t, std::uint16_t, std::uint8_t, double, float, std::string >
 Type-erased value for passing arguments to events. More...
 

Enumerations

enum class  rounding_method { nearest , nearest_not_zero , up , down }
 Rounding method for points to pixels conversions. More...
 

Functions

bool file_exists (const std::string &file)
 
string_vector get_directory_list (const std::string &rel_path)
 
string_vector get_file_list (const std::string &rel_path, bool with_path)
 
string_vector get_file_list (const std::string &rel_path, bool with_path, const std::string &extensions)
 
bool make_directory (const std::string &path)
 
std::string get_file_extension (const std::string &file)
 
float round (float value, float unit, rounding_method method)
 Round a floating point value to a specific unit and using a specific rounding method. More...
 
template<typename T , typename... Args>
owner_ptr< T > make_owned (Args &&... args)
 
template<typename C , typename T >
auto find (C &v, const T &s)
 
template<typename C , typename T >
auto find_if (C &v, T &&f)
 
template<typename T >
T & get (variant &value)
 Retrieve the value stored in an utils::variant. More...
 
template<typename T >
const T & get (const variant &value)
 Retrieve the value stored in an utils::variant. More...
 

Typedef Documentation

◆ enable_observer_from_this

template<typename T >
using lxgui::utils::enable_observer_from_this = typedef oup::enable_observer_from_this_sealed<T>

Definition at line 21 of file utils_observer.hpp.

◆ first_function_argument

template<typename T >
using lxgui::utils::first_function_argument = typedef typename impl::first_function_argument_<decltype(&std::decay_t<T>::operator())>::type

Definition at line 31 of file utils_meta.hpp.

◆ owner_ptr

template<typename T >
using lxgui::utils::owner_ptr = typedef oup::observable_sealed_ptr<T>

Definition at line 11 of file utils_observer.hpp.

◆ string_vector

using lxgui::utils::string_vector = typedef std::vector<std::string>

Definition at line 12 of file utils_file_system.hpp.

◆ variant

using lxgui::utils::variant = typedef std::variant< empty, bool, std::int64_t, std::int32_t, std::int16_t, std::int8_t, std::uint64_t, std::uint32_t, std::uint16_t, std::uint8_t, double, float, std::string>

Type-erased value for passing arguments to events.

This contains all the basic numerical types up to 64bit precision. Any other scalar types (such as charXX_t, or strongly typed enums) can be represented as one of these. Use utils::get() to enable automatic support for strongly typed enums. The utils::empty type is used to indicate an un-specified value. This is also the state of a default constructed utils::variant. When transferred to Lua, utils::empty is translated as nil.

Definition at line 25 of file utils_variant.hpp.

Enumeration Type Documentation

◆ rounding_method

Rounding method for points to pixels conversions.

Enumerator
nearest 

Equivalent to round()

nearest_not_zero 

Equivalent to round() but only returns 0 if input is exactly 0.

up 

Equivalent to ceil()

down 

Equivalent to floor()

Definition at line 10 of file utils_maths.hpp.

Function Documentation

◆ file_exists()

bool lxgui::utils::file_exists ( const std::string &  file)

Definition at line 10 of file utils_file_system.cpp.

◆ find()

template<typename C , typename T >
auto lxgui::utils::find ( C &  v,
const T &  s 
)

Definition at line 14 of file utils_std.hpp.

◆ find_if()

template<typename C , typename T >
auto lxgui::utils::find_if ( C &  v,
T &&  f 
)

Definition at line 19 of file utils_std.hpp.

◆ get() [1/2]

template<typename T >
const T& lxgui::utils::get ( const variant value)

Retrieve the value stored in an utils::variant.

Parameters
valueThe variant
Returns
The stored value, or throws std::bad_variant_access if the type was incorrect
Note
This wrapper around std::get() enables automatic support for strongly typed enums.

Definition at line 61 of file utils_variant.hpp.

◆ get() [2/2]

template<typename T >
T& lxgui::utils::get ( variant value)

Retrieve the value stored in an utils::variant.

Parameters
valueThe variant
Returns
The stored value, or throws std::bad_variant_access if the type was incorrect
Note
This wrapper around std::get() enables automatic support for strongly typed enums.

Definition at line 47 of file utils_variant.hpp.

◆ get_directory_list()

string_vector lxgui::utils::get_directory_list ( const std::string &  rel_path)

Definition at line 14 of file utils_file_system.cpp.

◆ get_file_extension()

std::string lxgui::utils::get_file_extension ( const std::string &  file)

Definition at line 65 of file utils_file_system.cpp.

◆ get_file_list() [1/2]

string_vector lxgui::utils::get_file_list ( const std::string &  rel_path,
bool  with_path 
)

Definition at line 24 of file utils_file_system.cpp.

◆ get_file_list() [2/2]

string_vector lxgui::utils::get_file_list ( const std::string &  rel_path,
bool  with_path,
const std::string &  extensions 
)

Definition at line 39 of file utils_file_system.cpp.

◆ make_directory()

bool lxgui::utils::make_directory ( const std::string &  path)

Definition at line 60 of file utils_file_system.cpp.

◆ make_owned()

template<typename T , typename... Args>
owner_ptr<T> lxgui::utils::make_owned ( Args &&...  args)

Definition at line 24 of file utils_observer.hpp.

◆ round()

float lxgui::utils::round ( float  value,
float  unit,
rounding_method  method 
)

Round a floating point value to a specific unit and using a specific rounding method.

Parameters
valueThe value to round
unitThe rounding unit (e.g., if set to 2, the output must be a multiple of 2)
methodThe rounding method
Returns
The rounded value

Definition at line 8 of file utils_maths.cpp.