VR-Link API Documentation for HLA 1.3
Home
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
vlutil
vlStringUtil.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 1992-2010 VT MAK
3
** All rights reserved.
4
*********************************************************************/
9
#pragma once
10
11
#include <string>
12
#include <sstream>
13
#include <set>
14
#include "
vlString.h
"
15
16
#ifdef DtUSE_UTILITIES_NAMESPACE
17
namespace
DtUSE_UTILITIES_NAMESPACE
18
{
19
#endif
20
22
typedef
std::set<DtString>
DtStringSet
;
23
26
template
<
typename
T>
27
std::wstring
DtToWString
(
const
T &val);
28
31
inline
std::wstring
DtToWString
(
const
std::string &val);
32
35
inline
std::wstring
DtToWString
(
const
char
*val);
36
39
inline
std::wstring
DtToWString
(
char
*val);
40
43
inline
std::wstring
DtToWString
(
const
DtString
&val);
44
45
49
template
<
typename
T>
50
std::string
DtToString
(
const
T &val);
51
56
inline
std::string
DtToString
(
const
std::wstring &val);
57
60
inline
std::string
DtToString
(
const
wchar_t
*val);
61
63
inline
DtString
DtToLower
(
const
char
*);
64
66
inline
DtString
DtToLower
(
const
DtString
&);
67
69
inline
DtString
DtToUpper
(
const
char
*);
70
72
inline
DtString
DtToUpper
(
const
DtString
&);
73
75
DT_DLL_VLUTIL
DtString
DtFirstCharToLower
(
const
DtString
&);
76
80
DT_DLL_VLUTIL
DtString
DtFirstCharToLowerConditional
(
const
DtString
&);
81
83
DT_DLL_VLUTIL
DtString
DtFirstCharToUpper
(
const
DtString
&);
84
91
DT_DLL_VLUTIL
DtString
DtReplaceSubstring
(
const
DtString
& str,
92
const
DtString
& searchFor,
const
DtString
& replacement);
93
100
DT_DLL_VLUTIL
DtString
DtReplaceAllSubstrings
(
const
DtString
& str,
101
const
DtString
& searchFor,
const
DtString
& replacement);
102
106
DT_DLL_VLUTIL
bool
DtContainsSubstring
(
const
DtString
& str,
107
const
DtString
& searchFor);
108
109
110
//---------------------------------------------------------------
113
template
<
typename
T>
114
inline
std::wstring
DtToWString
(
const
T &in_val)
115
{
116
std::wstringstream temp;
117
temp << in_val;
118
return
temp.str();
119
}
120
121
inline
std::wstring
DtToWString
(
const
std::string &in_val)
122
{
123
std::wstring temp;
124
std::string::const_iterator b = in_val.begin();
125
const
std::string::const_iterator e = in_val.end();
126
while
(b != e)
127
{
128
temp += *b;
129
++b;
130
}
131
return
temp;
132
}
133
134
inline
std::wstring
DtToWString
(
const
char
* in_val)
135
{
136
std::wstring temp;
137
while
(*in_val !=
'\0'
)
138
temp += *in_val++;
139
return
temp;
140
}
141
142
inline
std::wstring
DtToWString
(
char
* in_val)
143
{
144
std::wstring temp;
145
while
(*in_val !=
'\0'
)
146
temp += *in_val++;
147
return
temp;
148
}
149
150
inline
std::wstring
DtToWString
(
const
DtString
&val)
151
{
153
return
DtToWString
(val.
c_str
());
154
}
155
156
template
<
typename
T>
157
inline
std::string
DtToString
(
const
T &in_val)
158
{
159
std::stringstream temp;
160
temp << in_val;
161
return
temp.str();
162
}
163
164
inline
std::string
DtToString
(
const
std::wstring &in_val)
165
{
166
return
DtToString
(in_val.c_str());
167
}
168
169
170
inline
std::string
DtToString
(
const
wchar_t
* in_val)
171
{
172
std::string temp;
173
while
(*in_val != L
'\0'
)
174
{
175
temp += *in_val++;
176
}
177
return
temp;
178
}
179
180
inline
DtString
DtToLower
(
const
char
* str)
181
{
182
DtString
copy(str);
183
copy.
toLower
();
184
return
copy;
185
}
186
187
inline
DtString
DtToLower
(
const
DtString
& str)
188
{
189
DtString
copy(str);
190
copy.
toLower
();
191
return
copy;
192
}
193
194
inline
DtString
DtToUpper
(
const
char
* str)
195
{
196
DtString
copy(str);
197
copy.
toUpper
();
198
return
copy;
199
}
200
201
inline
DtString
DtToUpper
(
const
DtString
& str)
202
{
203
DtString
copy(str);
204
copy.
toUpper
();
205
return
copy;
206
}
207
208
216
class
DT_DLL_VLUTIL
DtStringPatternMatch
217
{
218
public
:
219
221
DtStringPatternMatch
();
222
224
DtStringPatternMatch
(
const
DtString
& testStr,
225
const
DtString
& pattern =
DtString::nullString
());
226
227
private
:
229
DtStringPatternMatch
(
const
DtStringPatternMatch
& orig);
230
232
DtStringPatternMatch
& operator=(
const
DtStringPatternMatch
& orig);
233
234
public
:
235
237
virtual
void
setPattern(
const
DtString
& pattern);
238
virtual
const
DtString
& pattern()
const
;
239
241
virtual
void
setString(
const
DtString
& testStr);
242
virtual
const
DtString
& string()
const
;
243
252
virtual
int
indexOfOccurence(
const
int
start = 0);
253
255
virtual
~
DtStringPatternMatch
();
256
257
protected
:
258
260
void
buildSkipTable();
261
262
263
DtString
myStrCopy
;
264
DtString
myPattern
;
265
int
*
mySkipTable
;
266
267
static
const
int
theSkipTableSize
;
268
};
269
270
271
272
enum
DtStringEncodingType
{
273
HLAvariableArray
,
274
HLAfixedArray
,
275
HLAnullTerminatedArray
,
276
RPRnullTerminatedArray
,
277
HLAlengthlessVarArray
,
278
RPRlengthlessArray
,
279
LengthlessArray
280
};
281
282
//String encodings and decoding fom network formats
283
extern
DT_DLL_VLUTIL
int
DtVariableArraySizeLength
;
284
DT_DLL_VLUTIL
int
DtStringToBuffer
(
DtStringEncodingType
encodingType,
char
* buffer,
int
bufferSize,
const
DtString
& origin,
bool
wide =
false
);
285
DT_DLL_VLUTIL
int
DtStringFromBuffer
(
DtStringEncodingType
encodingType,
DtString
* result,
const
char
* buffer,
int
bufferSize,
bool
wide =
false
);
286
DT_DLL_VLUTIL
int
DtStringGetNetPadding
(
DtStringEncodingType
encodingType);
287
288
#ifdef DtUSE_UTILITIES_NAMESPACE
289
}
290
#endif
Document ID: Generated on Fri Dec 2 02:42:08 EST 2016 from SVN revision 171416
Copyright © 2005-2016 VT MÄK. All Rights Reserved (
www.mak.com
)