attrint.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _ATTRINT_H
  2. #define _ATTRINT_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 Integer configuration attribute.
  9. @ver 1.0
  10. @author Nullsoft
  11. @see CfgItemI
  12. @see _bool
  13. @see _string
  14. @see _float
  15. */
  16. class _int : public Attribute {
  17. public:
  18. /**
  19. Optionally set the name and default value of
  20. your configuration attribute during construction.
  21. @param name Name of the configuration attribute.
  22. @param default_val Default value.
  23. */
  24. _int(const wchar_t *name=NULL, int default_val=0) : Attribute(name) {
  25. setValueAsInt(default_val, true);
  26. }
  27. // from AttributeI
  28. /**
  29. Get the attribute type. This will return
  30. a constant representing the attribute type.
  31. These constants can be: BOOL, FLOAT, STRING and INT.
  32. @see AttributeType
  33. @ret The attribute type.
  34. */
  35. virtual int getAttributeType() { return AttributeType::INT; }
  36. /**
  37. Get the configuration group to be used to represent
  38. this attribute in the registry.
  39. @ret Config group to be used.
  40. */
  41. virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.int"; }
  42. // virtual int getPermissions();
  43. // convenience operators
  44. /**
  45. Get the value of the attribute.
  46. */
  47. operator int() { return getValueAsInt(); }
  48. /**
  49. Set the value of the attribute.
  50. */
  51. int operator =(int newval) { return setValueAsInt(newval) ? newval : getValueAsInt(); }
  52. };
  53. #endif