VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlStringUtil.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 MAK Technologies, Inc
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 
76 
81 
84 
92  const DtString& searchFor, const DtString& replacement);
93 
101  const DtString& searchFor, const DtString& replacement);
102 
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 
217 {
218 public:
219 
222 
224  DtStringPatternMatch(const DtString & testStr,
225  const DtString & pattern = DtString::nullString());
226 
227 private:
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 
265  int * mySkipTable;
266 
267  static const int theSkipTableSize;
268 };
269 
270 
271 
280 };
281 
282 //String encodings and decoding fom network formats
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);
287 
288 #ifdef DtUSE_UTILITIES_NAMESPACE
289 }
290 #endif
DtString DtReplaceAllSubstrings(const DtString &str, const DtString &searchFor, const DtString &replacement)
This function will replace all instances of a substring within a string with another string specified...
DtString DtToLower(const char *)
This function returns a new lowercase DtString.
Definition: vlStringUtil.h:180
DtString DtReplaceSubstring(const DtString &str, const DtString &searchFor, const DtString &replacement)
This function will replace the first instance of a substring within a string with another string spec...
static const DtString & nullString()
a Null representation of a string, which is the same as an empty string
Definition: vlStringUtil.h:274
Contains the DtString class declaration.
DtStringEncodingType
Definition: vlStringUtil.h:272
std::wstring DtToWString(const T &val)
This template function takes an instance of any type which has overloaded operator&lt;&lt;(wostream).
Definition: vlStringUtil.h:114
Definition: vlStringUtil.h:278
virtual void toLower()
Convert this string&#39;s alphabetic characters to lowercase.
DtString DtFirstCharToLowerConditional(const DtString &)
This function returns a new string with the first character lowercase as long as the second character...
Definition: vlStringUtil.h:279
int DtStringFromBuffer(DtStringEncodingType encodingType, DtString *result, const char *buffer, int bufferSize, bool wide=false)
Performs pattern matching against user specified DtString using Boyer Moore algorithm.
Definition: vlStringUtil.h:216
int DtStringGetNetPadding(DtStringEncodingType encodingType)
DtString DtFirstCharToLower(const DtString &)
This function returns a new string with the first character lowercase.
int * mySkipTable
Definition: vlStringUtil.h:265
bool DtContainsSubstring(const DtString &str, const DtString &searchFor)
This function looks for a substring within str.
int DtVariableArraySizeLength
std::string DtToString(const T &val)
This Template method takes a variable of any type which has overloaded operator&lt;&lt;(ostream) and return...
Definition: vlStringUtil.h:157
DtString DtToUpper(const char *)
This function returns a new uppercase DtString.
Definition: vlStringUtil.h:194
Definition: vlStringUtil.h:277
Definition: vlStringUtil.h:276
DtString myPattern
Definition: vlStringUtil.h:264
int DtStringToBuffer(DtStringEncodingType encodingType, char *buffer, int bufferSize, const DtString &origin, bool wide=false)
DtString myStrCopy
Definition: vlStringUtil.h:263
virtual void toUpper()
Convert this string&#39;s alphabetic characters to uppercase.
Definition: vlStringUtil.h:273
virtual const char * c_str() const
Returns a char* representation of the DtString;.
Definition: vlStringUtil.h:275
static const int theSkipTableSize
Definition: vlStringUtil.h:267
DtString DtFirstCharToUpper(const DtString &)
This function returns a new string with the first character uppercase.
std::set< DtString > DtStringSet
An set of DtStrings.
Definition: vlStringUtil.h:22
Instances of DtString are used to represent strings.
Definition: vlString.h:29
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Thu Sep 19 02:12:35 EDT 2024 from SVN revision 269601
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)