Evita  0.16
evString.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evString_h
25 #define __evString_h
26 
27 
28 #define EVSTRINGLEN QCCSTRINGLEN
29 
30 class evString
31 {
32 public:
33  evString(void);
34  evString(const char *string);
35  evString(const evString &string);
36 
37  virtual ~evString(void);
38 
39  virtual const evString GetClassName(void) const
40  {
41  return(evString("evString"));
42  }
43 
44  void MakeNull(void);
45  int IsNull(void) const;
46 
47  int Length(void) const;
48 
49  char *GetString(void);
50  char const *GetString(void) const;
51  void SetString(const char *string);
52 
53  evString operator = (const evString &string);
54  int operator == (const evString &string) const;
55  int operator != (const evString &string) const;
56 
57  void Sprintf(const char *format, ...);
58 
59 protected:
60 
61 private:
62  char String[EVSTRINGLEN + 1];
63 
64 };
65 
66 
67 inline evString::evString(void)
68 {
69  this->MakeNull();
70 }
71 
72 
73 inline evString::evString(const char *string)
74 {
75  this->MakeNull();
76  this->SetString(string);
77 }
78 
79 
80 inline evString::evString(const evString &string)
81 {
82  this->MakeNull();
83  this->SetString(string.String);
84 }
85 
86 
87 inline evString::~evString(void)
88 {
89 }
90 
91 
92 inline void evString::MakeNull(void)
93 {
94  this->String[0] = '\0';
95 }
96 
97 
98 inline int evString::IsNull(void) const
99 {
100  return(strlen(this->String) <= 0);
101 }
102 
103 
104 inline int evString::Length(void) const
105 {
106  return(strlen(this->String));
107 }
108 
109 
110 inline char *evString::GetString(void)
111 {
112  return(this->String);
113 }
114 
115 
116 inline const char *evString::GetString(void) const
117 {
118  return(this->String);
119 }
120 
121 
122 inline void evString::SetString(const char *string)
123 {
124  if (string == NULL)
125  this->MakeNull();
126  else
127  {
128  strncpy(this->String, string, EVSTRINGLEN);
129  this->String[QCCSTRINGLEN] = '\0';
130  }
131 }
132 
133 
135 {
136  this->SetString(string.String);
137 
138  return(*this);
139 }
140 
141 
142 inline int evString::operator == (const evString &string) const
143 {
144  if (!strcmp(this->GetString(), string.GetString()))
145  return(1);
146  else
147  return(0);
148 }
149 
150 
151 inline int evString::operator != (const evString &string) const
152 {
153  return(!(*this == string));
154 }
155 
156 
157 #endif
int operator!=(const evString &string) const
Definition: evString.h:151
char * GetString(void)
Definition: evString.h:110
evString(void)
Definition: evString.h:67
void Sprintf(const char *format,...)
#define EVSTRINGLEN
Definition: evString.h:28
virtual const evString GetClassName(void) const
Definition: evString.h:39
char String[EVSTRINGLEN+1]
Definition: evString.h:62
int Length(void) const
Definition: evString.h:104
virtual ~evString(void)
Definition: evString.h:87
void MakeNull(void)
Definition: evString.h:92
int operator==(const evString &string) const
Definition: evString.h:142
void SetString(const char *string)
Definition: evString.h:122
int IsNull(void) const
Definition: evString.h:98
Definition: evString.h:30
evString operator=(const evString &string)
Definition: evString.h:134