VR-Link API Documentation for HLA Evolved
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 
76 
79 
87  const DtString& searchFor, const DtString& replacement);
88 
96  const DtString& searchFor, const DtString& replacement);
97 
102  const DtString& searchFor);
103 
104 
105 //---------------------------------------------------------------
108 template<typename T>
109 inline std::wstring DtToWString(const T &in_val)
110 {
111  std::wstringstream temp;
112  temp << in_val;
113  return temp.str();
114 }
115 
116 inline std::wstring DtToWString(const std::string &in_val)
117 {
118  std::wstring temp;
119  std::string::const_iterator b = in_val.begin();
120  const std::string::const_iterator e = in_val.end();
121  while (b != e)
122  {
123  temp += *b;
124  ++b;
125  }
126  return temp;
127 }
128 
129 inline std::wstring DtToWString(const char * in_val)
130 {
131  std::wstring temp;
132  while (*in_val != '\0')
133  temp += *in_val++;
134  return temp;
135 }
136 
137 inline std::wstring DtToWString(char * in_val)
138 {
139  std::wstring temp;
140  while (*in_val != '\0')
141  temp += *in_val++;
142  return temp;
143 }
144 
145 inline std::wstring DtToWString(const DtString &val)
146 {
148  return DtToWString(val.c_str());
149 }
150 
151 template<typename T>
152 inline std::string DtToString(const T &in_val)
153 {
154  std::stringstream temp;
155  temp << in_val;
156  return temp.str();
157 }
158 
159 inline std::string DtToString(const std::wstring &in_val)
160 {
161  return DtToString(in_val.c_str());
162 }
163 
164 
165 inline std::string DtToString(const wchar_t * in_val)
166 {
167  std::string temp;
168  while (*in_val != L'\0')
169  {
170  temp += *in_val++;
171  }
172  return temp;
173 }
174 
175 inline DtString DtToLower(const char* str)
176 {
177  DtString copy(str);
178  copy.toLower();
179  return copy;
180 }
181 
182 inline DtString DtToLower(const DtString& str)
183 {
184  DtString copy(str);
185  copy.toLower();
186  return copy;
187 }
188 
189 inline DtString DtToUpper(const char* str)
190 {
191  DtString copy(str);
192  copy.toUpper();
193  return copy;
194 }
195 
196 inline DtString DtToUpper(const DtString& str)
197 {
198  DtString copy(str);
199  copy.toUpper();
200  return copy;
201 }
202 
203 
212 {
213 public:
214 
217 
219  DtStringPatternMatch(const DtString & testStr,
220  const DtString & pattern = DtString::nullString());
221 
222 private:
225 
227  DtStringPatternMatch& operator=(const DtStringPatternMatch& orig);
228 
229 public:
230 
232  virtual void setPattern(const DtString & pattern);
233  virtual const DtString & pattern()const;
234 
236  virtual void setString(const DtString & testStr);
237  virtual const DtString & string()const;
238 
247  virtual int indexOfOccurence(const int start = 0);
248 
250  virtual ~DtStringPatternMatch();
251 
252 protected:
253 
255  void buildSkipTable();
256 
257 
260  int * mySkipTable;
261 
262  static const int theSkipTableSize;
263 };
264 
265 #ifdef DtUSE_UTILITIES_NAMESPACE
266 }
267 #endif

Document ID: Generated on Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)