R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Utilities Namespace Reference

Functions

std::ostream & operator<< (std::ostream &os, const bool &item)
 Outputs a boolean value to the given output stream using a custom string representation.
 
template<typename T1 , typename T2 >
std::ostream & operator<< (std::ostream &os, const std::pair< T1, T2 > &item)
 Outputs a pair of items to the given output stream using a custom string representation.
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const std::vector< T > &set)
 Outputs a vector of items to the given output stream using a custom string representation.
 
template<typename Key , typename Value >
std::ostream & operator<< (std::ostream &os, const std::unordered_map< Key, Value > &map)
 Outputs an unordered_map of items to the given output stream using a custom string representation.
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const std::set< T > &set)
 Outputs a set of items to the given output stream using a custom string representation.
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const std::unordered_set< T > &set)
 Outputs an unordered_set of items to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const ActiveScreen &item)
 Outputs a the string value of the ActiveScreen enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::GameComponents::Package_t &item)
 Outputs a the string value of the Package_t enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::GameComponents::EntityType &item)
 Outputs a the string value of the EntityType enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::GameComponents::ECSPackage_t &item)
 Outputs a the string value of the ECSPackage_t enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::GameComponents::EntityActions_t &item)
 Outputs a the string value of the EntityActions_t enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::GameComponents::EntityActionType &item)
 Outputs a the string value of the EntityActionType enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::ECS::Systems::ActiveShape &item)
 Outputs a the string value of the ActiveShape enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::Network::MessageType &item)
 Outputs a the string value of the MessageType enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::Network::MessageInfo &item)
 Outputs a the string value of the MessageInfo enum to the given output stream using a custom string representation.
 
std::ostream & operator<< (std::ostream &os, const GUI::Network::MessageNode &item)
 Outputs a the string value of the MessageNode enum to the given output stream using a custom string representation.
 
