VR-Link API Documentation for HLA 1.3
vlString.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
10 #include "vlMachineTypes.h"
11 #include <vector>
12 #include <iosfwd>
13 
14 #ifdef DtUSE_UTILITIES_NAMESPACE
15 namespace DtUSE_UTILITIES_NAMESPACE
16 {
17 #endif
18 
19 
20 
21 
27  {
28  friend DT_DLL_VLUTIL std::ostream& operator<<(std::ostream& os, const DtString& str);
29  friend DT_DLL_VLUTIL std::istream& operator>>(std::istream& is, DtString& str);
30  public:
31 
33  DtString();
34 
36  DtString(const char* str);
37 
39  DtString(const char* str,int length);
40 
46 
47  DtString(double val);
48  DtString(int val);
49  DtString(long val);
50  DtString(char val);
51  DtString(unsigned int val);
52  DtString(unsigned long val);
54 
55 
57  virtual ~DtString();
58 
60  DtString(const DtString& orig);
61 
63 
64  DtString& operator=(const DtString& orig);
65  DtString& operator=(const char* orig);
67 
69  virtual operator const char*() const;
70 
72  DtString* clone() const;
73 
75 
76  friend DT_DLL_VLUTIL bool operator==(const DtString& str1, const DtString& str2);
77  friend DT_DLL_VLUTIL bool operator<(const DtString& str1, const DtString& str2);
78  friend DT_DLL_VLUTIL bool operator<=(const DtString& str1, const DtString& str2);
79  friend DT_DLL_VLUTIL bool operator>(const DtString& str1, const DtString& str2);
80  friend DT_DLL_VLUTIL bool operator>=(const DtString& str1, const DtString& str2);
81  friend DT_DLL_VLUTIL bool operator!=(const DtString& str1, const DtString& str2);
82  virtual bool operator==(const char* str) const;
83  virtual bool operator<(const char* str) const;
84  virtual bool operator<=(const char* str) const;
85  virtual bool operator>(const char* str) const;
86  virtual bool operator>=(const char* str) const;
87  virtual bool operator!=(const char* str) const;
89 
92 
93  virtual bool caseCompare(const DtString& str) const;
94  virtual bool caseCompare(const char* str) const;
96 
98 
99  friend DT_DLL_VLUTIL DtString operator+(const DtString& str1, const DtString& str2);
100  friend DT_DLL_VLUTIL DtString operator+(const char* str1, const DtString& str2);
101  virtual DtString operator+(const char* str) const;
102  virtual DtString& operator+=(const char* str);
103  virtual DtString& operator+=(const DtString& str);
105 
107 
108  virtual const char& operator[](int index) const;
109  virtual char& operator[](int index);
111 
118 
119  virtual bool snipFront(const char ch, bool toLastCh = false);
120  virtual bool snipBack(const char ch, bool fromFirstCh = false);
122 
124 
125  virtual bool chompFront();
126  virtual bool chompBack();
128 
129 
132  virtual void tokenize(const char delimiter, std::vector<DtString>& tokens) const;
133 
137  virtual int toInt(bool* ok = 0) const;
138 
142  virtual unsigned int toUInt(bool* ok = 0) const;
143 
147  virtual float toFloat(bool* ok = 0) const;
148 
152  virtual double toDouble(bool* ok = 0) const;
153 
157  virtual bool toBoolean(bool* ok = 0) const;
158 
160  virtual void toUpper();
161 
163  virtual void toLower();
164 
168  virtual int findChar(const char ch);
169 
173  virtual int findLastChar(const char ch);
174 
178  virtual int findString(const DtString& string) const;
179 
183  virtual int findLastString(const DtString& string);
184 
185  bool snipFrontToLast(const char ch) { return snipFront(ch, true); }
186  bool snipBackToFirst(const char ch) { return snipBack(ch, true); }
187 
189  virtual int count(const char ch) const;
190 
193  virtual int length() const;
194 
196  virtual int size() const;
197 
200  const char* string() const;
201 
203  const char* c_str() const;
204 
206  bool isEmpty() const;
207 
208  public:
209 
211  static const DtString& nullString();
212 
213  protected:
214 
219  void clear();
220 
223  void setString(const char* str);
224 
225  protected:
226 
227  enum { theDefaultBufferSize = 64 };
228  char myDefaultBuffer[theDefaultBufferSize];
229  char* myString;
230 
232  unsigned int myBufSize;
233 
234  static const int theMaxInsertionStringSize;
235  };
236 
237  inline bool DtString::isEmpty() const
238  {
239  return (myString[0] == '\0');
240  }
241 
242 #ifdef DtUSE_UTILITIES_NAMESPACE
243 }
244 #endif
245 

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)