Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Classes | Functions | Variables
inexor::util Namespace Reference

Namespaces

 random
 

Classes

class  InexorConsoleSink
 Ingame GUI console. More...
 
class  InexorCutAnsiCodesSink
 Sink wrapper for removing any color codes from the log. More...
 
class  Logger
 Wrapper around spdlog::logger to put it into the InexorTree We want to set the pattern and the level on a per-logger-base and expose it. More...
 
class  log_manager
 The global inexor logging API TODO: enable sharing. More...
 
struct  embraced
 Helper class to allow the writing of std::cout << embraced("I should be inside curly brackets", "{", "}"); Same works for numbers, but it may destroy std::setprecision. More...
 
struct  quoted
 A simple helper class to allow you writing inexor::util::quoted(string) which automatically adds quotation marks. More...
 
class  InexorException
 Basic exception type for use in inexor. More...
 
class  StringFormatter
 Format strings with a one-liner. More...
 
class  Subsystem
 Subsystems are loosely coupled parts of inexor. More...
 
class  Metasystem
 A metasystem is a collection of multiple subsystems. More...
 

Functions

bool is_file_writeable (const std::string &filename)
 
bool find_logfile_name (std::string &logfile_without_extension)
 Modifies the given logname until its a writeable file. More...
 
std::vector< spdlog::sink_ptr > create_startup_sinks ()
 Some sinks are not dependend on settings and hence they get used even before the Tree is initialized. More...
 
std::vector< spdlog::sink_ptr > get_all_sinks ()
 Returns a vector with startup_sinks + logfile_sink (if logfile_sink != nullptr). More...
 
 IEXCEPTION (SubsystemException,"Some problem with the ""subsystems occurred.")
 
 EXCEPTION (NoSuchSubsystem, SubsystemException,"The subsystem you're trying to start does not exist.")
 
 EXCEPTION (SubsystemAlreadyRunning, SubsystemException,"The subsystem you're trying to start is already running.")
 
 EXCEPTION (SubsystemNotRunning, SubsystemException,"The subsystem you're trying to stop is not running.")
 
template<typename T >
std::string to_string (T x)
 Convert stuff to a string. More...
 
template<typename To , typename From >
std::unique_ptr< To > dynamic_pointer_cast (std::unique_ptr< From > &&f) noexcept
 Moving dynamic cast for unique_ptr. More...
 
template<typename T >
std::string split_find_last (const std::string &s, T sep__)
 Split a string and get the last component. More...
 

Variables

std::vector< spdlog::sink_ptr > startup_sinks
 
spdlog::sink_ptr logfile_sink
 The logfile gets added thereafter. More...
 
StringFormatter::FmtMark fmt
 Marker that starts formatting a string. More...
 

Function Documentation

std::vector<spdlog::sink_ptr> inexor::util::create_startup_sinks ( )

Some sinks are not dependend on settings and hence they get used even before the Tree is initialized.

So these are the "not-logfile" sinks.

Referenced by get_all_sinks().

template<typename To , typename From >
std::unique_ptr<To> inexor::util::dynamic_pointer_cast ( std::unique_ptr< From > &&  f)
noexcept

Moving dynamic cast for unique_ptr.

If successful, the given pointer will be released and moved into the returned pointer with the new type.

If the cast fails, the returned pointer will contain nullptr and the input pointer will be unmodified.

References f().

inexor::util::EXCEPTION ( NoSuchSubsystem  ,
SubsystemException  ,
"The subsystem you're trying to start does not exist."   
)
inexor::util::EXCEPTION ( SubsystemAlreadyRunning  ,
SubsystemException  ,
"The subsystem you're trying to start is already running."   
)
inexor::util::EXCEPTION ( SubsystemNotRunning  ,
SubsystemException  ,
"The subsystem you're trying to stop is not running."   
)
bool inexor::util::find_logfile_name ( std::string logfile_without_extension)

Modifies the given logname until its a writeable file.

Does so by simply appending a number to it.

Returns
false if it exceeded 100 rename tries and none worked.

References is_file_writeable(), and to_string().

Referenced by inexor::util::log_manager::log_manager().

std::vector<spdlog::sink_ptr> inexor::util::get_all_sinks ( )

Returns a vector with startup_sinks + logfile_sink (if logfile_sink != nullptr).

References create_startup_sinks(), logfile_sink, and startup_sinks.

Referenced by inexor::util::Logger::create_spdlog_logger().

inexor::util::IEXCEPTION ( SubsystemException  ,
"Some problem with the ""subsystems occurred."   
)
bool inexor::util::is_file_writeable ( const std::string filename)

Referenced by find_logfile_name().

template<typename T >
std::string inexor::util::split_find_last ( const std::string s,
sep__ 
)

Split a string and get the last component.

Example:

split_find_last("hello world this is patric", ' ') => "patric"

TODO: Use the boost tokenize lib.

Template Parameters
TThe type of the separator: Anything that std::string::find_last_of would take (at least char and string)
Parameters
sThe String to split
sep__The char/string/... to separate s by
Returns
The last element of s separated by sep

References to_string().

template<typename T >
std::string inexor::util::to_string ( x)

Convert stuff to a string.

This works for anything that has the ostream << operator defined.

This internally simply uses the StringFormatter

References fmt.

Referenced by find_logfile_name(), inexor::ui::CefSubsystem::initialize(), split_find_last(), and anonymous_namespace{utilTest.cpp}::t().

Variable Documentation

StringFormatter::FmtMark inexor::util::fmt
spdlog::sink_ptr inexor::util::logfile_sink

The logfile gets added thereafter.

Referenced by get_all_sinks(), and inexor::util::log_manager::log_manager().

std::vector<spdlog::sink_ptr> inexor::util::startup_sinks

Referenced by get_all_sinks().