00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __CXSIParser_H__
00032 #define __CXSIParser_H__
00033
00034
00035
00036
00037
00038 #include <SIBCUtil.h>
00039 #include <SIBCString.h>
00040
00041 #include "dotXSITemplate.h"
00042 #include "CXSIFilter.h"
00043
00044 namespace xercesc_2_7
00045 {
00046 class SAX2XMLReader;
00047 }
00048 class CCOLLADATemplate;
00049
00050 #define FORMAT_TEXT 0
00051 #define FORMAT_BINARY 1
00052 #define FORMAT_COLLADA 2
00053
00054 #define OPEN_READ 0
00055 #define OPEN_WRITE 1
00056
00057
00058
00059
00060
00061 class CdotXSITemplate;
00062 class CdotXSITemplates;
00063
00064 typedef struct
00065 {
00066 SI_Int nLen;
00067 SI_Char *pLabel;
00068 } TdotXSIDictEntry;
00069
00070 class CXSIParser;
00071
00072 typedef SI_Void (*SI_READ_CALLBACK_FNC) ( CXSIParser* );
00073
00075 class XSIEXPORT CXSIReturn
00076 {
00077 public:
00078 void *m_pPointer;
00079 CSIBCString m_Parameter;
00080 int m_Flags;
00081 };
00082
00083
00085 class XSIEXPORT CdotXSIDict
00086 {
00087 public :
00089 CdotXSIDict();
00091 ~CdotXSIDict();
00095 SI_Void Init( SI_Int i_nCount );
00099 SI_Void Add( SI_Char *i_pLabel );
00103 SI_Int GetCount();
00108 SI_Void Find( SI_Int i_nInd, SI_Char **o_pLabel );
00113 SI_Int Find( SI_Char *i_pLabel );
00117 SI_Void Read( _SI_FILE i_pFptr );
00121 SI_Void Write( _SI_FILE i_pFptr );
00122
00123 private :
00124 SI_Int m_nTotalCount;
00125 SI_Int m_nCount;
00126 TdotXSIDictEntry *m_Dict;
00127 };
00128
00130 class XSIEXPORT CXSIParser
00131 {
00132 public:
00133 CXSIParser();
00134 ~CXSIParser();
00135
00139 SI_Error Open(const CSIBCString &in_filename);
00143 SI_Bool EndOfFile();
00147 SI_Error Close();
00148
00152 CSIBCString &FileName() { return m_sFilename; }
00153
00157 SI_Int GetNbSupportedTemplates();
00161 SI_Char *GetSupportedTemplate(SI_Int in_lIndex);
00162
00166 SI_Char *GetNextTokenAsCharPtr();
00170 SI_Char *GetNextTokenAsString();
00174 SI_Float GetNextTokenAsFloat();
00178 SI_Int GetNextTokenAsInteger();
00188 SI_Error GetNextTokensAsFloatArray( SI_Int numFloats,
00189 SI_Int fileStepCount,
00190 SI_Int fileSkipCount,
00191 SI_Int arrayStepCount,
00192 SI_Int arraySkipCount,
00193 SI_Float *i_pArray );
00194
00204 SI_Error GetNextTokensAsIntegerArray( SI_Int numInts,
00205 SI_Int fileStepCount,
00206 SI_Int fileSkipCount,
00207 SI_Int arrayStepCount,
00208 SI_Int arraySkipCount,
00209 SI_Int *i_pArray );
00210
00220 SI_Error GetNextTokensAsUnsignedShortArray( SI_Int numUShorts,
00221 SI_Int fileStepCount,
00222 SI_Int fileSkipCount,
00223 SI_Int arrayStepCount,
00224 SI_Int arraySkipCount,
00225 SI_UShort *i_pArray );
00226
00230 SI_Char *GetCurrentTokenAsCharPtr();
00234 SI_Float GetCurrentTokenAsFloat();
00235
00239 SI_Int GetCurrentTokenAsInteger();
00240
00246 SI_Error GetNextPairAsFloat( SI_Float &fX, SI_Float &fY );
00251 SI_Error GetNextPairAsInt( SI_Int &nX, SI_Int &nY );
00252
00259 SI_Error GetNextTrippletAsFloat( SI_Float &fX, SI_Float &fY, SI_Float &fZ );
00265 SI_Error GetNextTrippletAsInt( SI_Int &nX, SI_Int &nY, SI_Int &nZ );
00266
00270 SI_Void SetOpenMode( SI_Int i_nMode );
00274 SI_Int GetOpenMode() { return m_nOpenMode; }
00275
00276
00277
00282 SI_Int CheckNextToken( CSIBCString *i_pReadString );
00286 SI_Long GetdotXSIFileVersionMajor() { return m_dotXSIFileVersionMajor; }
00290 SI_Long GetdotXSIFileVersionMinor() { return m_dotXSIFileVersionMinor; }
00294 SI_Int GetdotXSIFormat() { return m_dotXSIFormat; }
00298 SI_Void SetdotXSIFormat( SI_Int dotXSIFormat ) { m_dotXSIFormat = dotXSIFormat; }
00299
00303 SI_Int GetdotXSISystemFlags() { return m_dotXSISystemFlags; }
00307 SI_Void SetdotXSISystemFlags( SI_Int dotXSISystemFlags ) { m_dotXSISystemFlags = dotXSISystemFlags; }
00308
00313 SI_Int SetdotXSIFileVersion( SI_Int, SI_Int );
00317 SI_Int GetdotXSINumFileVersion();
00324 SI_Error GetdotXSIFileVersion( int, int*, int* );
00328 SI_Error Read();
00332 SI_Error Write();
00338 SI_Bool ReadTemplate( CSIBCString *i_sTemplateName, CdotXSITemplate *i_pParent );
00344 SI_Void WriteTemplate( CdotXSITemplates *dotXSITemplates, SI_Int i_nInd, SI_Int i_nLevel );
00349 CdotXSITemplates *dotXSITemplate() { return m_dotXSITemplates; }
00353 CdotXSITemplates *dotXSISupported() { return m_dotXSISupported; }
00357 SI_Int GetString();
00362 SI_Error AddEscapeChar ( const SI_Char *in_pStr, SI_Char *out_pStr );
00363
00364
00379 SI_Error ReadGenericParameters( CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nNbParam );
00389 SI_Error ReadParameterValue( SI_TinyVariant *o_vValue, SI_Int i_nLastInt );
00390
00400 SI_Error ReadCOLLADAParameterValue( SI_TinyVariant *o_vValue, char **in_pStream );
00401
00402
00414 SI_Error ReadIntegerArray( CdotXSITemplate *i_pNewTemplate, SI_Int i_nNbVertices, SI_Char *i_sName );
00415
00426 SI_Error ReadFloatArray( CdotXSITemplate *i_pNewTemplate, SI_Int i_nNbVertices, SI_Char *i_sName );
00427
00438 SI_Error ReadDoubleArray( CdotXSITemplate *i_pNewTemplate, SI_Int i_nNbVertices, SI_Char *i_sName );
00439
00440
00445 SI_Void WriteTabs( SI_Int i_nLevel );
00452 SI_Void WriteGenericParameters( CdotXSITemplate *i_pCurrentTemplate, SI_Int i_nNbParams, SI_Int i_nLevel );
00459 SI_Void WriteParameterValue( SI_TinyVariant *i_vValue, SI_Int i_nLevel, SI_Int in_nFlag = 0 );
00465 SI_Void RegisterdotXSINativeTemplates( SI_Long i_lMajor, SI_Long i_lMinor, SI_Int i_lFormat );
00470 SI_Void CleardotXSINativeTemplates();
00474 CdotXSITemplates* GetdotXSINativeTemplates();
00475
00476
00477
00478
00482 SI_Int FTK_Eof ();
00488 SI_Int FTK_Open (SI_Char* in_szName, _SI_FILE_MODE in_Mode );
00492 SI_Int FTK_Close ();
00498 SI_Long FTK_Read (void *out_pBuffer, SI_Long size, SI_Long count);
00504 SI_Int FTK_Write (void *in_pBuffer, SI_Long size, SI_Long count);
00508 SI_Int FTK_Printf (SI_Char* in_szData );
00514 SI_Int FTK_Seek (SI_Long in_lCount, SI_Int in_iMode );
00518 SI_Long FTK_Tell ();
00522 SI_Int FTK_FGetc ();
00526 SI_Int FTK_Getc ();
00527
00528
00529
00530
00535 SI_Void SetWarningCallback ( SI_WARNING_CALLBACK_FNC in_pfncCallback );
00541 SI_Void FTK_Warning ( SI_Char *in_szWarning, SI_Int in_iWarningLevel );
00542
00546 SI_Error GetLastError() { return m_nLastError; }
00547
00548
00549
00550
00555 SI_Void SetReadCallback(SI_READ_CALLBACK_FNC in_pCallback);
00559 SI_READ_CALLBACK_FNC GetReadCallback();
00560
00564 SI_Void ClearSkipTable();
00565
00569 SI_Void SkipTemplate ( CSIBCString );
00570
00571
00572
00573
00574 void endDocument();
00575
00576 void endElement( const void* const uri,
00577 const void* const localname,
00578 const void* const qname);
00579
00580 void characters(const void* const chars, const unsigned int length);
00581
00582 void ignorableWhitespace
00583 (
00584 const void* const chars
00585 , const unsigned int length
00586 );
00587
00588 void processingInstruction
00589 (
00590 const void* const target
00591 , const void* const data
00592 );
00593
00594 void startDocument();
00595
00596 void startElement( const void* const uri,
00597 const void* const localname,
00598 const void* const qname,
00599 const void* attributes);
00600
00601 SI_Char* GetErrors() { return m_csError.GetText (); }
00602
00603
00604
00605
00606
00607 void warning(const void* exception);
00608 void error(const void* exception);
00609 void fatalError(const void* exception);
00610
00611 CdotXSITemplate* ResolveTemplateURL ( const SI_Char* in_szLibrary, const SI_Char* in_URL );
00612
00613
00614 protected:
00615 SI_Error ParseToken();
00616 SI_Error ParseCOLLADAToken(char **in_pStream);
00617
00618 SI_Int CheckFileType();
00619
00620 private:
00621
00622 SI_Error ReadCOLLADA();
00623 SI_Error WriteCOLLADA();
00624 SI_Void WriteCOLLADATemplate( CdotXSITemplates *dotXSITemplates, SI_Int i_nInd, SI_Int i_nLevel );
00625
00626 enum
00627 {
00628 BUFFER_SIZE = 1024,
00629 FILE_BUFFER_SIZE = 16384
00630 };
00631
00632 CSIBCString m_sFilename;
00633 SI_Char *m_Buffer;
00634 SI_Int m_BufferSize;
00635 SI_Char *m_pCurrentToken;
00636 SI_Int m_nOpenMode;
00637 SI_Error m_nLastError;
00638
00639 SI_Bool IsInvalidParameterValue();
00640 SI_Error IncrementParseSpot();
00641 SI_Error GetNextByte(SI_Byte *in_pRead);
00642 void CreateFilter ();
00643 SI_Error ReadDotXSIHeader();
00644 CXSIFilter* CreateFilterFromID ( SI_Char* in_szID );
00645
00646
00647 CdotXSITemplates *m_dotXSITemplates;
00648 CdotXSITemplates *m_dotXSISupported;
00649 CdotXSITemplates *m_dotXSIUnsupported;
00650
00651 SI_Long m_dotXSIFileVersionMajor;
00652 SI_Long m_dotXSIFileVersionMinor;
00653 SI_Int m_dotXSIFormat;
00654 SI_Int m_dotXSISystemFlags;
00655
00656 CdotXSIDict m_dotXSIDict;
00657 CdotXSITemplates m_dotXSINativeTemplates;
00658 CSIAccumString m_szAccumBuffer;
00659 SI_Long m_lFilePtr;
00660
00661
00662
00663
00664
00665 CXSIFilter *m_pParserFilter;
00666 SI_Int m_iDataExported;
00667
00668
00669
00670
00671 SI_WARNING_CALLBACK_FNC m_pfncWarningCallback;
00672
00673
00674 SI_READ_CALLBACK_FNC m_pReadCallback;
00675
00676
00677
00678
00679 xercesc_2_7::SAX2XMLReader *m_pXMLParser;
00680 CSIBCString m_XMLBuffer;
00681 CSIBCString m_csError;
00682 CCOLLADATemplate *m_pParentTemplate;
00683 CdotXSITemplate* RecurseResolveURL ( CdotXSITemplate* in_pTemplate, const SI_Char* libID, const SI_Char* in_URL );
00684
00685 CSIBCArray<CSIBCString> m_SkipTable;
00686 SI_Int m_iIsInsideExtra;
00687 bool m_bNoTyping;
00688 };
00689
00690
00691
00692
00693
00702 extern SI_Bool IsSeparator( SI_Char i_Char );
00703
00704
00705
00706
00718 SI_Error dotXSICB_ReadGeneric( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00724 SI_Error dotXSICB_ReadCluster( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00730 SI_Error dotXSICB_ReadConstraint( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00736 SI_Error dotXSICB_ReadCustomPSet( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00742 SI_Error dotXSICB_ReadEnvelope( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00748 SI_Error dotXSICB_ReadFCurve( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00754 SI_Error dotXSICB_ReadFileInfo( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00760 SI_Error dotXSICB_ReadIKRoot( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00766 SI_Error dotXSICB_ReadImageClip( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00772 SI_Error dotXSICB_ReadLight( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00778 SI_Error dotXSICB_ReadNurbsSurface( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00784 SI_Error dotXSICB_ReadNurbsCurve( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00790 SI_Error dotXSICB_ReadPatchSurface( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00796 SI_Error dotXSICB_ReadPolygonList( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00802 SI_Error dotXSICB_ReadScene( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00808 SI_Error dotXSICB_ReadShape( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00814 SI_Error dotXSICB_ReadTriangleList( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00820 SI_Error dotXSICB_ReadTriStrip( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate );
00821
00827 SI_Error dotXSICB_WriteGeneric( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00833 SI_Error dotXSICB_WriteCluster( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00839 SI_Error dotXSICB_WriteConstraint( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00845 SI_Error dotXSICB_WriteCustomPSet( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00851 SI_Error dotXSICB_WriteEnvelope( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00857 SI_Error dotXSICB_WriteFCurve( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00863 SI_Error dotXSICB_WriteFileInfo( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00869 SI_Error dotXSICB_WriteIKRoot( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00875 SI_Error dotXSICB_WriteImageClip( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00881 SI_Error dotXSICB_WriteNurbsSurface( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00887 SI_Error dotXSICB_WriteNurbsCurve( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00893 SI_Error dotXSICB_WritePatchSurface( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00899 SI_Error dotXSICB_WritePolygonList( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00905 SI_Error dotXSICB_WriteShape( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00911 SI_Error dotXSICB_WriteTriangleList( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00917 SI_Error dotXSICB_WriteTriStrip( CXSIParser *i_pParser, CdotXSITemplate *i_pCurrentTemplate, CdotXSITemplate *i_pNewTemplate, SI_Int i_nLevel );
00918
00919
00920
00921 #endif // CXSIParser