Kigs Framework  Doc version 0.8
Open source multi purpose Rapid Application Development framework
maString.h
1 #pragma once
2 
4 #include "AttributeModifier.h"
5 
6 // ****************************************
7 // * maStringHeritage class
8 // * --------------------------------------
14 // ****************************************
15 
16 template<int notificationLevel>
17 class maStringHeritage : public CoreModifiableAttributeData<kstl::string>
18 {
19  DECLARE_ATTRIBUTE_HERITAGE(maStringHeritage, maStringHeritage, kstl::string, CoreModifiable::ATTRIBUTE_TYPE::STRING);
20 
21 public:
22 
23 
26  const char* c_str() const { return mValue.c_str(); }
27 
28 
29  // getValue overloads
30  virtual bool getValue(kstl::string& value) const override
31  {
32  kstl::string tmpValue = this->mValue;
33  CALL_GETMODIFIER(notificationLevel, tmpValue);
34  value = tmpValue;
35  return true;
36  }
37  virtual bool getValue(usString& value) const override
38  {
39  kstl::string tmpValue = this->mValue;
40  CALL_GETMODIFIER(notificationLevel, tmpValue);
41  value = tmpValue;
42  return true;
43  }
44  virtual bool getValue(void*& value) const override
45  {
46  value = (void*)&mValue;
47  return true;
48  }
49 
50  virtual bool getValue(float& value) const override
51  {
52  value = (float)atof(mValue.c_str());
53  return true;
54  }
55 
57 
58  // setValue overloads
59  virtual bool setValue(const char* value) override
60  {
61  if (this->isReadOnly())
62  return false;
63 
64  kstl::string tmpValue = value;
65  CALL_SETMODIFIER(notificationLevel, tmpValue);
66  this->mValue = tmpValue;
67  DO_NOTIFICATION(notificationLevel);
68  return true;
69  }
70  virtual bool setValue(const kstl::string& value) override
71  {
72  if (this->isReadOnly())
73  return false;
74 
75  kstl::string tmpValue = value;
76  CALL_SETMODIFIER(notificationLevel, tmpValue);
77  this->mValue = tmpValue;
78  DO_NOTIFICATION(notificationLevel);
79  return true;
80  }
82 
83  // operators
84  auto& operator+=(const kstl::string& attribute)
85  {
86  kstl::string val;
87  getValue(val);
88  val += attribute;
89  setValue(val);
90  return *this;
91  }
92  auto& operator+=(const char* attribute)
93  {
94  *this += kstl::string{ attribute };
95  return *this;
96  }
98 
99 
100 
101 };
102 
103 
104 STATIC_ASSERT_NOTIF_LEVEL_SIZES(maStringHeritage);
105 
106 
108 
CoreModifiableAttribute::isReadOnly
virtual bool isReadOnly()
Read only attributes cannot be modified with setValue.
Definition: CoreModifiableAttribute.h:276
maStringHeritage
CoreModifiableAttributeData of string with different level of notification.
Definition: maString.h:17
maStringHeritage::c_str
const char * c_str() const
Definition: maString.h:26
CoreModifiableAttribute.h
Base template class for CoreModifiable attributes managing data.