Style.hpp

A CSS class for tracking font style, etc.

class Style
#include <Style.hpp>

Class to maintain a map of setting names to values that can be easily ported over to JavaScript. A companial class, Attributes, also exists.

Public Functions

inline Style()
Style(const Style&) = default
Style(Style&&) = default
Style &operator=(const Style&) = default
Style &operator=(Style&&) = default
inline size_t GetSize() const

Return a count of the number of settings that have been set.

inline size_t GetNClasses() const

Return a count of the number of classes that have been added.

inline Style &AddClass(const std::string &in_clss)
inline Style &DoSet(const std::string &in_set, const std::string &in_val)
template<typename SET_TYPE>
inline Style &Set(const std::string &s, SET_TYPE v)

Record that setting “s” is set to value “v” (converted to string) and return this object.

inline Style &Insert(const Style &in_css)

Set all values from in_css here as well. Return this object.

inline bool Has(const std::string &setting) const

Return true/false based on whether “setting” has been given a value in this Style.

inline const std::string &Get(const std::string &setting) const

Return the (string) value of “setting” that has been recorded in this Style.

inline const std::map<std::string, std::string> &GetMap() const
inline const std::set<std::string> &GetClasses() const
inline void Clear()

Remove all setting values and all classes.

inline void Remove(const std::string &setting)

Remove a specific setting value.

inline void RemoveClass(const std::string &clss)

Remove a specific class.

inline void Apply(const std::string &widget_id)

Apply ALL of the style settings to a specified widget.

inline void Apply(const std::string &widget_id, const std::string &setting)

Apply only a SPECIFIC style setting from the setting library.

inline operator bool() const

Have any settings be set?

Public Static Functions

static inline void Apply(const std::string &widget_id, const std::string &setting, const std::string &value)

Apply onlay a SPECIFIC style setting with a specifid value!

static inline void ApplyClass(const std::string &widget_id, const std::string &clss)
static inline void ApplyRemoveClass(const std::string &widget_id, const std::string &clss)

Private Members

std::map<std::string, std::string> settings

CSS Setting values being tracked.

std::set<std::string> classes

CSS classes.