- Main Page
- Classes
- Files
- Directories

- File List
- File Members

# fbxstring.h

Go to the documentation of this file.

    00001 /****************************************************************************************
    00002
    00003    Copyright (C) 2013 Autodesk, Inc.
    00004    All rights reserved.
    00005
    00006    Use of this software is subject to the terms of the Autodesk license agreement
    00007    provided at the time of installation or download, or which otherwise accompanies
    00008    this software in either electronic or hard copy form.
    00009
    00010 ****************************************************************************************/
    00011
    00013 #ifndef _FBXSDK_CORE_BASE_STRING_H_
    00014 #define _FBXSDK_CORE_BASE_STRING_H_
    00015
    00016 #include <fbxsdk/fbxsdk_def.h>
    00017
    00018 #if defined(FBXSDK_COMPILER_MSC)
    00019     #if defined(FBXSDK_CPU_32)
    00020         #if _MSC_VER <= 1600
    00021             #define SIZE_OF_STDSTRING 32
    00022         #elif _MSC_VER == 1700
    00023             #define SIZE_OF_STDSTRING 28
    00024         #endif
    00025     #elif defined(FBXSDK_CPU_64)
    00026         #if _MSC_VER <= 1600
    00027             #define SIZE_OF_STDSTRING 48
    00028         #elif _MSC_VER == 1700
    00029             #define SIZE_OF_STDSTRING 40
    00030         #endif
    00031     #endif
    00032 #elif defined(FBXSDK_COMPILER_GNU)
    00033     #if defined(FBXSDK_CPU_32)
    00034         #define SIZE_OF_STDSTRING 4
    00035     #elif defined(FBXSDK_CPU_64)
    00036         #define SIZE_OF_STDSTRING 8
    00037     #endif
    00038 #endif
    00039
    00040 #if !defined(SIZE_OF_STDSTRING)
    00041     #error Unsupported architecture!
    00042 #endif
    00043
    00044 #define FBXSDK_STRING_OPAQUE_OBJECT_HEADER void* mOpaqueChunk[SIZE_OF_STDSTRING/sizeof(void*)]
    00045 #ifndef FBXSDK_STRING_OPAQUE_OBJECT
    00046     #define FBXSDK_STRING_OPAQUE_OBJECT FBXSDK_STRING_OPAQUE_OBJECT_HEADER
    00047 #endif
    00048
    00049 #include <fbxsdk/fbxsdk_nsbegin.h>
    00050
    00051 //Conversions between WideChar, UTF8 and ANSI
    00052
    00059 FBXSDK_DLL void FbxUTF8ToWC(const char* pInUTF8, wchar_t*& pOutWideChar, size_t* pOutWideCharSize = NULL);
    00060
    00067 FBXSDK_DLL void FbxWCToUTF8(const wchar_t* pInWideChar, char*& pOutUTF8, size_t* pOutUTF8Size = NULL);
    00068
    00069 #if defined(FBXSDK_ENV_WIN)
    00070
    00076     FBXSDK_DLL void FbxWCToAnsi(const wchar_t* pInWideChar, char*& pOutANSI, size_t* pOutANSISize = NULL);
    00077
    00084     FBXSDK_DLL void FbxAnsiToWC(const char* pInANSI, wchar_t*& pOutWideChar, size_t* pOutWideCharSize = NULL);
    00085
    00092     FBXSDK_DLL void FbxAnsiToUTF8(const char* pInANSI, char*& pOutUTF8, size_t* pOutUTF8Size = NULL);
    00093
    00100     FBXSDK_DLL void FbxUTF8ToAnsi(const char* pInUTF8, char*& pOutANSI, size_t* pOutANSISize = NULL);
    00101 #endif
    00102
    00105 class FBXSDK_DLL FbxString
    00106 {
    00107 public:
    00112
    00113         FbxString();
    00114
    00117         FbxString(const FbxString& pStr);
    00118
    00121         FbxString(const char* pStr);
    00122
    00126         FbxString(char pChar, size_t pNbRepeat=1);
    00127
    00131         FbxString(const char* pCharPtr, size_t pLength);
    00132
    00135         FbxString(const int pValue);
    00136
    00139         FbxString(const float pValue);
    00140
    00143         FbxString(const double pValue);
    00144
    00146         ~FbxString();
    00148
    00153
    00154         size_t GetLen() const;
    00155
    00157         bool IsEmpty() const;
    00158
    00160         FbxString& Clear();
    00161
    00165         char& operator[](int pIndex);
    00166
    00170         char operator[](int pIndex) const;
    00171
    00173         char* Buffer();
    00174
    00176         const char* Buffer()const;
    00178
    00185         const FbxString& operator=(const FbxString& pStr);
    00186
    00189         const FbxString& operator=(char pChar);
    00190
    00193         const FbxString& operator=(const char* pStr);
    00194
    00197         const FbxString& operator=(int pValue);
    00198
    00201         const FbxString& operator=(float pValue);
    00202
    00205         const FbxString& operator=(double pValue);
    00206
    00209         const FbxString& operator+=(const FbxString& pKStr);
    00210
    00213         const FbxString& operator+=(char pChar);
    00214
    00217         const FbxString& operator+=(const char* pStr);
    00218
    00221         const FbxString& operator+=(int pValue);
    00222
    00225         const FbxString& operator+=(float pValue);
    00226
    00229         const FbxString& operator+=(double pValue);
    00230
    00233         bool operator== (const FbxString& pStr) const;
    00234
    00237         bool operator!= (const FbxString& pStr) const;
    00238
    00241         bool operator< (const FbxString& pStr) const;
    00242
    00245         bool operator<= (const FbxString& pStr) const;
    00246
    00249         bool operator>= (const FbxString& pStr) const;
    00250
    00253         bool operator> (const FbxString& pStr) const;
    00254
    00257         bool operator== (const char* pStr) const;
    00258
    00261         bool operator!= (const char* pStr) const;
    00262
    00265         bool operator< (const char* pStr) const;
    00266
    00269         bool operator<= (const char* pStr) const;
    00270
    00273         bool operator>= (const char* pStr) const;
    00274
    00277         bool operator> (const char* pStr) const;
    00278
    00282         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr1, const FbxString& pKStr2);
    00283
    00287         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr, char pChar);
    00288
    00292         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr, const char* pStr);
    00293
    00297         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr, int pValue);
    00298
    00302         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr, float pValue);
    00303
    00307         friend FBXSDK_DLL FbxString operator+(const FbxString& pKStr, double pValue);
    00308
    00310         operator const char*() const;
    00311
    00315         const FbxString& Copy(const char* pStr, size_t pLength);
    00316
    00320         const FbxString& Append(const char* pStr, size_t pLength);
    00321
    00324         int Compare(const char* pStr) const;
    00325
    00328         int CompareNoCase(const char* pStr) const;
    00329
    00332         void Swap(FbxString& pStr);
    00333
    00335         FbxString Upper() const;
    00336
    00338         FbxString Lower() const;
    00340
    00348         FbxString Mid(size_t pFirst, size_t pCount) const;
    00349
    00352         FbxString Mid(size_t pFirst) const;
    00353
    00356         FbxString Left(size_t pCount) const;
    00357
    00360         FbxString Right(size_t pCount) const;
    00362
    00371         enum EPaddingType {eRight, eLeft, eBoth};
    00372
    00377         FbxString Pad(EPaddingType pPadding, size_t pLen, char pCar=' ') const;
    00378
    00381         FbxString UnPad(EPaddingType pPadding) const;
    00383
    00392         int Find(char pChar, size_t pStartPosition=0) const;
    00393
    00398         int Find(const char* pStrSub, size_t pStartPosition=0) const;
    00399
    00403         int ReverseFind(char pChar) const;
    00404
    00409         int FindOneOf(const char* pStrCharSet, size_t pStartPosition=0) const;
    00410
    00416         bool FindAndReplace(const char* pFind, const char* pReplaceBy, size_t pStartPosition=0);
    00417
    00422         bool ReplaceAll(const char* pFind, const char* pReplaceBy);
    00423
    00428         bool ReplaceAll(char pFind, char pReplaceBy);
    00430
    00438         int GetTokenCount(const char* pSpans) const;
    00439
    00443         FbxString GetToken(int pTokenIndex, const char* pSpans) const;
    00445
    00446 private:
    00447     FBXSDK_STRING_OPAQUE_OBJECT;
    00448 };
    00449
    00450 FBXSDK_INCOMPATIBLE_WITH_ARRAY(FbxString);
    00451
    00453 FBXSDK_DLL FbxString operator+(const FbxString& pKStr1, const FbxString& pKStr2);
    00454
    00456 FBXSDK_DLL FbxString operator+(const FbxString& pKStr, char pChar);
    00457
    00459 FBXSDK_DLL FbxString operator+(const FbxString& pKStr, const char* pStr);
    00460
    00462 FBXSDK_DLL FbxString operator+(const FbxString& pKStr, int pValue);
    00463
    00465 FBXSDK_DLL FbxString operator+(const FbxString& pKStr, float pValue);
    00466
    00468 FBXSDK_DLL FbxString operator+(const FbxString& pKStr, double pValue);
    00469
    00471 class FbxStringCompare
    00472 {
    00473 public:
    00479     inline int operator()(const FbxString& pKeyA, const FbxString& pKeyB) const
    00480     {
    00481         return (pKeyA < pKeyB) ? -1 : ((pKeyB < pKeyA) ? 1 : 0);
    00482     }
    00483 };
    00484
    00486 class FbxCharCompare
    00487 {
    00488 public:
    00490     inline int operator()(char const* pKeyA, char const* pKeyB) const
    00491     {
    00492         return strcmp(pKeyA, pKeyB);
    00493     }
    00494 };
    00495
    00500 inline void FbxRemoveChar(FbxString& pString, char pToRemove)
    00501 {
    00502     int lPos = pString.ReverseFind(pToRemove);
    00503     while( lPos >= 0 )
    00504     {
    00505         pString = pString.Left(lPos) + pString.Mid(lPos + 1);
    00506         lPos = pString.ReverseFind(pToRemove);
    00507     }
    00508 }
    00509
    00510 #include <fbxsdk/fbxsdk_nsend.h>
    00511
    00512 #endif /* _FBXSDK_CORE_BASE_STRING_H_ */