qxLib
Public Member Functions | List of all members
qx::details::string_to_color_converter< char_t > Class Template Referencefinal

Helper class for string -> color conversion. More...

Inheritance diagram for qx::details::string_to_color_converter< char_t >:
singleton< string_to_color_converter< char_t > >

Public Member Functions

void add (basic_string< char_t > sName, color_name_type eColorNameType, color color) noexcept
 Add new color to the mapping. More...
 
std::optional< color > get (const basic_string< char_t > &sName) const noexcept
 Try to get ac olor from a color name. More...
 
std::optional< basic_string_view< char_t > > get (const color &color, color_name_type eColorNameType) const noexcept
 Try to a color name get from a color. More...
 

Detailed Description

template<class char_t>
class qx::details::string_to_color_converter< char_t >

Helper class for string -> color conversion.

The only purpose of this class is to hide the map from a user

Template Parameters
char_t- string char type
Author
Khrapov
Date
5.04.2023

Definition at line 41 of file color.inl.

Member Function Documentation

◆ add()

template<class char_t >
void qx::details::string_to_color_converter< char_t >::add ( basic_string< char_t >  sName,
color_name_type  eColorNameType,
color  color 
)
inlinenoexcept

Add new color to the mapping.

Parameters
sName- name registered for forward lookup
eColorNameType- css_snake or css_pascal selects the reverse lookup table; other formats only update the forward lookup
color- RGBA value associated with sName; an existing entry with the same key is replaced

Definition at line 91 of file color.inl.

◆ get() [1/2]

template<class char_t >
std::optional< color > qx::details::string_to_color_converter< char_t >::get ( const basic_string< char_t > &  sName) const
inlinenoexcept

Try to get ac olor from a color name.

Parameters
sName- color name
Return values
-color or nullopt

Definition at line 105 of file color.inl.

◆ get() [2/2]

template<class char_t >
std::optional< basic_string_view< char_t > > qx::details::string_to_color_converter< char_t >::get ( const color &  color,
color_name_type  eColorNameType 
) const
inlinenoexcept

Try to a color name get from a color.

Parameters
color- RGBA lookup key
eColorNameType- css_snake or css_pascal selects the reverse lookup table
Return values
-registered name, or nullopt if the key is absent or the requested name format is unsupported

Definition at line 114 of file color.inl.


The documentation for this class was generated from the following file: