A word, that is, a string with very few properties.
More...
#include <words.h>
|
int | len |
| The length of the word (without the terminating zero character). More...
|
|
char * | txt |
| A memory buffer containing the word. More...
|
|
A word, that is, a string with very few properties.
Definition at line 64 of file words.h.
◆ word() [1/3]
chomp::homology::word::word |
( |
| ) |
|
|
inline |
Default constructor of an empty word.
Definition at line 112 of file words.h.
113{
116 return;
117}
char * txt
A memory buffer containing the word.
int len
The length of the word (without the terminating zero character).
References len, and txt.
◆ word() [2/3]
chomp::homology::word::word |
( |
const char * |
s | ) |
|
|
inline |
Constructor of a word based on a given C-style string.
Definition at line 119 of file words.h.
120{
121 len = s ? strlen (s) : 0;
124 else
125 {
128 throw "Not enough memory to create a word.";
130 }
131 return;
132}
References len, and txt.
◆ word() [3/3]
chomp::homology::word::word |
( |
const word & |
w | ) |
|
|
inline |
Copy constructor.
Definition at line 134 of file words.h.
135{
139 else
140 {
143 throw "Not enough memory to copy a word.";
145 }
146 return;
147}
References len, and txt.
◆ ~word()
chomp::homology::word::~word |
( |
| ) |
|
|
inline |
Destructor.
Definition at line 149 of file words.h.
References txt.
◆ length()
int chomp::homology::word::length |
( |
| ) |
const |
|
inline |
Returns the length of the word (without the ending zero char).
Definition at line 173 of file words.h.
References len.
◆ operator const char *()
chomp::homology::word::operator const char * |
( |
| ) |
const |
|
inline |
Returns a pointer to the contents of the word.
Definition at line 183 of file words.h.
◆ operator int()
chomp::homology::word::operator int |
( |
| ) |
const |
|
inline |
Returns the value of the number contained in the word; allows a preceding '+'.
Definition at line 214 of file words.h.
215{
217 return 0;
219 if (*s == '+')
220 ++ s;
221 int num;
222 std::istringstream str (s);
223 str >> num;
224 if (!str)
225 return 0;
226 else
227 return num;
228}
◆ operator+()
word chomp::homology::word::operator+ |
( |
const word & |
w | ) |
const |
|
inline |
Word concatenation operator.
Definition at line 207 of file words.h.
208{
210 new_w += w;
211 return new_w;
212}
word()
Default constructor of an empty word.
◆ operator+=()
word & chomp::homology::word::operator+= |
( |
const word & |
w | ) |
|
|
inline |
Word concatenation operator.
Definition at line 188 of file words.h.
189{
191 {
192 *this = w;
193 return *this;
194 }
196 return *this;
197 int newlen =
len + w.
len;
198 char *newtxt = new char [newlen + 1];
199 strcpy (newtxt,
txt);
200 strcat (newtxt, w.
txt);
204 return *this;
205}
References len, and txt.
◆ operator=()
word & chomp::homology::word::operator= |
( |
const word & |
w | ) |
|
|
inline |
Assignment operator.
Definition at line 156 of file words.h.
157{
162 {
165 throw "Not enough memory to copy a word.";
167 }
168 else
170 return *this;
171}
References len, and txt.
◆ text()
const char * chomp::homology::word::text |
( |
| ) |
const |
|
inline |
Returns a pointer to the contents of the word.
Definition at line 178 of file words.h.
References txt.
◆ len
int chomp::homology::word::len |
|
private |
◆ txt
char* chomp::homology::word::txt |
|
private |
The documentation for this class was generated from the following file: