1
- #ifndef xrstringH
2
- #define xrstringH
3
1
#pragma once
4
2
5
3
// TODO: tamlin: Get rid of _std_extensions.h as compile-time dependency, if possible.
6
4
#include " _types.h"
7
5
#include " _std_extensions.h"
8
6
9
7
#pragma pack(push, 4)
10
- // ////////////////////////////////////////////////////////////////////////
11
- // TODO: tamlin: Get rid of this blobal namespace polluting silly typedef.
12
- typedef const char * str_c;
13
-
14
- // ////////////////////////////////////////////////////////////////////////
15
8
#pragma warning(push)
16
9
#pragma warning(disable : 4200)
17
10
struct XRCORE_API str_value
@@ -45,7 +38,7 @@ class XRCORE_API str_container
45
38
str_container ();
46
39
~str_container ();
47
40
48
- str_value* dock (str_c value);
41
+ str_value* dock (pcstr value);
49
42
void clean ();
50
43
void dump ();
51
44
void dump (IWriter* W);
@@ -60,7 +53,6 @@ XRCORE_API extern str_container* g_pStringContainer;
60
53
// ////////////////////////////////////////////////////////////////////////
61
54
class shared_str
62
55
{
63
- private:
64
56
str_value* p_;
65
57
66
58
protected:
@@ -75,7 +67,7 @@ class shared_str
75
67
}
76
68
77
69
public:
78
- void _set (str_c rhs)
70
+ void _set (pcstr rhs)
79
71
{
80
72
str_value* v = g_pStringContainer->dock (rhs);
81
73
if (0 != v)
@@ -98,7 +90,7 @@ class shared_str
98
90
public:
99
91
// construction
100
92
shared_str () { p_ = 0 ; }
101
- shared_str (str_c rhs)
93
+ shared_str (pcstr rhs)
102
94
{
103
95
p_ = 0 ;
104
96
_set (rhs);
@@ -110,7 +102,7 @@ class shared_str
110
102
}
111
103
~shared_str () { _dec (); }
112
104
// assignment & accessors
113
- shared_str& operator =(str_c rhs)
105
+ shared_str& operator =(pcstr rhs)
114
106
{
115
107
_set (rhs);
116
108
return (shared_str&)*this ;
@@ -121,10 +113,10 @@ class shared_str
121
113
return (shared_str&)*this ;
122
114
}
123
115
// XXX tamlin: Remove operator*(). It may be convenient, but it's dangerous. Use
124
- str_c operator *() const { return p_ ? p_->value : 0 ; }
116
+ pcstr operator *() const { return p_ ? p_->value : 0 ; }
125
117
bool operator !() const { return p_ == 0 ; }
126
118
char operator [](size_t id) { return p_->value [id]; }
127
- str_c c_str () const { return p_ ? p_->value : 0 ; }
119
+ pcstr c_str () const { return p_ ? p_->value : 0 ; }
128
120
// misc func
129
121
u32 size () const
130
122
{
@@ -172,5 +164,3 @@ IC int xr_strcmp(const shared_str& a, const shared_str& b) throw()
172
164
void xr_strlwr (shared_str& src);
173
165
174
166
#pragma pack(pop)
175
-
176
- #endif
0 commit comments