1
0

attrbool.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _ATTRBOOL_H
  2. #define _ATTRBOOL_H
  3. #include "attribute.h"
  4. // inherit from this one, or just use it
  5. /**
  6. Boolean configuration attributes have two values, true or false.
  7. They can be used like any other config item.
  8. @short Boolean configuration attribute.
  9. @ver 1.0
  10. @author Nullsoft
  11. @see _int
  12. @see _string
  13. @see _float
  14. */
  15. class _bool : public Attribute {
  16. public:
  17. /**
  18. Optionally set the name and default value of
  19. your configuration attribute during construction.
  20. @param name Name of the configuration attribute.
  21. @param default_val Default value.
  22. */
  23. _bool(const wchar_t *name=NULL, int default_val=0) : Attribute(name) {
  24. setValueAsInt(!!default_val, true);
  25. }
  26. // convenience operators
  27. /**
  28. Get the value of the attribute.
  29. */
  30. operator bool() { return !!getValueAsInt(); }
  31. /**
  32. Set the value of the attribute.
  33. */
  34. bool operator =(int newval) { setValueAsInt(!!newval); return *this; }
  35. // from Attribute
  36. /**
  37. Get the attribute type. This will return
  38. a constant representing the attribute type.
  39. These constants can be: BOOL, FLOAT, STRING and INT.
  40. @see AttributeType
  41. @ret The attribute type.
  42. */
  43. virtual int getAttributeType() { return AttributeType::BOOL; }
  44. /**
  45. Get the configuration group to be used to represent
  46. this attribute in the registry.
  47. @ret Config group to be used.
  48. */
  49. virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.bool"; }
  50. };
  51. #endif