- Main Page
- Classes
- Files
- Directories

- File List
- File Members

# fbxcolladaiostream.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_FILEIO_COLLADA_IO_STREAM_H_
    00014 #define _FBXSDK_FILEIO_COLLADA_IO_STREAM_H_
    00015
    00016 #include <fbxsdk.h>
    00017
    00018 #include <fbxsdk/fbxsdk_nsbegin.h>
    00019
    00027 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())
    00028 {
    00029     if (pString == 0 || pArray == 0)
    00030         return 0;
    00031
    00032     FBX_ASSERT(pSourceUnitOffset >= 0 && pSourceUnitOffset < pSourceGroupSize);
    00033     FBX_ASSERT(pSourceValidUnitCount >= 0 && pSourceUnitOffset + pSourceValidUnitCount <= pSourceGroupSize);
    00034     FBX_ASSERT(pDestUnitOffset >= 0 && pDestUnitOffset < pDestGroupSize);
    00035     FBX_ASSERT(pDestValidUnitCount >= 0 && pDestUnitOffset + pDestValidUnitCount <= pDestGroupSize);
    00036     const char * lSource = pString;
    00037     TYPE * lDest = pArray;
    00038
    00039     int lReadCount = 0;
    00040     int lSourceCounter = 0;
    00041     int lDestCounter = 0;
    00042     const int lSourceUnitValidEnd = pSourceUnitOffset + pSourceValidUnitCount;
    00043     const int lDestUnitGap = pDestGroupSize - pDestValidUnitCount - pDestUnitOffset;
    00044     while (lSource && *lSource)
    00045     {
    00046         TYPE lData;
    00047         const char * lSourceStart = lSource;
    00048         if (FromString(&lData, lSource, &lSource) && lSourceCounter >= pSourceUnitOffset && lSourceCounter < lSourceUnitValidEnd)
    00049         {
    00050             if (lDestCounter == 0)
    00051             {
    00052                 for (int lIndex = 0; lIndex < pDestUnitOffset; ++lIndex)
    00053                     *(lDest++) = pDefaultValue;
    00054             }
    00055
    00056             *lDest++ = lData;
    00057             ++lReadCount;
    00058             ++lDestCounter;
    00059             if (lDestCounter == pDestValidUnitCount)
    00060             {
    00061                 lDestCounter = 0;
    00062                 for (int lIndex = 0; lIndex < lDestUnitGap; ++lIndex)
    00063                     *lDest++ = pDefaultValue;
    00064             }
    00065         }
    00066         else
    00067         {
    00068             // we met a stop condition of FromString. In the normal case, lSource should now be "" or ' '. If not,
    00069             // the converted string is corrupted and we have to break the loop. We can detect this by checking
    00070             // if lSource pointer has moved.
    00071             if (lSource == lSourceStart)
    00072             {
    00073                 break;
    00074             }
    00075         }
    00076         ++lSourceCounter;
    00077         if (lSourceCounter == pSourceGroupSize)
    00078             lSourceCounter = 0;
    00079     }
    00080     return lReadCount;
    00081 }
    00082
    00083 //----------------------------------------------------------------------------//
    00084
    00091 template <typename T> bool FromString(T * pDest, const char * pSourceBegin, const char ** pSourceEnd = NULL);
    00092 template <> bool FromString(int * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00093 template <> bool FromString(double * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00094 template <> bool FromString(FbxString * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00095 template <> bool FromString(FbxDouble2 * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00096 template <> bool FromString(FbxDouble3 * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00097 template <> bool FromString(FbxDouble4 * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00098 template <> bool FromString(FbxVector4 * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00099 template <> bool FromString(FbxAMatrix * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00100 template <> bool FromString(FbxAMatrix * pDest, const char * pSourceBegin, const char ** pSourceEnd);
    00101
    00102 //----------------------------------------------------------------------------//
    00103
    00104 template <typename T>
    00105 const FbxString ToString(const T & pValue)
    00106 {
    00107     return FbxString(pValue);
    00108 }
    00109 template <>
    00110 const FbxString ToString(const FbxVector4 & pValue);
    00111 template <>
    00112 const FbxString ToString(const FbxAMatrix & pValue);
    00113
    00114 //----------------------------------------------------------------------------//
    00115
    00121 const FbxString DecodePercentEncoding(const FbxString & pEncodedString);
    00122
    00123 #include <fbxsdk/fbxsdk_nsend.h>
    00124
    00125 #endif /* _FBXSDK_FILEIO_COLLADA_IO_STREAM_H_ */