Attributes.hpp

An Attributes class for tracking non-style features about HTML objects.

class Attributes
#include <Attributes.hpp>

Maintains a map of attribute names to values for use in JavaScript Closely related to Style.h, which is for CSS-values.

Public Functions

inline Attributes()
Attributes(const Attributes&) = default
Attributes &operator=(const Attributes&) = default
inline int GetSize() const

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

inline Attributes &DoSet(const std::string &in_set, const std::string &in_val)

Set the specified setting to the specified value.

inline Attributes &DoAddAttr(const std::string in_attr, const std::string &in_val)

Append a new value to an existing attribute

Parameters:
  • in_attr – attribute name

  • in_val – attribute value to be added

inline std::string GetAttrValue(const std::string &in_set)
template<typename SET_TYPE>
inline Attributes &Set(const std::string &s, SET_TYPE v)

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

inline Attributes &Insert(const Attributes &in_attr)

Set all values from in_attr 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 Attributes obj.

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

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

inline const std::map<std::string, std::string> &GetMap() const
inline void Remove(const std::string &setting)
inline void Clear()

Remove all setting values.

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

Apply ALL of the Attribute’s settings to dom element “widget_id”.

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

Apply only a SPECIFIC attributes setting from the setting library to widget_id.

inline operator bool() const

Convert to true if there are any setting, false otherwise.

Public Static Functions

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

Apply onlay a SPECIFIC attributes setting with a specifid value!

Private Members

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