BoolAttribute.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "main.h"
  2. #include "attributes.h"
  3. _bool_base::_bool_base() : value(false) {}
  4. bool _bool_base::GetBool()
  5. {
  6. return value;
  7. }
  8. void _bool_base::SetBool(bool boolValue)
  9. {
  10. value = boolValue;
  11. }
  12. intptr_t _bool_base::GetInt()
  13. {
  14. return value ? 1 : 0;
  15. }
  16. void _bool_base::SetInt(intptr_t intValue)
  17. {
  18. value = !!intValue;
  19. }
  20. _bool_base::operator intptr_t()
  21. {
  22. return GetInt();
  23. }
  24. intptr_t _bool_base::operator =(intptr_t intValue)
  25. {
  26. value = !!intValue;
  27. return GetInt();
  28. }
  29. bool _bool_base::operator =(bool boolValue)
  30. {
  31. value = boolValue;
  32. return GetBool();
  33. }
  34. _bool_base::operator bool()
  35. {
  36. return value;
  37. }
  38. _bool_base::operator UINT()
  39. {
  40. return value?1:0;
  41. }
  42. bool _bool_base::operator !()
  43. {
  44. return !value;
  45. }
  46. /* --------------------- */
  47. _bool::_bool(bool defaultValue)
  48. {
  49. value = defaultValue;
  50. }
  51. #define CBCLASS _bool
  52. START_DISPATCH;
  53. CB(IFC_CONFIGITEM_GETBOOL, GetBool)
  54. CB(IFC_CONFIGITEM_GETINT, GetInt)
  55. END_DISPATCH;
  56. #undef CBCLASS
  57. /* --------------------- */
  58. _mutable_bool::_mutable_bool(bool defaultValue)
  59. {
  60. value = defaultValue;
  61. }
  62. #define CBCLASS _mutable_bool
  63. START_DISPATCH;
  64. CB(IFC_CONFIGITEM_GETBOOL, GetBool)
  65. CB(IFC_CONFIGITEM_GETINT, GetInt)
  66. VCB(IFC_CONFIGITEM_SETINT, SetInt)
  67. VCB(IFC_CONFIGITEM_SETBOOL, SetBool)
  68. END_DISPATCH;
  69. #undef CBCLASS