Skip to content

Commit e311ece

Browse files
committed
Get rid of global namespace polluting silly typedef.
1 parent 2a44a75 commit e311ece

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/xrCore/xrstring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ str_container::str_container() :
144144
#endif
145145
{}
146146

147-
str_value* str_container::dock(str_c value)
147+
str_value* str_container::dock(pcstr value)
148148
{
149149
if (0 == value)
150150
return 0;

src/xrCore/xrstring.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
#ifndef xrstringH
2-
#define xrstringH
31
#pragma once
42

53
// TODO: tamlin: Get rid of _std_extensions.h as compile-time dependency, if possible.
64
#include "_types.h"
75
#include "_std_extensions.h"
86

97
#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-
//////////////////////////////////////////////////////////////////////////
158
#pragma warning(push)
169
#pragma warning(disable : 4200)
1710
struct XRCORE_API str_value
@@ -45,7 +38,7 @@ class XRCORE_API str_container
4538
str_container();
4639
~str_container();
4740

48-
str_value* dock(str_c value);
41+
str_value* dock(pcstr value);
4942
void clean();
5043
void dump();
5144
void dump(IWriter* W);
@@ -60,7 +53,6 @@ XRCORE_API extern str_container* g_pStringContainer;
6053
//////////////////////////////////////////////////////////////////////////
6154
class shared_str
6255
{
63-
private:
6456
str_value* p_;
6557

6658
protected:
@@ -75,7 +67,7 @@ class shared_str
7567
}
7668

7769
public:
78-
void _set(str_c rhs)
70+
void _set(pcstr rhs)
7971
{
8072
str_value* v = g_pStringContainer->dock(rhs);
8173
if (0 != v)
@@ -98,7 +90,7 @@ class shared_str
9890
public:
9991
// construction
10092
shared_str() { p_ = 0; }
101-
shared_str(str_c rhs)
93+
shared_str(pcstr rhs)
10294
{
10395
p_ = 0;
10496
_set(rhs);
@@ -110,7 +102,7 @@ class shared_str
110102
}
111103
~shared_str() { _dec(); }
112104
// assignment & accessors
113-
shared_str& operator=(str_c rhs)
105+
shared_str& operator=(pcstr rhs)
114106
{
115107
_set(rhs);
116108
return (shared_str&)*this;
@@ -121,10 +113,10 @@ class shared_str
121113
return (shared_str&)*this;
122114
}
123115
// 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; }
125117
bool operator!() const { return p_ == 0; }
126118
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; }
128120
// misc func
129121
u32 size() const
130122
{
@@ -172,5 +164,3 @@ IC int xr_strcmp(const shared_str& a, const shared_str& b) throw()
172164
void xr_strlwr(shared_str& src);
173165

174166
#pragma pack(pop)
175-
176-
#endif

src/xrGame/game_cl_capture_the_artefact.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ void game_cl_CaptureTheArtefact::OnVoteStart(NET_Packet& P)
12891289
{
12901290
if (!xr_strcmp(cmd_name, ttable[i][0]))
12911291
{
1292-
str_c ted_str = st.translate(ttable[i][1]).c_str();
1292+
pcstr ted_str = st.translate(ttable[i][1]).c_str();
12931293
VERIFY(ted_str);
12941294
tcmd_len = xr_strlen(ted_str) + 1;
12951295
tcmd_name = static_cast<char*>(_alloca(tcmd_len));
@@ -1312,7 +1312,7 @@ void game_cl_CaptureTheArtefact::OnVoteStart(NET_Packet& P)
13121312
xr_strcat(vstr, vstr_size, " ");
13131313
xr_strcat(vstr, vstr_size, st.translate(args[i]).c_str());
13141314
}
1315-
str_c t_vote_str = st.translate("mp_voting_started").c_str();
1315+
pcstr t_vote_str = st.translate("mp_voting_started").c_str();
13161316
VERIFY(t_vote_str);
13171317
u32 fin_str_size = xr_strlen(t_vote_str) + vstr_size + xr_strlen(player) + 1;
13181318
char* fin_str = static_cast<char*>(_alloca(fin_str_size));

0 commit comments

Comments
 (0)