fbxsdk/fileio/collada/fbxcolladaiostream.h File Reference

fbxcolladaiostream.h File Reference
#include <fbxsdk.h>
#include <fbxsdk/fbxsdk_nsbegin.h>
#include <fbxsdk/fbxsdk_nsend.h>

Functions

template<typename T >
bool FromString (T *pDest, const char *pSourceBegin, const char **pSourceEnd=((void *) 0))
 Convert part of the source string into destination type. More...
 
template<>
bool FromString (int *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (double *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxString *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxDouble2 *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxDouble3 *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxDouble4 *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxVector4 *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<>
bool FromString (FbxAMatrix *pDest, const char *pSourceBegin, const char **pSourceEnd)
 
template<typename TYPE >
int FromStringToArray (const char *pString, TYPE *pArray, int pSourceUnitOffset, int pSourceValidUnitCount, int pSourceGroupSize, int pDestUnitOffset, int pDestValidUnitCount, int pDestGroupSize, TYPE pDefaultValue=TYPE())
 Parse the string into an array. More...
 
template<typename T >
const FbxString ToString (const T &pValue)
 
template<>
const FbxString ToString (const FbxVector4 &pValue)
 
template<>
const FbxString ToString (const FbxAMatrix &pValue)
 
const FbxString DecodePercentEncoding (const FbxString &pEncodedString)
 Decode percent encoded characters, returns an empty string if there's an error. More...
 

Function Documentation

bool FromString ( T *  pDest,
const char *  pSourceBegin,
const char **  pSourceEnd = ((void *) 0) 
)

Convert part of the source string into destination type.

Parameters
pDestThe destination with a specific type.
pSourceBeginThe begin of the source string.
pSourceEndReturn the end of the part of the source string.
Returns
Return true on success and false if else.
bool FromString ( int *  pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( double *  pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxString pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxDouble2 pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxDouble3 pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxDouble4 pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxVector4 pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
bool FromString ( FbxAMatrix pDest,
const char *  pSourceBegin,
const char **  pSourceEnd 
)
int FromStringToArray ( const char *  pString,
TYPE *  pArray,
int  pSourceUnitOffset,
int  pSourceValidUnitCount,
int  pSourceGroupSize,
int  pDestUnitOffset,
int  pDestValidUnitCount,
int  pDestGroupSize,
TYPE  pDefaultValue = TYPE() 
)

Parse the string into an array.

The source string is made up with many groups and each group contains pSourceGroupSize units separated by spaces; The destination array is also made up with many groups and each unit contains pDestGroupSize units. The valid unit range in each source group is [pSourceUnitOffset, pSourceUnitOffset + pSourceValidUnitCount). The valid unit range in each destination unit is [pDestUnitOffset, pDestUnitOffset + pDestValidUnitCount). The units in invalid range of destination is set to a default value.

Definition at line 48 of file fbxcolladaiostream.h.

49 {
50  if (pString == 0 || pArray == 0)
51  return 0;
52 
53  FBX_ASSERT(pSourceUnitOffset >= 0 && pSourceUnitOffset < pSourceGroupSize);
54  FBX_ASSERT(pSourceValidUnitCount >= 0 && pSourceUnitOffset + pSourceValidUnitCount <= pSourceGroupSize);
55  FBX_ASSERT(pDestUnitOffset >= 0 && pDestUnitOffset < pDestGroupSize);
56  FBX_ASSERT(pDestValidUnitCount >= 0 && pDestUnitOffset + pDestValidUnitCount <= pDestGroupSize);
57  const char * lSource = pString;
58  TYPE * lDest = pArray;
59 
60  int lReadCount = 0;
61  int lSourceCounter = 0;
62  int lDestCounter = 0;
63  const int lSourceUnitValidEnd = pSourceUnitOffset + pSourceValidUnitCount;
64  const int lDestUnitGap = pDestGroupSize - pDestValidUnitCount - pDestUnitOffset;
65  while (lSource && *lSource)
66  {
67  TYPE lData;
68  const char * lSourceStart = lSource;
69  if (FromString(&lData, lSource, &lSource) && lSourceCounter >= pSourceUnitOffset && lSourceCounter < lSourceUnitValidEnd)
70  {
71  if (lDestCounter == 0)
72  {
73  for (int lIndex = 0; lIndex < pDestUnitOffset; ++lIndex)
74  *(lDest++) = pDefaultValue;
75  }
76 
77  *lDest++ = lData;
78  ++lReadCount;
79  ++lDestCounter;
80  if (lDestCounter == pDestValidUnitCount)
81  {
82  lDestCounter = 0;
83  for (int lIndex = 0; lIndex < lDestUnitGap; ++lIndex)
84  *lDest++ = pDefaultValue;
85  }
86  }
87  else
88  {
89  // we met a stop condition of FromString. In the normal case, lSource should now be "" or ' '. If not,
90  // the converted string is corrupted and we have to break the loop. We can detect this by checking
91  // if lSource pointer has moved.
92  if (lSource == lSourceStart)
93  {
94  break;
95  }
96  }
97  ++lSourceCounter;
98  if (lSourceCounter == pSourceGroupSize)
99  lSourceCounter = 0;
100  }
101  return lReadCount;
102 }
bool FromString(T *pDest, const char *pSourceBegin, const char **pSourceEnd=((void *) 0))
Convert part of the source string into destination type.
const FbxString ToString ( const T &  pValue)

Definition at line 107 of file fbxcolladaiostream.h.

108 {
109  return FbxString(pValue);
110 }
Utility class to manipulate strings.
Definition: fbxstring.h:66
const FbxString ToString ( const FbxVector4 pValue)
const FbxString ToString ( const FbxAMatrix pValue)
const FbxString DecodePercentEncoding ( const FbxString pEncodedString)

Decode percent encoded characters, returns an empty string if there's an error.

For example, a string like "abc%20abc" is converted into "abc abc".

Parameters
pEncodedStringThe percent encoded string.
Returns
The decoded string.

Go to the source code of this file.