Skip to content

Commit fc6a52d

Browse files
committed
xrCore and xrGame XML: use own pcstr instead of Microsoft LPCSTR
1 parent 89cf211 commit fc6a52d

File tree

7 files changed

+61
-61
lines changed

7 files changed

+61
-61
lines changed

src/utils/xrSE_Factory/xrUIXmlParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "xrGame/ui_base.h"
66
#endif // XRGAME_EXPORTS
77

8-
shared_str CUIXml::correct_file_name(LPCSTR path, LPCSTR fn)
8+
shared_str CUIXml::correct_file_name(pcstr path, pcstr fn)
99
{
1010
#ifdef XRGAME_EXPORTS
1111
if (0 == xr_strcmp(path, UI_PATH) || 0 == xr_strcmp(path, "UI"))

src/utils/xrSE_Factory/xrUIXmlParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ class CUIXml : public XMLDocument
99
CUIXml();
1010
virtual ~CUIXml();
1111

12-
virtual shared_str correct_file_name(LPCSTR path, LPCSTR fn);
12+
virtual shared_str correct_file_name(pcstr path, pcstr fn);
1313
};

src/xrCore/XML/XMLDocument.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void ParseFile(LPCSTR path, CMemoryWriter& W, IReader* F, XMLDocument* xml)
4242
}
4343
}
4444

45-
void XMLDocument::Load(LPCSTR path_alias, LPCSTR path, LPCSTR _xml_filename)
45+
void XMLDocument::Load(pcstr path_alias, pcstr path, pcstr _xml_filename)
4646
{
4747
shared_str fn = correct_file_name(path, _xml_filename);
4848

@@ -52,7 +52,7 @@ void XMLDocument::Load(LPCSTR path_alias, LPCSTR path, LPCSTR _xml_filename)
5252
}
5353

5454
//инициализация и загрузка XML файла
55-
void XMLDocument::Load(LPCSTR path, LPCSTR xml_filename)
55+
void XMLDocument::Load(pcstr path, pcstr xml_filename)
5656
{
5757
xr_strcpy(m_xml_file_name, xml_filename);
5858
// Load and parse xml file
@@ -76,7 +76,7 @@ void XMLDocument::Load(LPCSTR path, LPCSTR xml_filename)
7676
m_root = m_Doc.FirstChildElement();
7777
}
7878

