Kigs Framework  Doc version 0.8
Open source multi purpose Rapid Application Development framework
maUSString.h
1 #ifndef _MAUSSTRING_H
2 #define _MAUSSTRING_H
3 
5 #include "usString.h"
6 #include "AttributeModifier.h"
7 
8 // ****************************************
9 // * maUSStringHeritage class
10 // * --------------------------------------
16 // ****************************************
17 template<int notificationLevel>
18 class maUSStringHeritage : public CoreModifiableAttributeData<usString>
19 {
20  DECLARE_ATTRIBUTE_HERITAGE(maUSStringHeritage, maUSStringHeritage, usString, CoreModifiable::ATTRIBUTE_TYPE::USSTRING);
21 
22 public:
23 
25  maUSStringHeritage(CoreModifiable& owner, bool isInitAttribute, KigsID ID, const kstl::string& value ) : CoreModifiableAttributeData<usString>(owner, isInitAttribute, ID)
26  {
27  mValue = usString{ value };
28  }
29 
30 
31 
33  virtual bool getValue(kstl::string& value) const override
34  {
35  usString copy(mValue);
36  value = copy.ToString();
37  return true;
38  }
39  virtual bool getValue(usString& value) const override
40  {
41  value = mValue;
42  return true;
43  }
44  virtual bool getValue(void*& value) const override
45  {
46  value = (void*)&mValue;
47  return true;
48  }
50 
52  virtual bool setValue(const char* value) override
53  {
54  if (this->isReadOnly())
55  return false;
56 
57  mValue = usString(value);
58 
59  DO_NOTIFICATION(notificationLevel);
60 
61  return true;
62  }
63  virtual bool setValue(const kstl::string& value) override
64  {
65  if (this->isReadOnly())
66  return false;
67 
68  mValue = value;
69 
70  DO_NOTIFICATION(notificationLevel);
71 
72  return false;
73  }
74  virtual bool setValue(const unsigned short* value) override
75  {
76  if (this->isReadOnly())
77  return false;
78 
79  mValue = value;
80  DO_NOTIFICATION(notificationLevel);
81 
82  return true;
83  }
84  virtual bool setValue(const usString& value) override
85  {
86  if (this->isReadOnly())
87  return false;
88 
89  mValue = value;
90  DO_NOTIFICATION(notificationLevel);
91  return true;
92  }
93 
94  virtual bool setValue(const UTF8Char* value) override
95  {
96  if (this->isReadOnly())
97  return false;
98 
99  mValue = value;
100 
101  DO_NOTIFICATION(notificationLevel);
102 
103  return false;
104  }
105 
107 
109  // Assign
110  auto& operator=(const unsigned short* attribute)
111  {
112  mValue = attribute;
113  return *this;
114  }
115  auto& operator=(kstl::string& attribute)
116  {
117  mValue = attribute;
118  return *this;
119  }
120  auto& operator=(const char* attribute)
121  {
122  mValue = attribute;
123  return *this;
124  }
125 
126  // Comparison
127  bool operator==(const usString& L_value) const
128  {
129  return (mValue == L_value);
130  }
131  bool operator==(unsigned short* L_value) const
132  {
133  return (mValue == L_value);
134  }
135  bool operator!=(const usString& L_value) const
136  {
137  return (mValue != L_value);
138  }
139  bool operator!=(unsigned short* L_value) const
140  {
141  return (mValue != L_value);
142  }
143 
144  // Append
145  auto& operator+=(const usString& value)
146  {
147  mValue += value;
148  return *this;
149  }
150  auto& operator+=(unsigned short* value)
151  {
152  mValue += value;
153  return *this;
154  }
155  auto& operator+=(const CoreModifiableAttribute& value)
156  {
157  usString L_tmp = usString("");
158  if(value.getValue(L_tmp))
159  mValue += L_tmp;
160  return *this;
161  }
163 
165  const unsigned short* us_str() const { return mValue.us_str(); }
166  kstl::string ToString() { return mValue.ToString(); }
167  void strcpywUtoC(char * _Dest, const unsigned short * src) { mValue.strcpywUtoC(_Dest, src); }
168  kstl::vector<usString> SplitByCharacter(unsigned short value) const { return mValue.SplitByCharacter(value); }
169  unsigned int strlen() const { return mValue.strlen(); }
170 
171 };
172 
173 
175 
176 
177 
178 #endif //_MAUSSTRING_H
CoreModifiableAttribute::isReadOnly
virtual bool isReadOnly()
Read only attributes cannot be modified with setValue.
Definition: CoreModifiableAttribute.h:276
maUSStringHeritage::operator=
auto & operator=(const unsigned short *attribute)
operators
Definition: maUSString.h:110
maUSStringHeritage::us_str
const unsigned short * us_str() const
return a const unsigned short* pointer on internal value
Definition: maUSString.h:165
maUSStringHeritage::maUSStringHeritage
maUSStringHeritage(CoreModifiable &owner, bool isInitAttribute, KigsID ID, const kstl::string &value)
Extra constructors.
Definition: maUSString.h:25
CoreModifiable
Base class for Kigs framework objects. CoreModifiable class manage a list of attributes supporting re...
Definition: CoreModifiable.h:400
maUSStringHeritage
CoreModifiableAttributeData of usstring with different level of notification.
Definition: maUSString.h:18
maUSStringHeritage::getValue
virtual bool getValue(kstl::string &value) const override
getValue overloads
Definition: maUSString.h:33
maUSStringHeritage::setValue
virtual bool setValue(const char *value) override
setValue overloads
Definition: maUSString.h:52
CoreModifiableAttribute.h
Base template class for CoreModifiable attributes managing data.
CoreModifiableAttribute
Base class for all CoreModifiableAttribute . This class is just composed of virtual methods.
Definition: CoreModifiableAttribute.h:145