|
0
|
1 |
#include "mystring.h"
|
|
|
2 |
#include "trace.h"
|
|
|
3 |
#include <ctype.h>
|
|
|
4 |
#include <string.h>
|
|
|
5 |
|
|
|
6 |
void mystring::dupnil()
|
|
|
7 |
{
|
|
|
8 |
trace("");
|
|
|
9 |
rep = &nil;
|
|
|
10 |
rep->attach();
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
void mystring::assign(const char* in)
|
|
|
14 |
{
|
|
|
15 |
if(in)
|
|
|
16 |
assign(in, strlen(in));
|
|
|
17 |
else {
|
|
|
18 |
mystringrep* tmp = rep;
|
|
|
19 |
dupnil();
|
|
|
20 |
tmp->detach();
|
|
|
21 |
}
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
void mystring::assign(const char* in, size_t len)
|
|
|
25 |
{
|
|
|
26 |
trace("in='" << in << "'");
|
|
|
27 |
if(in != rep->buf) {
|
|
|
28 |
mystringrep* tmp = rep;
|
|
|
29 |
dup(in, len);
|
|
|
30 |
tmp->detach();
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
void mystring::dup(const char* in, size_t len)
|
|
|
35 |
{
|
|
|
36 |
trace("in='" << in << "'");
|
|
|
37 |
rep = mystringrep::dup(in, len);
|
|
|
38 |
rep->attach();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
void mystring::dup(const char* in)
|
|
|
42 |
{
|
|
|
43 |
if(in)
|
|
|
44 |
dup(in, strlen(in));
|
|
|
45 |
else
|
|
|
46 |
dupnil();
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
void mystring::operator=(const mystringjoin& in)
|
|
|
50 |
{
|
|
|
51 |
mystringrep* tmp = rep;
|
|
|
52 |
rep = in.traverse();
|
|
|
53 |
rep->attach();
|
|
|
54 |
tmp->detach();
|
|
|
55 |
}
|