source: trunk/vizservers/nanovis/R2/src/R2string.cpp @ 835

Last change on this file since 835 was 835, checked in by gah, 17 years ago

More clean up. Added dxReader.cpp

File size: 1.1 KB
Line 
1#include <R2/R2string.h>
2#include <string.h>
3
4R2string::R2string() : _string(NULL), _length(0)
5{
6}
7
8R2string::R2string(const char* str) : _string(NULL), _length(0)
9{
10        if (str != NULL)
11        {
12                set(str, (R2int32) strlen(str));
13        }
14}
15
16R2string::R2string(const R2string& string) : _string(NULL)
17{
18        set(string._string, string._length);
19}
20
21R2string::~R2string()
22{
23    delete [] _string;
24}
25
26R2string& R2string::operator=(const R2string& string)
27{
28        set(string._string, string._length);
29
30        return *this;
31}
32
33R2string& R2string::operator=(const char* string)
34{
35        set(string, strlen(string));
36
37        return *this;
38}
39
40R2string operator+(const R2string& string1, const R2string& string2)
41{
42        R2string ret;
43        ret._length = string1._length + string2._length;
44        ret._string = new R2char[ret._length + 1];
45       
46        strcpy(ret._string, string1._string);
47        strcpy(ret._string + string1._length, string2._string);
48       
49        return ret;
50}
51
52
53R2string operator+(const R2string& string1, const char* string2)
54{
55        R2string ret;
56        ret._length = string1._length + strlen(string2);
57        ret._string = new R2char[ret._length + 1];
58       
59        strcpy(ret._string, string1._string);
60        strcpy(ret._string + string1._length, string2);
61       
62        return ret;
63}
Note: See TracBrowser for help on using the repository browser.