template<typename T , typename Exception = CustomExceptions::InvalidType>
std::optional< T > unCast (const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
 Casts the content of a std::any back to its original type.
 

Function Documentation

◆ operator<<() [1/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const ActiveScreen & item )
inline

Outputs a the string value of the ActiveScreen enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the ActiveScreen to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the ActiveScreen will be written.
itemThe ActiveScreen struct value to output.
Returns
The modified output stream with the ActiveScreen's string representation appended.

Definition at line 156 of file OperatorRebind.hpp.

◆ operator<<() [2/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const bool & item )
inline

Outputs a boolean value to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the boolean value to a string ("true" or "false") and then inserts the result into the output stream.

Parameters
osThe output stream to which the boolean value will be written.
itemThe boolean value to output.
Returns
The modified output stream with the boolean's string representation appended.

Definition at line 38 of file OperatorRebind.hpp.

◆ operator<<() [3/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::GameComponents::ECSPackage_t & item )
inline

Outputs a the string value of the ECSPackage_t enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the ECSPackage_t to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the ECSPackage_t will be written.
itemThe ECSPackage_t struct value to output.
Returns
The modified output stream with the ECSPackage_t's string representation appended.

Definition at line 207 of file OperatorRebind.hpp.

◆ operator<<() [4/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::GameComponents::EntityActions_t & item )
inline

Outputs a the string value of the EntityActions_t enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the EntityActions_t to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the EntityActions_t will be written.
itemThe EntityActions_t struct value to output.
Returns
The modified output stream with the EntityActions_t's string representation appended.

Definition at line 224 of file OperatorRebind.hpp.

◆ operator<<() [5/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::GameComponents::EntityActionType & item )
inline

Outputs a the string value of the EntityActionType enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the EntityActionType to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the EntityActionType will be written.
itemThe EntityActionType enum value to output.
Returns
The modified output stream with the EntityActionType's string representation appended.

Definition at line 241 of file OperatorRebind.hpp.

◆ operator<<() [6/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::GameComponents::EntityType & item )
inline

Outputs a the string value of the EntityType enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the EntityType to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the EntityType will be written.
itemThe EntityType struct value to output.
Returns
The modified output stream with the EntityType's string representation appended.

Definition at line 190 of file OperatorRebind.hpp.

◆ operator<<() [7/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::GameComponents::Package_t & item )
inline

Outputs a the string value of the Package_t enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the Package_t to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the Package_t will be written.
itemThe Package_t struct value to output.
Returns
The modified output stream with the Package_t's string representation appended.

Definition at line 173 of file OperatorRebind.hpp.

◆ operator<<() [8/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::ECS::Systems::ActiveShape & item )
inline

Outputs a the string value of the ActiveShape enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the ActiveShape to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the ActiveShape will be written.
itemThe ActiveShape enum value to output.
Returns
The modified output stream with the ActiveShape's string representation appended.

Definition at line 258 of file OperatorRebind.hpp.

◆ operator<<() [9/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::Network::MessageInfo & item )
inline

Outputs a the string value of the MessageInfo enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the MessageInfo to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the MessageInfo will be written.
itemThe MessageInfo value to output.
Returns
The modified output stream with the MessageInfo's string representation appended.

Definition at line 292 of file OperatorRebind.hpp.

◆ operator<<() [10/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::Network::MessageNode & item )
inline

Outputs a the string value of the MessageNode enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the MessageNode to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the MessageNode will be written.
itemThe MessageNode value to output.
Returns
The modified output stream with the MessageNode's string representation appended.

Definition at line 309 of file OperatorRebind.hpp.

◆ operator<<() [11/16]

std::ostream & Utilities::operator<< ( std::ostream & os,
const GUI::Network::MessageType & item )
inline

Outputs a the string value of the MessageType enum to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the MessageType to a string and then inserts the result into the output stream.

Parameters
osThe output stream to which the MessageType will be written.
itemThe MessageType value to output.
Returns
The modified output stream with the MessageType's string representation appended.

Definition at line 275 of file OperatorRebind.hpp.

◆ operator<<() [12/16]

template<typename T1 , typename T2 >
std::ostream & Utilities::operator<< ( std::ostream & os,
const std::pair< T1, T2 > & item )
inline

Outputs a pair of items to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the pair to a string and then inserts the result into the output stream.

Template Parameters
T1The type of the first element in the pair.
T2The type of the second element in the pair.
Parameters
osThe output stream to which the pair will be written.
itemThe pair of items to output.
Returns
The modified output stream with the pair's string representation appended.

Definition at line 59 of file OperatorRebind.hpp.

◆ operator<<() [13/16]

template<typename T >
std::ostream & Utilities::operator<< ( std::ostream & os,
const std::set< T > & set )
inline

Outputs a set of items to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the set to a string and then inserts the result into the output stream.

Template Parameters
TThe type of the elements in the set.
Parameters
osThe output stream to which the set will be written.
itemThe set of items to output.
Returns
The modified output stream with the set's string representation appended.

Definition at line 119 of file OperatorRebind.hpp.

◆ operator<<() [14/16]

template<typename Key , typename Value >
std::ostream & Utilities::operator<< ( std::ostream & os,
const std::unordered_map< Key, Value > & map )
inline

Outputs an unordered_map of items to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the unordered_map to a string and then inserts the result into the output stream.

Template Parameters
TThe type of the elements in the unordered_map.
Parameters
osThe output stream to which the unordered_map will be written.
itemThe unordered_map of items to output.
Returns
The modified output stream with the unordered_map's string representation appended.

Definition at line 99 of file OperatorRebind.hpp.

◆ operator<<() [15/16]

template<typename T >
std::ostream & Utilities::operator<< ( std::ostream & os,
const std::unordered_set< T > & set )
inline

Outputs an unordered_set of items to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the unordered_set to a string and then inserts the result into the output stream.

Template Parameters
TThe type of the elements in the unordered_set.
Parameters
osThe output stream to which the unordered_set will be written.
itemThe unordered_set of items to output.
Returns
The modified output stream with the unordered_set's string representation appended.

Definition at line 139 of file OperatorRebind.hpp.

◆ operator<<() [16/16]

template<typename T >
std::ostream & Utilities::operator<< ( std::ostream & os,
const std::vector< T > & set )
inline

Outputs a vector of items to the given output stream using a custom string representation.

This function uses the custom Recoded::myToString function to convert the vector to a string and then inserts the result into the output stream.

Template Parameters
TThe type of the elements in the vector.
Parameters
osThe output stream to which the vector will be written.
itemThe vector of items to output.
Returns
The modified output stream with the vector's string representation appended.

Definition at line 79 of file OperatorRebind.hpp.

◆ unCast()

template<typename T , typename Exception = CustomExceptions::InvalidType>
std::optional< T > Utilities::unCast ( const std::any & classNode,
const bool raiseOnError = true,
const std::string customErrorMessage = "" )

Casts the content of a std::any back to its original type.

This function attempts to safely cast the value stored in a std::any object to the specified type T. If the casting fails due to a type mismatch, an exception of type Exception may be thrown, or a warning may be logged based on the raiseOnError parameter.

Template Parameters
TThe expected type of the value contained in the std::any object.
ExceptionThe type of exception to throw in case of a failure. Defaults to CustomExceptions::InvalidType. The exception must be constructible with a single string parameter, as this is the only argument passed when thrown.
Parameters
classNodeThe std::any object containing the value to be cast.
raiseOnErrorWhether to throw an exception if the casting fails. Defaults to true.
customErrorMessageAn optional custom message prepended to the error description if an exception is thrown or a warning is logged.
Returns
std::optional<T> The successfully cast value wrapped in a std::optional, or std::nullopt if the casting fails and exceptions are not raised.
Exceptions
ExceptionIf raiseOnError is true and:
  • The type stored in the std::any object does not match the expected type T.
  • The std::any object does not contain a value.
  • A std::bad_any_cast is encountered during the casting attempt.
Note
If raiseOnError is false and an error occurs, a warning is logged using PRETTY_WARNING, and std::nullopt is returned instead of throwing an exception.

Example usage:

try {
std::any data = 42;
auto value = Utilities::unCast<int>(data);
if (value.has_value()) {
std::cout << "Uncast value: " << value.value() << std::endl;
} else {
std::cout << "Failed to cast value." << std::endl;
}
} catch (const CustomExceptions::InvalidType& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
This is the class in charge of informing the user that they tried to display a non-existent or invali...
Definition Invalid.hpp:517
const char * what() const noexcept
Retrieves the error message.
Definition Invalid.cpp:356
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.
Definition UnCast.hpp:65

Definition at line 65 of file UnCast.hpp.