1
0

attrstr.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _ATTRSTR_H
  2. #define _ATTRSTR_H
  3. #include "attribute.h"
  4. #include <bfc/string/bfcstring.h>
  5. #include <bfc/common.h>
  6. /**
  7. String configuration attributes, can have any string value
  8. of any length. They can be used like any other config item.
  9. @short String configuration attribute.
  10. @ver 1.0
  11. @author Nullsoft
  12. @see _int
  13. @see _bool
  14. @see _float
  15. */
  16. class _string : public Attribute {
  17. public:
  18. /**
  19. Optionally set the name and default value of
  20. your configuration attribute during construction.
  21. @param name
  22. @param default_val
  23. */
  24. _string(const wchar_t *name=NULL, const wchar_t *default_val=NULL)
  25. : Attribute(name) {
  26. setData(default_val, true);
  27. }
  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::STRING; }
  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.string"; }
  42. //CUT virtual int getPermissions() { return ATTR_PERM_ALL; }
  43. /**
  44. Get the value of the attribute.
  45. @ret The value of the attribute
  46. */
  47. const wchar_t *getValue();
  48. /**
  49. Set the value of the attribute.
  50. @param val The value you want to set.
  51. @ret 1, success; 0, failure;
  52. */
  53. int setValue(const wchar_t *val) { return setData(val); }
  54. // convenience operators
  55. /**
  56. Get the value of the attribute.
  57. */
  58. operator const wchar_t *() { return getValue(); }
  59. /**
  60. Set the value of the attribute.
  61. */
  62. const wchar_t *operator =(const wchar_t *newval) { return setValue(newval) ? newval : getValue(); }
  63. private:
  64. StringW returnval;
  65. };
  66. #endif