rpparser.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:10k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #ifndef RPPARSER_H
  36. #define RPPARSER_H
  37. #define REALPIX_STRICTNESS_LOW     0  // legacy errors pass through, no warnings
  38. #define REALPIX_STRICTNESS_MEDIUM  1  // legacy errors pass through, logged as warnings
  39. #define REALPIX_STRICTNESS_HIGH    2  // legacy errors thrown as errors
  40. class PXRealPixParser : public CHXBaseCountingObject,
  41.                         public CUnknownIMP,
  42.                         public IHXXMLParserResponse
  43. {
  44.     DECLARE_UNKNOWN(PXRealPixParser)
  45. public:
  46.     // PXRealPixParser methods
  47.     STDMETHOD(Init)                        (THIS_ IUnknown*        pContext,
  48.                                                   PXRealPixFile*   pRealPixFile,
  49.                                                   UINT32           ulStrictnessLevel);
  50.     STDMETHOD(Parse)                       (THIS_ IHXBuffer*      pFileBuffer,
  51.                                                   BOOL             bIsFinal,
  52.                                                   REF(IHXBuffer*) rpErrorText);
  53.     // IHXXMLParserResponse methods
  54.     STDMETHOD(HandleStartElement)          (THIS_ const char* pName,
  55.                                                   IHXValues* pAttributes,
  56.                                                   UINT32      ulLineNumber,
  57.                                                   UINT32      ulColumnNumber);
  58.     STDMETHOD(HandleEndElement)            (THIS_ const char* pName,
  59.                                                   UINT32      ulLineNumber,
  60.                                                   UINT32      ulColumnNumber);
  61.     STDMETHOD(HandleCharacterData)         (THIS_ IHXBuffer* pBuffer,
  62.                                                   UINT32      ulLineNumber,
  63.                                                   UINT32      ulColumnNumber);
  64.     STDMETHOD(HandleProcessingInstruction) (THIS_ const char* pTarget,
  65.                                                   IHXValues* pAttributes,
  66.                                                   UINT32      ulLineNumber,
  67.                                                   UINT32      ulColumnNumber);
  68.     STDMETHOD(HandleUnparsedEntityDecl)    (THIS_ const char* pEntityName,
  69.                                                   const char* pSystemID,
  70.                                                   const char* pPublicID,
  71.                                                   const char* pNotationName,
  72.                                                   UINT32      ulLineNumber,
  73.                                                   UINT32      ulColumnNumber);
  74.     STDMETHOD(HandleNotationDecl)          (THIS_ const char* pNotationName,
  75.                                                   const char* pSystemID,
  76.                                                   const char* pPublicID,
  77.                                                   UINT32      ulLineNumber,
  78.                                                   UINT32      ulColumNumber);
  79.     STDMETHOD(HandleComment)               (THIS_ const char* pComment,
  80.                                                   UINT32      ulLineNumber,
  81.                                                   UINT32      ulColumnNumber);
  82.     STDMETHOD(HandleUnparsedDoctypeDecl)   (THIS_ const char* pDoctype,
  83.                                                   const char* pSystemID,
  84.                                                   const char* pPublicID,
  85.                                                   UINT32      ulLineNumber,
  86.                                                   UINT32      ulColumnNumber);
  87.     STDMETHOD(HandleDefault)               (THIS_ IHXBuffer* pBuffer,
  88.                                                   UINT32      ulLineNumber,
  89.                                                   UINT32      ulColumnNumber);
  90. protected:
  91.     PXRealPixParser();
  92.     virtual ~PXRealPixParser();
  93.     enum
  94.     {
  95.         kTagRoot,
  96.         kTagHead,
  97.         kTagImage,
  98.         kTagFill,
  99.         kTagFadein,
  100.         kTagCrossfade,
  101.         kTagFadeout,
  102.         kTagWipe,
  103.         kTagAnimate,
  104.         kTagViewchange,
  105.         kTagEffect,
  106.         kNumTags  // This should always be last in the enum
  107.     };
  108.     enum
  109.     {
  110.         kAttrWidth,
  111.         kAttrHeight,
  112.         kAttrBitrate,
  113.         kAttrTimeformat,
  114.         kAttrVersion,
  115.         kAttrTitle,
  116.         kAttrAuthor,
  117.         kAttrCopyright,
  118.         kAttrBackgroundcolor,
  119.         kAttrBackgroundOpacity,
  120.         kAttrStart,
  121.         kAttrPreroll,
  122.         kAttrAspect,
  123.         kAttrUrl,
  124.         kAttrMaxfps,
  125.         kAttrDuration,
  126.         kAttrHandle,
  127.         kAttrName,
  128.         kAttrTarget,
  129.         kAttrSrcx,
  130.         kAttrSrcy,
  131.         kAttrSrcw,
  132.         kAttrSrch,
  133.         kAttrDstx,
  134.         kAttrDsty,
  135.         kAttrDstw,
  136.         kAttrDsth,
  137.         kAttrColor,
  138.         kAttrDirection,
  139.         kAttrType,
  140.         kAttrPackage,
  141.         kAttrData,
  142.         kAttrFile,
  143.         kAttrStartsrcx,
  144.         kAttrStartsrcy,
  145.         kAttrStartsrcw,
  146.         kAttrStartsrch,
  147.         kAttrStartdstx,
  148.         kAttrStartdsty,
  149.         kAttrStartdstw,
  150.         kAttrStartdsth,
  151.         kAttrCenter,
  152.         kAttrSize,
  153.         kAttrMime,
  154.         kNumAttr   // This should always be last in the enum
  155.     };
  156.     enum
  157.     {
  158.         kStateConstructed,
  159.         kStateInitialized,
  160.         kStateSawRootStart,
  161.         kStateSawHead,
  162.         kStateSawRootEnd
  163.     };
  164.     struct PXStringTable
  165.     {
  166.         UINT32      m_ulStringID;
  167.         const char* m_pszString;
  168.     };
  169.     HX_RESULT   SetError(UINT32 ulErrorID, UINT32 ulLine, UINT32 ulCol,
  170.                          const char* pszArg1, const char* pszArg2,
  171.                          REF(IHXBuffer*) rpErrStr);
  172.     HX_RESULT   ParseTag(UINT32 ulTagID, IHXValues* pAttr, UINT32 ulLine, UINT32 ulCol, REF(IHXBuffer*) rpError);
  173.     HX_RESULT   ParseHeadTag(IHXValues* pAttr, UINT32 ulLine, UINT32 ulCol, REF(IHXBuffer*) rpError);
  174.     HX_RESULT   ParseImageTag(IHXValues* pAttr, UINT32 ulLine, UINT32 ulCol, REF(IHXBuffer*) rpError);
  175.     HX_RESULT   ParseEffectTag(UINT32 ulTagID, IHXValues* pAttr, UINT32 ulLine,
  176.                                UINT32 ulCol, REF(IHXBuffer*) rpError);
  177.     HX_RESULT   SetupLegalAttrLUT();
  178.     HX_RESULT   SetupIDMaps();
  179.     BOOL        IsLegalAttr(UINT32 ulTagID, const char* pszAttr);
  180.     HX_RESULT   GetTagNameFromID(UINT32 ulTagID, REF(const char*) rpszTag);
  181.     HX_RESULT   GetTagIDFromName(const char* pszTag, REF(UINT32) rulTagID);
  182.     HX_RESULT   GetAttributeNameFromID(UINT32 ulAttrID, REF(const char*) rpszAttr);
  183.     HX_RESULT   GetAttributeIDFromName(const char* pszAttr, REF(UINT32) rulAttrID);
  184.     HX_RESULT   GetFirstRequiredAttribute(UINT32 ulTagID, REF(const char*) rpszAttr);
  185.     HX_RESULT   GetNextRequiredAttribute(UINT32 ulTagID, REF(const char*) rpszAttr);
  186.     HX_RESULT   CheckStringContents(IHXBuffer* pString);
  187.     HX_RESULT   ConvertTimeValue(IHXBuffer* pValue, UINT32 ulTimeFormat, REF(UINT32) ulTime);
  188.     HX_RESULT   ConvertBoolValue(IHXBuffer* pValue, REF(BOOL) rbValue);
  189.     HX_RESULT   ConvertVersionValue(IHXBuffer* pValue, REF(UINT32) rulVersion);
  190.     HX_RESULT   ConvertColorValue(IHXBuffer* pValue, REF(BYTE) rucRed,
  191.                                   REF(BYTE) rucGreen, REF(BYTE) rucBlue);
  192.     HX_RESULT   ConvertWipeDirectionValue(IHXBuffer* pValue, REF(BYTE) rucDir);
  193.     HX_RESULT   ConvertWipeTypeValue(IHXBuffer* pValue, REF(BYTE) rucType);
  194.     HX_RESULT   CheckVersion(UINT32 ulMinVersion);
  195.     void        ReportError(const UINT8 ucSeverity, HX_RESULT lHXCode, IHXBuffer* pErrorStr);
  196.     IUnknown*                  m_pContext;
  197.     IHXCommonClassFactory*     m_pCommonClassFactory;
  198.     IHXXMLParser*              m_pParser;
  199.     PXRealPixFile*             m_pRealPixFile;
  200.     IHXBuffer*                 m_pErrorText;
  201.     IHXBuffer*                 m_pLegalAttrLUT;
  202.     CHXMapStringToOb*          m_pTagToIDMap;
  203.     CHXMapStringToOb*          m_pAttrToIDMap;
  204.     BOOL                       m_bRealPixError;
  205.     BYTE*                      m_pByteListCursor;
  206.     UINT32                     m_ulState;
  207.     PXEffect*                  m_pLastEffect;
  208.     BOOL                       m_bVersionSpecified;
  209.     UINT32                     m_ulStrictnessLevel;
  210.     static const PXStringTable m_pTagTable[];
  211.     static const PXStringTable m_pAttrTable[];
  212.     static const BYTE          m_pAttrList[];
  213.     static const BYTE          m_pRequiredAttrList[];
  214.     static const UINT32        m_ulHighestSupportedContentVersion;
  215. };
  216. #endif