Open Reality Reference Guide
fbstring.h
Go to the documentation of this file.
1 #ifndef __FBSTRING_H__
2 #define __FBSTRING_H__
3 /**************************************************************************
4  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5  All Rights Reserved.
6 
7  The coded instructions, statements, computer programs, and/or related
8  material (collectively the "Data") in these files contain unpublished
9  information proprietary to Autodesk, Inc. and/or its licensors, which is
10  protected by Canada and United States of America federal copyright law
11  and by international treaties.
12 
13  The Data may not be disclosed or distributed to third parties, in whole
14  or in part, without the prior written consent of Autodesk, Inc.
15  ("Autodesk").
16 
17  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24  FREE.
25 
26  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
43 #include <kaydaradef.h>
44 
45 #ifndef FBSDK_DLL
49  #define FBSDK_DLL K_DLLIMPORT
50 #endif
51 
52 #include <fbsdk/fbtypes.h>
53 
54 K_FORWARD( KStringList );
55 
56 #ifdef FBSDKUseNamespace
57  namespace FBSDKNamespace {
58 #endif
59 
61 // FBString
63 
67 {
68 private:
69  char* mStr{ nullptr };
70 
71 public:
73  FBString() = default;
74 
78  FBString(const char* pStr);
79 
83  FBString(const FBString &pStr);
84 
89  FBString(const char* p1Str,const char* p2Str);
90 
93 
95  operator char*() const;
96  operator const char*() const;
97 
102  char operator[](unsigned int pIndex) const;
103 
108  const FBString& operator=( const char* pStr );
109 
114  const FBString& operator=( const FBString &pStr );
115 
120  bool operator == ( const FBString& pStr ) const;
121  bool operator == ( const char* pStr ) const;
122  bool operator == ( char* pStr ) const;
123 
128  bool operator != ( const FBString& pStr ) const;
129  bool operator != ( const char* pStr ) const;
130  bool operator != ( char* pStr ) const;
131 
136  const FBString& operator+=(const char pChr);
137 
142  const FBString& operator+=( const char* pStr );
143 
148  FBString operator+( const char* pStr );
149 
154  FBString Mid( unsigned int pStart, unsigned int pLen ) const;
155 
160  FBString Left( unsigned int pLen ) const;
161 
166  FBString Right( unsigned int pLen ) const;
167 
171  unsigned int GetLen() const;
172 
176  bool IsEmpty() const;
177 
182  int Find( char pCar ) const;
183 
188  int ReverseFind( char pCar ) const;
189 
190 private:
194  void Copy( const char* pStr );
195 
199  void Cat( const char* pStr );
200 
201  friend FBString operator+( const FBString& p1Str, const char* p2Str );
202 };
203 
204 FBString operator+( const FBString& p1Str, const char* p2Str );
205 
207 class FBSDK_DLL FBStringList // This class is a direct wrapper it cannot have virtual functions
208 {
209 protected:
211  KStringList* mItems;
212 public:
215 
220  FBStringList( const char *pString, const char pSeparator = '~');
221 
223  FBStringList(const FBStringList& pOther);
224 
229  FBStringList& operator= (const FBStringList& pOther);
230 
233 
234 public:
236  KStringList* GetInternal() const;
237 
242  kReference GetReferenceAt( int pIndex ) const;
243 
248  void SetReferenceAt( int pIndex,kReference pRef );
249 
254  int Find( kReference pRef ) const;
255 
262  int Find( const char *pString, bool pCaseSensitive = true, bool pStartWith = false ) const;
263 
268  const char *GetAt( int pIndex ) const;
269 
275  const char *operator[](int pIndex) const;
276 
278  void Sort( );
279 
283  int GetCount() const;
284 
289  int Remove( const char *S );
290 
295  const char* AsString(const char pSeparator = '~') const;
296 
301  bool SetString( const char *pString, const char pSeparator = '~');
302 
308  int Add( const char *S,kReference pRef = 0 );
309 
311  void Clear();
312 
316  void RemoveAt( int pIndex );
317 
322  int IndexOf( const char *S ) const;
323 
329  void InsertAt( int pIndex, const char *S,kReference pRef = 0 );
330 
335  bool SetAt( int pIndex,const char *pString );
336 };
337 
339 // Global
341 #ifdef FBSDKUseNamespace
342  }
343 #endif
344 
345 #endif
346 
Basic string class.
Definition: fbstring.h:67
FBString(const char *p1Str, const char *p2Str)
Constructor from the concatenation of two strings.
FBString(const char *pStr)
Constructor from a string.
char operator[](unsigned int pIndex) const
Overloaded [] operator.
const FBString & operator=(const FBString &pStr)
Overloaded = operator with an FBString.
unsigned int GetLen() const
Get the number of characters in this string.
FBString(const FBString &pStr)
Copy constructor.
const FBString & operator=(const char *pStr)
Overloaded = operator with a string.
~FBString()
Destructor.
FBString()=default
Constructor.
const FBString & operator+=(const char *pStr)
Overloaded += operator with a string.
int Find(char pCar) const
Find first occurrence of the specified character.
bool IsEmpty() const
This method determines whether the string is empty or not.
FBString Right(unsigned int pLen) const
Extracts the last pLen characters from this string.
FBString operator+(const char *pStr)
Overloaded + operator with a string.
const FBString & operator+=(const char pChr)
Overloaded += operator with a char.
FBString Left(unsigned int pLen) const
Extracts the first pLen characters from this string.
FBString Mid(unsigned int pStart, unsigned int pLen) const
Extracts a substring of length a specified length from a certain position.
int ReverseFind(char pCar) const
Find last occurrence of the specified character.
String list.
Definition: fbstring.h:208
int Find(const char *pString, bool pCaseSensitive=true, bool pStartWith=false) const
Find the index with the string pString (or start with pString)
int Find(kReference pRef) const
Find the index where pRef is stored.
FBStringList()
Constructor.
int GetCount() const
Get the number of items in the list.
KStringList * GetInternal() const
Get internal variable.
~FBStringList()
Destructor.
KStringList * mItems
Internal use only - List of items.
Definition: fbstring.h:211
const char * AsString(const char pSeparator='~') const
Get as string.
FBStringList(const char *pString, const char pSeparator='~')
Constructor.
int IndexOf(const char *S) const
Get the index of a string.
void RemoveAt(int pIndex)
Remove an entry at pIndex.
void InsertAt(int pIndex, const char *S, kReference pRef=0)
Insert an entry at pIndex.
void Clear()
Clear the list (remove all the items).
int Add(const char *S, kReference pRef=0)
Add a string to the list.
bool SetString(const char *pString, const char pSeparator='~')
Set string for list.
const char * GetAt(int pIndex) const
Get the string at pIndex.
bool SetAt(int pIndex, const char *pString)
Set the string at pIndex.
void SetReferenceAt(int pIndex, kReference pRef)
Set the reference stored with the string at pIndex.
int Remove(const char *S)
Remove a string from the list.
void Sort()
Sort the string list (ascending)
const char * operator[](int pIndex) const
Overloaded [] operator.
FBStringList(const FBStringList &pOther)
Copy constructor.
kReference GetReferenceAt(int pIndex) const
Get the reference store with the string at pIndex.
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbstring.h:49
Types & macros.