VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlString.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2015 MAK Technologies, Inc
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vlutil/vlMachineTypes.h>
13 #include <vector>
14 #include <iosfwd>
15 
16 #if _MSC_VER >= 1920 //VC16 2019
17 #include <xstring>
18 #endif
19 
20 #ifdef DtUSE_UTILITIES_NAMESPACE
21 namespace DtUSE_UTILITIES_NAMESPACE
22 {
23 #endif
24 
30  {
31  public:
32 
34  DtString();
35 
37  DtString( const char* str );
38 
40  DtString( const char* str, int length );
41 
43  DtString( const std::string& str );
44 
46  DtString( const DtString& orig );
47 
54 
55  DtString( double val );
56  DtString( int val );
57  DtString( long val );
58  DtString( char val );
59  DtString( unsigned int val );
60  DtString( unsigned long val );
61 
63 
65  virtual ~DtString();
66 
69 
70  virtual DtString& operator = ( const char* orig );
71  virtual DtString& operator = ( const DtString& orig );
72 
74 
76  virtual operator const char*() const;
77 
79  virtual DtString* clone() const;
80 
83 
84  friend DT_DLL_VLUTIL bool operator < ( const DtString& str1, const DtString& str2 );
85  friend DT_DLL_VLUTIL bool operator > ( const DtString& str1, const DtString& str2 );
86  friend DT_DLL_VLUTIL bool operator == ( const DtString& str1, const DtString& str2 );
87  friend DT_DLL_VLUTIL bool operator != ( const DtString& str1, const DtString& str2 );
88  friend DT_DLL_VLUTIL bool operator <= ( const DtString& str1, const DtString& str2 );
89  friend DT_DLL_VLUTIL bool operator >= ( const DtString& str1, const DtString& str2 );
90 
91  virtual bool operator < ( const char* str ) const;
92  virtual bool operator > ( const char* str ) const;
93  virtual bool operator == ( const char* str ) const;
94  virtual bool operator != ( const char* str ) const;
95  virtual bool operator <= ( const char* str ) const;
96  virtual bool operator >= ( const char* str ) const;
97 
99 
103 
104  virtual bool caseCompare( const char* str ) const;
105  virtual bool caseCompare( const DtString& str ) const;
106 
108 
111 
112  friend DT_DLL_VLUTIL DtString operator + ( const char* str1, const DtString& str2 );
113  friend DT_DLL_VLUTIL DtString operator + ( const DtString& str1, const DtString& str2 );
114 
115  virtual DtString operator + ( const char* str ) const;
116  virtual DtString& operator += ( const char* str );
117  virtual DtString& operator += ( const DtString& str );
118 
120 
123 
124  virtual char& operator [] ( int index );
125  virtual const char& operator [] ( int index ) const;
126 
128 
135 
136  virtual bool snipFront( const char ch, bool toLastCh = false );
137  virtual bool snipBack( const char ch, bool fromFirstCh = false );
139 
141 
142  virtual bool chompFront();
143  virtual bool chompBack();
145 
148  virtual void tokenize( const char delimiter, std::vector<DtString>& tokens ) const;
149 
153  virtual int toInt( bool* ok = 0 ) const;
154 
158  virtual unsigned int toUInt( bool* ok = 0 ) const;
159 
163  virtual float toFloat( bool* ok = 0 ) const;
164 
168  virtual double toDouble( bool* ok = 0 ) const;
169 
173  virtual bool toBoolean( bool* ok = 0 ) const;
174 
176  virtual void toUpper();
177 
179  virtual void toLower();
180 
184  virtual int findChar( const char ch );
185 
189  virtual int findLastChar( const char ch );
190 
194  virtual int findString( const DtString& string ) const;
195 
199  virtual int findLastString( const DtString& string );
200 
201  bool snipFrontToLast( const char ch )
202  {
203  return snipFront( ch, true );
204  }
205 
206  bool snipBackToFirst( const char ch )
207  {
208  return snipBack( ch, true );
209  }
210 
212  virtual int count( const char ch ) const;
213 
216  virtual int length() const;
217 
219  virtual int size() const;
220 
222  virtual std::string stdString() const;
223 
226  virtual const char* string() const;
227 
229  virtual const char* c_str() const;
230 
232  virtual bool isEmpty() const;
233 
236  virtual DtString section(const char sep, int start, int end = -1) const;
237 
238  public:
239 
241  static const DtString& nullString();
242 
245  static const DtString& nullId();
246 
247  protected:
248 
249  friend DT_DLL_VLUTIL std::ostream& operator << ( std::ostream& os, const DtString& str );
250  friend DT_DLL_VLUTIL std::istream& operator >> ( std::istream& is, DtString& str );
251 
256  void clear();
257 
260  void setString( const char* str );
261 
262  protected:
263 
264  enum
265  {
266  theDefaultBufferSize = 64
267  };
268 
269  char myDefaultBuffer[theDefaultBufferSize];
270  char* myString;
271  bool myStringAlloced;
273  unsigned int myBufSize;
274 
275  static const int theMaxInsertionStringSize;
276 
277  };
278 
279 
280  inline bool DtString::isEmpty() const
281  {
282  return (myString[0] == '\0');
283  }
284 
285 #ifdef DtUSE_UTILITIES_NAMESPACE
286 }
287 #endif
const bool operator==(const DtU128 &lhs, const DtU128 &rhs)
virtual bool isEmpty() const
returns true if the string is empty, where empty is size() == 0
Definition: vlString.h:280
bool snipFrontToLast(const char ch)
Definition: vlString.h:201
DtVector operator+(const DtVector &v1, const DtVector &v2)
implements v1 + v2
std::ostream & operator<<(std::ostream &os, const Dt3dChord &chord)
std::istream & operator>>(std::istream &is, Dt3dExtent &extent)
bool snipBackToFirst(const char ch)
Definition: vlString.h:206
char * myString
Use this buffer if possible.
Definition: vlString.h:270
unsigned int myBufSize
Does myString need to be deleted when done?
Definition: vlString.h:273
bool operator<(const DtTimeReflectedObjectIdKey &left, const DtTimeReflectedObjectIdKey &right)
Compare 2 time ID keys.
Definition: reflectedObjectListHLA.h:548
const bool operator!=(const DtU128 &lhs, const DtU128 &rhs)
Instances of DtString are used to represent strings.
Definition: vlString.h:29
This file contains typedefs for machine dependant types.
const bool operator>(const DtU128 &lhs, const DtU128 &rhs)
static const int theMaxInsertionStringSize
current buffer size
Definition: vlString.h:275
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)