ANNA Suite  2020b
Multipurpose development suite for Telco applications
String.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_dbms_String_hpp
10 #define anna_dbms_String_hpp
11 
13 
14 #include <anna/dbms/Data.hpp>
15 
16 namespace anna {
17 
18 namespace dbms {
19 
23 class String : public Data {
24 public:
31  explicit String(const int maxSize, const bool isNulleable = false) :
32  Data(Type::String, maxSize, isNulleable) {
33  Data::setBuffer(a_value = new char [maxSize + 1]);
34  anna_memset(a_value, 0, maxSize + 1);
35  }
36 
41  String(const String& other) :
42  Data(other),
43  a_value(other.a_value) {
44  const int maxSize = getMaxSize();
45  Data::setBuffer(a_value = new char [maxSize + 1]);
46  anna_memset(a_value, 0, maxSize + 1);
47  }
48 
52  virtual ~String() { delete [] a_value; }
53 
59  const char* getValue() const { return a_value; }
60 
67  String& operator = (const String& str) noexcept(false);
68 
75  String& operator = (const char* str) noexcept(false);
76 
83  String& operator = (const std::string& str) noexcept(false) { return operator= (str.c_str()); }
84 
90  operator const char*() const { return (Data::isNull() == true) ? NULL : a_value; }
91 
96  static char* strip(char *str) ;
97 
102  virtual std::string asString() const ;
103 
104 private:
105  char* a_value;
106 
107  void do_clear() { a_value [0] = 0; }
108 };
109 
110 }
111 }
112 
113 #endif
114 
String(const String &other)
Definition: String.hpp:41
String(const int maxSize, const bool isNulleable=false)
Definition: String.hpp:31
virtual ~String()
Definition: String.hpp:52
bool isNull() const
Definition: Data.hpp:62
void setBuffer(void *buffer)
Definition: Data.hpp:131
static char * strip(char *str)
#define anna_memset(a, b, c)
Definition: defines.hpp:43
Definition: Data.hpp:29
Definition: Data.hpp:27
int getMaxSize() const
Definition: Data.hpp:45
virtual std::string asString() const
Definition: String.hpp:25
String & operator=(const char *vv)
Definition: String.hpp:74
const char * getValue() const
Definition: String.hpp:59
Definition: app.hpp:12
bool isNulleable() const
Definition: Data.hpp:68