79-
XML_NODE* XMLDocument::NavigateToNode(XML_NODE* start_node, LPCSTR path, int node_index)
79+
XML_NODE* XMLDocument::NavigateToNode(XML_NODE* start_node, pcstr path, int node_index)
8080
{
8181
R_ASSERT3(start_node && path, "NavigateToNode failed in XML file ", m_xml_file_name);
8282
XML_NODE* node = NULL;
@@ -119,12 +119,12 @@ XML_NODE* XMLDocument::NavigateToNode(XML_NODE* start_node, LPCSTR path, int nod
119119
return node;
120120
}
121121

122-
XML_NODE* XMLDocument::NavigateToNode(LPCSTR path, int node_index)
122+
XML_NODE* XMLDocument::NavigateToNode(pcstr path, int node_index)
123123
{
124124
return NavigateToNode(GetLocalRoot() ? GetLocalRoot() : GetRoot(), path, node_index);
125125
}
126126

127-
XML_NODE* XMLDocument::NavigateToNodeWithAttribute(LPCSTR tag_name, LPCSTR attrib_name, LPCSTR attrib_value)
127+
XML_NODE* XMLDocument::NavigateToNodeWithAttribute(pcstr tag_name, pcstr attrib_name, pcstr attrib_value)
128128
{
129129
XML_NODE* root = GetLocalRoot() ? GetLocalRoot() : GetRoot();
130130
int tabsCount = GetNodesNum(root, tag_name);
@@ -140,21 +140,21 @@ XML_NODE* XMLDocument::NavigateToNodeWithAttribute(LPCSTR tag_name, LPCSTR attri
140140
return NULL;
141141
}
142142

143-
LPCSTR XMLDocument::Read(LPCSTR path, int index, LPCSTR default_str_val)
143+
pcstr XMLDocument::Read(pcstr path, int index, pcstr default_str_val)
144144
{
145145
XML_NODE* node = NavigateToNode(path, index);
146146
LPCSTR result = Read(node, default_str_val);
147147
return result;
148148
}
149149

150-
LPCSTR XMLDocument::Read(XML_NODE* start_node, LPCSTR path, int index, LPCSTR default_str_val)
150+
pcstr XMLDocument::Read(XML_NODE* start_node, pcstr path, int index, pcstr default_str_val)
151151
{
152152
XML_NODE* node = NavigateToNode(start_node, path, index);
153153
LPCSTR result = Read(node, default_str_val);
154154
return result;
155155
}
156156

157-
LPCSTR XMLDocument::Read(XML_NODE* node, LPCSTR default_str_val)
157+
pcstr XMLDocument::Read(XML_NODE* node, pcstr default_str_val)
158158
{
159159
if (node == NULL)
160160
return default_str_val;
@@ -182,7 +182,7 @@ int XMLDocument::ReadInt(XML_NODE* node, int default_int_val)
182182
return atoi(result_str);
183183
}
184184

185-
int XMLDocument::ReadInt(LPCSTR path, int index, int default_int_val)
185+
int XMLDocument::ReadInt(pcstr path, int index, int default_int_val)
186186
{
187187
LPCSTR result_str = Read(path, index, NULL);
188188
if (result_str == NULL)
@@ -191,7 +191,7 @@ int XMLDocument::ReadInt(LPCSTR path, int index, int default_int_val)
191191
return atoi(result_str);
192192
}
193193

194-
int XMLDocument::ReadInt(XML_NODE* start_node, LPCSTR path, int index, int default_int_val)
194+
int XMLDocument::ReadInt(XML_NODE* start_node, pcstr path, int index, int default_int_val)
195195
{
196196
LPCSTR result_str = Read(start_node, path, index, NULL);
197197
if (result_str == NULL)
@@ -200,7 +200,7 @@ int XMLDocument::ReadInt(XML_NODE* start_node, LPCSTR path, int index, int defau
200200
return atoi(result_str);
201201
}
202202

203-
float XMLDocument::ReadFlt(LPCSTR path, int index, float default_flt_val)
203+
float XMLDocument::ReadFlt(pcstr path, int index, float default_flt_val)
204204
{
205205
LPCSTR result_str = Read(path, index, NULL);
206206
if (result_str == NULL)
@@ -209,7 +209,7 @@ float XMLDocument::ReadFlt(LPCSTR path, int index, float default_flt_val)
209209
return (float)atof(result_str);
210210
}
211211

212-
float XMLDocument::ReadFlt(XML_NODE* start_node, LPCSTR path, int index, float default_flt_val)
212+
float XMLDocument::ReadFlt(XML_NODE* start_node, pcstr path, int index, float default_flt_val)
213213
{
214214
LPCSTR result_str = Read(start_node, path, index, NULL);
215215
if (result_str == NULL)
@@ -228,22 +228,22 @@ float XMLDocument::ReadFlt(XML_NODE* node, float default_flt_val)
228228
return (float)atof(result_str);
229229
}
230230

231-
LPCSTR XMLDocument::ReadAttrib(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, LPCSTR default_str_val)
231+
pcstr XMLDocument::ReadAttrib(XML_NODE* start_node, pcstr path, int index, pcstr attrib, pcstr default_str_val)
232232
{
233233
XML_NODE* node = NavigateToNode(start_node, path, index);
234234
LPCSTR result = ReadAttrib(node, attrib, default_str_val);
235235

236236
return result;
237237
}
238238

239-
LPCSTR XMLDocument::ReadAttrib(LPCSTR path, int index, LPCSTR attrib, LPCSTR default_str_val)
239+
pcstr XMLDocument::ReadAttrib(pcstr path, int index, pcstr attrib, pcstr default_str_val)
240240
{
241241
XML_NODE* node = NavigateToNode(path, index);
242242
LPCSTR result = ReadAttrib(node, attrib, default_str_val);
243243
return result;
244244
}
245245

246-
LPCSTR XMLDocument::ReadAttrib(XML_NODE* node, LPCSTR attrib, LPCSTR default_str_val)
246+
pcstr XMLDocument::ReadAttrib(XML_NODE* node, pcstr attrib, pcstr default_str_val)
247247
{
248248
if (node == NULL)
249249
return default_str_val;
@@ -274,7 +274,7 @@ LPCSTR XMLDocument::ReadAttrib(XML_NODE* node, LPCSTR attrib, LPCSTR default_str
274274
}
275275
}
276276

277-
int XMLDocument::ReadAttribInt(XML_NODE* node, LPCSTR attrib, int default_int_val)
277+
int XMLDocument::ReadAttribInt(XML_NODE* node, pcstr attrib, int default_int_val)
278278
{
279279
LPCSTR result_str = ReadAttrib(node, attrib, NULL);
280280

@@ -284,7 +284,7 @@ int XMLDocument::ReadAttribInt(XML_NODE* node, LPCSTR attrib, int default_int_va
284284
return atoi(result_str);
285285
}
286286

287-
int XMLDocument::ReadAttribInt(LPCSTR path, int index, LPCSTR attrib, int default_int_val)
287+
int XMLDocument::ReadAttribInt(pcstr path, int index, pcstr attrib, int default_int_val)
288288
{
289289
LPCSTR result_str = ReadAttrib(path, index, attrib, NULL);
290290

@@ -294,7 +294,7 @@ int XMLDocument::ReadAttribInt(LPCSTR path, int index, LPCSTR attrib, int defaul
294294
return atoi(result_str);
295295
}
296296

297-
int XMLDocument::ReadAttribInt(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, int default_int_val)
297+
int XMLDocument::ReadAttribInt(XML_NODE* start_node, pcstr path, int index, pcstr attrib, int default_int_val)
298298
{
299299
LPCSTR result_str = ReadAttrib(start_node, path, index, attrib, NULL);
300300

@@ -303,7 +303,7 @@ int XMLDocument::ReadAttribInt(XML_NODE* start_node, LPCSTR path, int index, LPC
303303
return atoi(result_str);
304304
}
305305

306-
float XMLDocument::ReadAttribFlt(LPCSTR path, int index, LPCSTR attrib, float default_flt_val)
306+
float XMLDocument::ReadAttribFlt(pcstr path, int index, pcstr attrib, float default_flt_val)
307307
{
308308
LPCSTR result_str = ReadAttrib(path, index, attrib, NULL);
309309

@@ -313,7 +313,7 @@ float XMLDocument::ReadAttribFlt(LPCSTR path, int index, LPCSTR attrib, float de
313313
return (float)atof(result_str);
314314
}
315315

316-
float XMLDocument::ReadAttribFlt(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, float default_flt_val)
316+
float XMLDocument::ReadAttribFlt(XML_NODE* start_node, pcstr path, int index, pcstr attrib, float default_flt_val)
317317
{
318318
LPCSTR result_str = ReadAttrib(start_node, path, index, attrib, NULL);
319319

@@ -323,7 +323,7 @@ float XMLDocument::ReadAttribFlt(XML_NODE* start_node, LPCSTR path, int index, L
323323
return (float)atof(result_str);
324324
}
325325

326-
float XMLDocument::ReadAttribFlt(XML_NODE* node, LPCSTR attrib, float default_flt_val)
326+
float XMLDocument::ReadAttribFlt(XML_NODE* node, pcstr attrib, float default_flt_val)
327327
{
328328
LPCSTR result_str = ReadAttrib(node, attrib, NULL);
329329

@@ -333,7 +333,7 @@ float XMLDocument::ReadAttribFlt(XML_NODE* node, LPCSTR attrib, float default_fl
333333
return (float)atof(result_str);
334334
}
335335

336-
int XMLDocument::GetNodesNum(LPCSTR path, int index, LPCSTR tag_name)
336+
int XMLDocument::GetNodesNum(pcstr path, int index, pcstr tag_name)
337337
{
338338
XML_NODE* node = NULL;
339339

@@ -354,7 +354,7 @@ int XMLDocument::GetNodesNum(LPCSTR path, int index, LPCSTR tag_name)
354354
return GetNodesNum(node, tag_name);
355355
}
356356

357-
int XMLDocument::GetNodesNum(XML_NODE* node, LPCSTR tag_name)
357+
int XMLDocument::GetNodesNum(XML_NODE* node, pcstr tag_name)
358358
{
359359
if (node == NULL)
360360
return 0;
@@ -382,15 +382,15 @@ int XMLDocument::GetNodesNum(XML_NODE* node, LPCSTR tag_name)
382382

383383
//нахождение элемнета по его атрибуту
384384
XML_NODE* XMLDocument::SearchForAttribute(
385-
LPCSTR path, int index, LPCSTR tag_name, LPCSTR attrib, LPCSTR attrib_value_pattern)
385+
pcstr path, int index, pcstr tag_name, pcstr attrib, pcstr attrib_value_pattern)
386386
{
387387
XML_NODE* start_node = NavigateToNode(path, index);
388388
XML_NODE* result = SearchForAttribute(start_node, tag_name, attrib, attrib_value_pattern);
389389
return result;
390390
}
391391

392392
XML_NODE* XMLDocument::SearchForAttribute(
393-
XML_NODE* start_node, LPCSTR tag_name, LPCSTR attrib, LPCSTR attrib_value_pattern)
393+
XML_NODE* start_node, pcstr tag_name, pcstr attrib, pcstr attrib_value_pattern)
394394
{
395395
while (start_node)
396396
{
@@ -419,7 +419,7 @@ XML_NODE* XMLDocument::SearchForAttribute(
419419

420420
#ifdef DEBUG // debug & mixed
421421

422-
LPCSTR XMLDocument::CheckUniqueAttrib(XML_NODE* start_node, LPCSTR tag_name, LPCSTR attrib_name)
422+
pcstr XMLDocument::CheckUniqueAttrib(XML_NODE* start_node, pcstr tag_name, pcstr attrib_name)
423423
{
424424
m_AttribValues.clear_not_free();
425425

src/xrCore/XML/XMLDocument.hpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include "Common/Platform.hpp"
66

7-
const LPCSTR CONFIG_PATH = "$game_config$";
8-
const LPCSTR UI_PATH = "ui";
7+
const pcstr CONFIG_PATH = "$game_config$";
8+
const pcstr UI_PATH = "ui";
99

1010
#include "tinyxml.h"
1111

@@ -14,61 +14,61 @@ typedef TiXmlAttribute XML_ATTRIBUTE;
1414

1515
class XRCORE_API XMLDocument
1616
{
17-
void Load(LPCSTR path_alias, LPCSTR xml_filename);
17+
void Load(pcstr path_alias, pcstr xml_filename);
1818

1919
public:
2020
string_path m_xml_file_name;
2121
XMLDocument();
2222
virtual ~XMLDocument();
2323
void ClearInternal();
2424

25-
void Load(LPCSTR path_alias, LPCSTR path, LPCSTR xml_filename);
25+
void Load(pcstr path_alias, pcstr path, pcstr xml_filename);
2626

2727
//чтение элементов
28-
LPCSTR Read(LPCSTR path, int index, LPCSTR default_str_val);
29-
LPCSTR Read(XML_NODE* start_node, LPCSTR path, int index, LPCSTR default_str_val);
30-
LPCSTR Read(XML_NODE* node, LPCSTR default_str_val);
28+
pcstr Read(pcstr path, int index, pcstr default_str_val);
29+
pcstr Read(XML_NODE* start_node, pcstr path, int index, pcstr default_str_val);
30+
pcstr Read(XML_NODE* node, pcstr default_str_val);
3131

32-
int ReadInt(LPCSTR path, int index, int default_int_val);
33-
int ReadInt(XML_NODE* start_node, LPCSTR path, int index, int default_int_val);
32+
int ReadInt(pcstr path, int index, int default_int_val);
33+
int ReadInt(XML_NODE* start_node, pcstr path, int index, int default_int_val);
3434
int ReadInt(XML_NODE* node, int default_int_val);
3535

36-
float ReadFlt(LPCSTR path, int index, float default_flt_val);
37-
float ReadFlt(XML_NODE* start_node, LPCSTR path, int index, float default_flt_val);
36+
float ReadFlt(pcstr path, int index, float default_flt_val);
37+
float ReadFlt(XML_NODE* start_node, pcstr path, int index, float default_flt_val);
3838
float ReadFlt(XML_NODE* node, float default_flt_val);
3939

40-
LPCSTR ReadAttrib(LPCSTR path, int index, LPCSTR attrib, LPCSTR default_str_val = "");
41-
LPCSTR ReadAttrib(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, LPCSTR default_str_val = "");
42-
LPCSTR ReadAttrib(XML_NODE* node, LPCSTR attrib, LPCSTR default_str_val);
40+
pcstr ReadAttrib(pcstr path, int index, pcstr attrib, pcstr default_str_val = "");
41+
pcstr ReadAttrib(XML_NODE* start_node, pcstr path, int index, pcstr attrib, pcstr default_str_val = "");
42+
pcstr ReadAttrib(XML_NODE* node, pcstr attrib, pcstr default_str_val);
4343

44-
int ReadAttribInt(LPCSTR path, int index, LPCSTR attrib, int default_int_val = 0);
45-
int ReadAttribInt(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, int default_int_val = 0);
46-
int ReadAttribInt(XML_NODE* node, LPCSTR attrib, int default_int_val);
44+
int ReadAttribInt(pcstr path, int index, pcstr attrib, int default_int_val = 0);
45+
int ReadAttribInt(XML_NODE* start_node, pcstr path, int index, pcstr attrib, int default_int_val = 0);
46+
int ReadAttribInt(XML_NODE* node, pcstr attrib, int default_int_val);
4747

48-
float ReadAttribFlt(LPCSTR path, int index, LPCSTR attrib, float default_flt_val = 0.0f);
49-
float ReadAttribFlt(XML_NODE* start_node, LPCSTR path, int index, LPCSTR attrib, float default_flt_val = 0.0f);
50-
float ReadAttribFlt(XML_NODE* node, LPCSTR attrib, float default_flt_val = 0.0f);
48+
float ReadAttribFlt(pcstr path, int index, pcstr attrib, float default_flt_val = 0.0f);
49+
float ReadAttribFlt(XML_NODE* start_node, pcstr path, int index, pcstr attrib, float default_flt_val = 0.0f);
50+
float ReadAttribFlt(XML_NODE* node, pcstr attrib, float default_flt_val = 0.0f);
5151

52-
XML_NODE* SearchForAttribute(LPCSTR path, int index, LPCSTR tag_name, LPCSTR attrib, LPCSTR attrib_value_pattern);
53-
XML_NODE* SearchForAttribute(XML_NODE* start_node, LPCSTR tag_name, LPCSTR attrib, LPCSTR attrib_value_pattern);
52+
XML_NODE* SearchForAttribute(pcstr path, int index, pcstr tag_name, pcstr attrib, pcstr attrib_value_pattern);
53+
XML_NODE* SearchForAttribute(XML_NODE* start_node, pcstr tag_name, pcstr attrib, pcstr attrib_value_pattern);
5454

5555
//возвращает количество узлов с заданым именем
56-
int GetNodesNum(LPCSTR path, int index, LPCSTR tag_name);
57-
int GetNodesNum(XML_NODE* node, LPCSTR tag_name);
56+
int GetNodesNum(pcstr path, int index, pcstr tag_name);
57+
int GetNodesNum(XML_NODE* node, pcstr tag_name);
5858

5959
#ifdef DEBUG // debug & mixed
6060
//проверка того, что аттрибуты у тегов уникальны
6161
//(если не NULL, то уникальность нарушена и возврашается имя
6262
//повторяющегося атрибута)
63-
LPCSTR CheckUniqueAttrib(XML_NODE* start_node, LPCSTR tag_name, LPCSTR attrib_name);
63+
pcstr CheckUniqueAttrib(XML_NODE* start_node, pcstr tag_name, pcstr attrib_name);
6464
#endif
6565

6666
//переместиться по XML дереву
6767
//путь задается в форме PARENT:CHILD:CHIDLS_CHILD
6868
// node_index - номер, если узлов с одним именем несколько
69-
XML_NODE* NavigateToNode(LPCSTR path, int node_index = 0);
70-
XML_NODE* NavigateToNode(XML_NODE* start_node, LPCSTR path, int node_index = 0);
71-
XML_NODE* NavigateToNodeWithAttribute(LPCSTR tag_name, LPCSTR attrib_name, LPCSTR attrib_value);
69+
XML_NODE* NavigateToNode(pcstr path, int node_index = 0);
70+
XML_NODE* NavigateToNode(XML_NODE* start_node, pcstr path, int node_index = 0);
71+
XML_NODE* NavigateToNodeWithAttribute(pcstr tag_name, pcstr attrib_name, pcstr attrib_value);
7272

7373
void SetLocalRoot(XML_NODE* pLocalRoot) { m_pLocalRoot = pLocalRoot; }
7474
XML_NODE* GetLocalRoot() { return m_pLocalRoot; }
@@ -82,7 +82,7 @@ class XRCORE_API XMLDocument
8282
xr_vector<shared_str> m_AttribValues;
8383
#endif
8484
public:
85-
virtual shared_str correct_file_name(LPCSTR path, LPCSTR fn) { return fn; }
85+
virtual shared_str correct_file_name(pcstr path, pcstr fn) { return fn; }
8686
private:
8787
XMLDocument(const XMLDocument& copy);
8888
void operator=(const XMLDocument& copy);

src/xrGame/ui/UIChatWnd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ void CUIChatWnd::PendingMode(bool const is_pending_mode)
3131
pendingGameMode = false;
3232
}
3333

34-
#define CHAT_PREFIX_PENDING "chat_prefix_pending"
35-
#define CHAT_EDITBOX_PENDING "chat_editbox_pending"
34+
const pcstr CHAT_PREFIX_PENDING = "chat_prefix_pending";
35+
const pcstr CHAT_EDITBOX_PENDING = "chat_editbox_pending";
3636

3737
void CUIChatWnd::Init(CUIXml& uiXml)
3838
{

src/xrGame/ui/xrUIXmlParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "ui_base.h"
66
#endif
77

8-
shared_str CUIXml::correct_file_name(LPCSTR path, LPCSTR fn)
8+
shared_str CUIXml::correct_file_name(pcstr path, pcstr fn)
99
{
1010
#ifdef XRGAME_EXPORTS
1111
if (0 == xr_strcmp(path, UI_PATH) || 0 == xr_strcmp(path, "UI"))

src/xrGame/ui/xrUIXmlParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ class CUIXml : public XMLDocument
99
CUIXml();
1010
virtual ~CUIXml();
1111

12-
virtual shared_str correct_file_name(LPCSTR path, LPCSTR fn);
12+
virtual shared_str correct_file_name(pcstr path, pcstr fn);
1313
};

0 commit comments

Comments
 (0)