[mareframe] Annotation of /trunk/gadget/strstack.cc
Annotation of /trunk/gadget/strstack.cc
Parent Directory
| Revision Log
Revision 20 -
(view)
(download)
1 : |
agomez |
1 |
#include "strstack.h" |
2 : |
|
|
#include "gadget.h" |
3 : |
agomez |
20 |
#include "omp.h"
|
4 : |
agomez |
1 |
|
5 : |
|
|
StrStack::~StrStack() {
|
6 : |
|
|
int i;
|
7 : |
|
|
for (i = 0; i < v.Size(); i++)
|
8 : |
|
|
delete[] v[i];
|
9 : |
|
|
}
|
10 : |
|
|
|
11 : |
|
|
void StrStack::clearString() {
|
12 : |
agomez |
20 |
#pragma omp critical
|
13 : |
agomez |
1 |
if (size > 0)
|
14 : |
|
|
size--;
|
15 : |
|
|
}
|
16 : |
|
|
|
17 : |
|
|
void StrStack::storeString(const char* str) {
|
18 : |
agomez |
20 |
#pragma omp critical
|
19 : |
|
|
{
|
20 : |
agomez |
1 |
if (size == v.Size()) {
|
21 : |
|
|
v.resize(new char[MaxStrLength]);
|
22 : |
|
|
strncpy(v[size], "", MaxStrLength);
|
23 : |
|
|
}
|
24 : |
|
|
strcpy(v[size], str);
|
25 : |
|
|
size++;
|
26 : |
|
|
}
|
27 : |
agomez |
20 |
}
|
28 : |
agomez |
1 |
|
29 : |
|
|
char* StrStack::sendAll() const {
|
30 : |
|
|
int i, len;
|
31 : |
|
|
len = size * MaxStrLength;
|
32 : |
|
|
char* rstr = new char[len];
|
33 : |
|
|
strncpy(rstr, "", len);
|
34 : |
|
|
for (i = 0; i < size; i++)
|
35 : |
|
|
strcat(rstr, v[i]);
|
36 : |
|
|
|
37 : |
|
|
return rstr;
|
38 : |
|
|
}
|
39 : |
|
|
|
40 : |
|
|
char* StrStack::sendTop() const {
|
41 : |
|
|
char* rstr = new char[MaxStrLength];
|
42 : |
|
|
strncpy(rstr, "", MaxStrLength);
|
43 : |
|
|
if (size != 0)
|
44 : |
|
|
strcpy(rstr, v[size - 1]);
|
45 : |
|
|
|
46 : |
|
|
return rstr;
|
47 : |
|
|
}
|
|