imageeditorengine/inc/CExifParser.h
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CEXIFPARSER_H__
       
    21 #define __CEXIFPARSER_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 
       
    26 
       
    27 class TExifEntry
       
    28 	{
       
    29 	public:
       
    30 		inline TExifEntry()
       
    31 			{
       
    32 			iIfd = 0;
       
    33 			iTag = 0;
       
    34 			iType = 0;
       
    35 			iCount = 0;
       
    36 			iData = NULL;
       
    37 			}
       
    38 
       
    39 		inline ~TExifEntry()
       
    40 			{
       
    41 			delete iData;
       
    42 			}
       
    43 	public:
       
    44 		TUint8 iIfd;
       
    45 		TUint16 iTag;
       
    46 		TUint8 iType;
       
    47 		TUint32 iCount;
       
    48 		TUint8* iData;
       
    49 	};
       
    50 
       
    51 
       
    52 class TParseStack
       
    53 	{
       
    54 	public:
       
    55 		inline TParseStack( TUint32 aPosition, TUint8 aIfd )
       
    56 			: iPosition( aPosition )
       
    57 			, iIfd( aIfd )
       
    58 			{
       
    59 			}
       
    60 	public:
       
    61 		TUint32 iPosition;
       
    62 		TUint8 iIfd;
       
    63 	};
       
    64 
       
    65 
       
    66 
       
    67 class CExifParser
       
    68 	: public CBase
       
    69 	{
       
    70 	public:
       
    71 		enum EIfd
       
    72 			{
       
    73 			EIfd0 = 0,
       
    74 			EIfd1,
       
    75 			ESubIfd,
       
    76 			EInteroperability
       
    77 			};
       
    78 
       
    79 	public:
       
    80 		static CExifParser* NewL();
       
    81 		static CExifParser* NewLC();
       
    82 		~CExifParser();
       
    83 
       
    84 	private:
       
    85 		CExifParser();
       
    86 		void ConstructL();
       
    87 
       
    88 	public:
       
    89 		void ParseL( const TPtrC8& aData );
       
    90 		TBool TagExist( TInt aIfd, TUint16 aTag );
       
    91 		void DeleteTag( TInt aIfd, TUint16 aTag );
       
    92 		TUint32 TagValue( TInt aIfd, TUint16 aTag );
       
    93 		
       
    94 		void AddTagL( TInt aIfd, TUint16 aTag, TInt32 aValue );
       
    95 		void AddTagL( TInt aIfd, TUint16 aTag, TUint32 aValue );
       
    96 		void AddTagL( TInt aIfd, TUint16 aTag, TUint16 aValue );
       
    97 		void AddTagL( TInt aIfd, TUint16 aTag, TUint8 aValue );
       
    98 		void AddTagL( TInt aIfd, TUint16 aTag, TPtrC8 aData );
       
    99 		void AddTagL( TInt aIfd, TUint16 aTag, const TUint8* aValue );
       
   100 		void AddTagL( TInt aIfd, TUint16 aTag, TUint32 aNominator, TUint32 aDenominator );
       
   101 
       
   102 		TPtrC8 ThumbData();
       
   103 		TPtr8 SaveL( const TPtrC8& aThumbData );
       
   104 
       
   105 
       
   106 	private: // new methods
       
   107 		TUint32 Get8();
       
   108 		TUint32 Get16();
       
   109 		TUint32 Get32();
       
   110 		TUint32 Get8( const TUint8* aData );
       
   111 		TUint32 Get16( const TUint8* aData );
       
   112 		TUint32 Get32( const TUint8* aData );
       
   113 		void ParseIfdL( TUint8 aIfd );
       
   114 		TInt FindTag( TInt aIfd, TUint16 aTag );
       
   115 		void StoreEntry( TInt aIndex );
       
   116 
       
   117 		void Put8( TUint8 aData );
       
   118 		void Put16( TUint16 aData );
       
   119 		void Put32( TUint32 aData );
       
   120 
       
   121 		TUint32 StoreData( TUint8* aData, TInt aCount );
       
   122 
       
   123 		TInt IfdCount( TInt aType );
       
   124 
       
   125 		void AddTagL( TInt aIfd, TUint16 aTag, TInt aType, TUint8* aData, TInt aDataLen );
       
   126 
       
   127 
       
   128 
       
   129 	private:
       
   130 		TPtrC8	iData;
       
   131 		TInt	iPosition;
       
   132 		TBool	iIntelByteOrder;
       
   133 
       
   134 		RArray< TParseStack >iParseStack;
       
   135 		RPointerArray< TExifEntry >iEntry;
       
   136 
       
   137 		TUint8*	iSaveBuf;				// used to store tags
       
   138 		TInt	iSaveBufPos;
       
   139 
       
   140 		TUint8*	iSaveDataBuf;			// used to store tag data
       
   141 		TInt	iSaveDataBufPos;
       
   142 
       
   143 		RArray< TUint32 >iDataEntry;	// list of tag data pointers
       
   144 
       
   145 		TUint8*	iThumbData;
       
   146 		TInt	iThumbLen;
       
   147 	};
       
   148 
       
   149 #endif