imagingmodules/exiflib/inc/ExifEndian.h
changeset 0 469c91dae73b
equal deleted inserted replaced
-1:000000000000 0:469c91dae73b
       
     1 /*
       
     2 * Copyright (c) 2003, 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:  Exif data parser for both Little and Big Endian formats.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef EXIFENDIAN_H
       
    20 #define EXIFENDIAN_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 /**
       
    28 *  Exif data parser base class.
       
    29 *  Provides the base for Little and Big endian parsers.
       
    30 *
       
    31 *  @lib ExifLib
       
    32 *  @since 2.6 
       
    33 */
       
    34 NONSHARABLE_CLASS( CExifEndianBase ): public CBase
       
    35     {
       
    36     public:  // Constructors and destructor
       
    37 
       
    38         /**
       
    39         * Two-phased constructor.
       
    40         */
       
    41         static CExifEndianBase* NewBaseL( 
       
    42             const TUint8* aExifDataPtr, 
       
    43             TUint aDataLength, 
       
    44             TBool aIsExif );
       
    45 
       
    46         /**
       
    47         * Destructor.
       
    48         */
       
    49         virtual ~CExifEndianBase();
       
    50 
       
    51         /**
       
    52         * Gets the next 8-bit unsigned integer from the data.
       
    53         * @since 2.6 
       
    54         * @param aUint8 The 8-bit integer returned.
       
    55         * @return Error code.
       
    56         */
       
    57         TInt ReadUint8( TUint8& aUint8 );
       
    58 
       
    59         /**
       
    60         * Gets the next 16-bit unsigned integer from the data.
       
    61         * @since 2.6 
       
    62         * @param aUint16 The 16-bit integer returned.
       
    63         * @return Error code.
       
    64         */
       
    65         virtual TInt ReadUInt16( TUint16& aUint16 ) = 0;
       
    66 
       
    67         /**
       
    68         * Gets the next 32-bit unsigned integer from the data.
       
    69         * @since 2.6 
       
    70         * @param aUint32 The 32-bit integer returned.
       
    71         * @return Error code.
       
    72         */
       
    73         virtual TInt ReadUInt32( TUint32& aUint32 ) = 0;
       
    74 
       
    75         /**
       
    76         * Copies the data from the location, which starts and ends with the 
       
    77         * given Jpeg Markers.
       
    78         * @since 2.6 
       
    79         * @param aStartMarker Jpeg Marker for the beginning of copying.
       
    80         * @param aEndMarker Jpeg Marker for the end of copying.
       
    81         * @param aDestBuffer Pointer to the target descriptor.
       
    82         * @param aIncludeEnd States if the ending Jpeg Marker will be copied 
       
    83         *                    or not.
       
    84         * @return void
       
    85         */
       
    86         void CopyBufferL( 
       
    87             TUint16 aStartMarker, 
       
    88             TUint16 aEndMarker, 
       
    89             HBufC8*& aDestBuffer, 
       
    90             TBool aIncludeEnd = ETrue );
       
    91 
       
    92         /**
       
    93         * Copies the next specified amount of data to the given descriptor.
       
    94         * @since 2.6 
       
    95         * @param aCount Number of words to copy
       
    96         * @param aWordSize Word size
       
    97         * @param aBuffer Pointer to the target descriptor.
       
    98         * @return void
       
    99         */
       
   100         virtual TInt CopyBuffer( 
       
   101             TUint32 aCount, 
       
   102             TUint8 aWordSize, 
       
   103             HBufC8*& aBuffer ) = 0;
       
   104 
       
   105         /**
       
   106         * Copies the specified amount of data located in the given offset to 
       
   107         * the given descriptor.
       
   108         * @since 2.6 
       
   109         * @param aOffset Offset for starting copying
       
   110         * @param aCount Number of words to copy
       
   111         * @param aWordSize Word size
       
   112         * @param aBuffer Pointer to the target descriptor.
       
   113         * @return void
       
   114         */
       
   115         virtual TInt CopyBuffer( 
       
   116             TUint32 aOffset, 
       
   117             TUint32 aCount, 
       
   118             TUint8 aWordSize, 
       
   119             HBufC8*& aBuffer ) = 0;
       
   120 
       
   121         /**
       
   122         * Moves to the specified offset.
       
   123         * @since 2.6 
       
   124         * @param aOffset Target offset.
       
   125         * @return Error code.
       
   126         */
       
   127         TInt MoveTo( TUint aOffset );
       
   128 
       
   129         /**
       
   130         * Moves the current position forward by the given number of bytes.
       
   131         * @since 2.6 
       
   132         * @param aNoBytes Number of bytes to skip
       
   133         * @return Error code.
       
   134         */
       
   135         TInt Skip( TUint aNoBytes );
       
   136 
       
   137         /**
       
   138         * Locates the offset of the next specified 8-bit unsigned integer 
       
   139         * @since 2.6 
       
   140         * @param aSearch Queried 8-bit unsigned integer
       
   141         * @param aOffset The offset of the found location.
       
   142         * @return Error code.
       
   143         */
       
   144         TInt Locate8( TUint8 aSearch, TUint32& aOffset );
       
   145 
       
   146         /**
       
   147         * Locates the offset of the next specified 16-bit unsigned integer 
       
   148         * @since 2.6 
       
   149         * @param aSearch Queried 16-bit integer
       
   150         * @param aOffset The offset of the found location.
       
   151         * @return Error code.
       
   152         */
       
   153         virtual TInt Locate16( TUint16 aSearch, TUint32& aOffset ) = 0;
       
   154 
       
   155         /**
       
   156         * Locates the offset of the specified Jpeg Marker, which resides 
       
   157         * inside the given interval.
       
   158         * @since 2.6 
       
   159         * @param aMarker The queried Jpeg Marker
       
   160         * @param aOffset The offset of the found location.
       
   161         * @param aAfter Offset for starting searching.
       
   162         * @param aBefore Offset for ending searching.
       
   163         * @return Error code.
       
   164         */
       
   165         TInt LocateJpegMarker( 
       
   166             TUint16 aMarker, 
       
   167             TUint32& aOffset, 
       
   168             TUint32 aAfter = 0,
       
   169             TUint32 aBefore = 0 );
       
   170 
       
   171         /**
       
   172         * Locates the offset of the last specified Jpeg Marker, which resides
       
   173         * inside the given interval
       
   174         * @since 2.6 
       
   175         * @param aMarker The queried Jpeg Marker
       
   176         * @param aOffset The offset of the found location.
       
   177         * @param aAfter Offset for starting searching.
       
   178         * @param aBefore Offset for ending searching.
       
   179         * @return Error code.
       
   180         */
       
   181         TInt LocateJpegMarkerFromEnd( 
       
   182             TUint16 aMarker, 
       
   183             TUint32& aOffset, 
       
   184             TUint32 aAfter = 0,
       
   185             TUint32 aBefore = 0 );
       
   186 
       
   187         /**
       
   188         * Returns the current offset position
       
   189         * @since 3.1 
       
   190         * @param aOffset The offset of the location.
       
   191         * @return void.
       
   192         */
       
   193         void CurrentPosOffset( TUint32& aOffset );
       
   194         
       
   195     protected:
       
   196 
       
   197         /**
       
   198         * C++ default constructor.
       
   199         */
       
   200         CExifEndianBase();
       
   201 
       
   202     private:
       
   203 
       
   204         /**
       
   205         * By default Symbian 2nd phase constructor is private.
       
   206         */
       
   207         void ConstructL();
       
   208 
       
   209     protected:  // Data
       
   210 
       
   211         // The offset of the current position in the Exif data.
       
   212         TUint32 iPosOffset;
       
   213 
       
   214         // The offset of the Exif header (APP1 header) in the Exif data.
       
   215         TUint32 iExifStartOffset;
       
   216 
       
   217         // The offset for the end of Exif data.
       
   218         TUint32 iExifEndOffset;
       
   219 
       
   220         // The pointer to the beginning of the Exif data.
       
   221         TUint8* iDataStartPtr;
       
   222 
       
   223     };
       
   224 
       
   225 
       
   226 /**
       
   227 *  Exif data parser class for Little endian format.
       
   228 *
       
   229 *  @lib ExifLib
       
   230 *  @since 2.6 
       
   231 */
       
   232 NONSHARABLE_CLASS( CExifLittleEndian ): public CExifEndianBase
       
   233     {
       
   234     public:  // Constructors and destructor
       
   235 
       
   236         /**
       
   237         * Two-phased constructor.
       
   238         */
       
   239         static CExifLittleEndian* NewL( 
       
   240             const TUint8* aDataStartPtr,
       
   241             TUint8* aExifStartPtr, 
       
   242             TUint8* aExifEndPtr, 
       
   243             TBool aIsExif );
       
   244 
       
   245         /**
       
   246         * C++ default constructor.
       
   247         */
       
   248         CExifLittleEndian();
       
   249 
       
   250         /**
       
   251         * Destructor.
       
   252         */        
       
   253         virtual ~CExifLittleEndian();
       
   254 
       
   255     public: // Functions from base classes
       
   256 
       
   257         /**
       
   258         * From CExifEndianBase Gets the next 16-bit unsigned integer from the 
       
   259         * data.
       
   260         * @since 2.6 
       
   261         * @param aUint16 The 16-bit integer returned.
       
   262         * @return Error code.
       
   263         */
       
   264         TInt ReadUInt16( TUint16& aUint16 );
       
   265 
       
   266         /**
       
   267         * From CExifEndianBase Gets the next 32-bit unsigned integer from the 
       
   268         * data.
       
   269         * @since 2.6 
       
   270         * @param aUint32 The 32-bit integer returned.
       
   271         * @return Error code.
       
   272         */        
       
   273         TInt ReadUInt32( TUint32& aUint32 );
       
   274         
       
   275         /**
       
   276         * From CExifEndianBase Copies the next specified amount of data to the 
       
   277         * given descriptor.
       
   278         * @since 2.6 
       
   279         * @param aCount Number of words to copy
       
   280         * @param aWordSize Word size
       
   281         * @param aBuffer Pointer to the target descriptor.
       
   282         * @return void
       
   283         */
       
   284         TInt CopyBuffer( TUint32 aCount, TUint8 aWordSize, HBufC8*& aBuffer );
       
   285 
       
   286         /**
       
   287         * From CExifEndianBase Copies the specified amount of data located in 
       
   288         * the given offset to the given descriptor.
       
   289         * @since 2.6 
       
   290         * @param aOffset Offset for starting copying
       
   291         * @param aCount Number of words to copy
       
   292         * @param aWordSize Word size
       
   293         * @param aBuffer Pointer to the target descriptor.
       
   294         * @return void
       
   295         */
       
   296         TInt CopyBuffer( 
       
   297             TUint32 aOffset, 
       
   298             TUint32 aCount, 
       
   299             TUint8 aWordSize, 
       
   300             HBufC8*& aBuffer );
       
   301 
       
   302         /**
       
   303         * From CExifEndianBase Locates the offset of the next specified 16-bit 
       
   304         * unsigned integer 
       
   305         * @since 2.6 
       
   306         * @param aSearch Queried 16-bit integer
       
   307         * @param aOffset The offset of the found location.
       
   308         * @return Error code.
       
   309         */        
       
   310         TInt Locate16( TUint16 aSearch, TUint32& aOffset );
       
   311 
       
   312     private:
       
   313 
       
   314         /**
       
   315         * By default Symbian 2nd phase constructor is private.
       
   316         */
       
   317         void ConstructL( 
       
   318             TUint8* aDataStartPtr,
       
   319             TUint8* aExifStartPtr, 
       
   320             TUint8* aExifEndPtr, 
       
   321             TBool aIsExif );
       
   322 
       
   323     };
       
   324 
       
   325 
       
   326 /**
       
   327 *  Exif data parser class for Big endian format.
       
   328 *
       
   329 *  @lib ExifLib
       
   330 *  @since 2.6 
       
   331 */
       
   332 NONSHARABLE_CLASS( CExifBigEndian ): public CExifEndianBase
       
   333     {
       
   334     public:
       
   335 
       
   336         /**
       
   337         * Two-phased constructor.
       
   338         */
       
   339         static CExifBigEndian* NewL( 
       
   340             const TUint8* aDataStartPtr, 
       
   341             TUint8* aExifStartPtr, 
       
   342             TUint8* aExifEndPtr, 
       
   343             TBool aIsExif );
       
   344 
       
   345         /**
       
   346         * C++ default constructor.
       
   347         */
       
   348         CExifBigEndian();
       
   349 
       
   350         /**
       
   351         * Destructor.
       
   352         */        
       
   353         virtual ~CExifBigEndian();
       
   354 
       
   355     public: // Functions from base classes
       
   356 
       
   357         /**
       
   358         * From CExifEndianBase Gets the next 16-bit unsigned integer from the 
       
   359         * data.
       
   360         * @since 2.6 
       
   361         * @param aUint16 The 16-bit integer returned.
       
   362         * @return Error code.
       
   363         */        
       
   364         TInt ReadUInt16( TUint16& aUint16 );
       
   365         
       
   366         /**
       
   367         * From CExifEndianBase Gets the next 32-bit unsigned integer from the 
       
   368         * data.
       
   369         * @since 2.6 
       
   370         * @param aUint32 The 32-bit integer returned.
       
   371         * @return Error code.
       
   372         */        
       
   373         TInt ReadUInt32( TUint32& aUint32 );
       
   374         
       
   375         /**
       
   376         * From CExifEndianBase Copies the next specified amount of data to the 
       
   377         * given descriptor.
       
   378         * @since 2.6 
       
   379         * @param aCount Number of words to copy
       
   380         * @param aWordSize Word size
       
   381         * @param aBuffer Pointer to the target descriptor.
       
   382         * @return void
       
   383         */
       
   384         TInt CopyBuffer( TUint32 aCount, TUint8 aWordSize, HBufC8*& aBuffer );
       
   385 
       
   386         /**
       
   387         * From CExifEndianBase Copies the specified amount of data located in 
       
   388         * the given offset to the given descriptor.
       
   389         * @since 2.6 
       
   390         * @param aOffset Offset for starting copying
       
   391         * @param aCount Number of words to copy
       
   392         * @param aWordSize Word size
       
   393         * @param aBuffer Pointer to the target descriptor.
       
   394         * @return void
       
   395         */
       
   396         TInt CopyBuffer( 
       
   397             TUint32 aOffset, 
       
   398             TUint32 aCount, 
       
   399             TUint8 aWordSize, 
       
   400             HBufC8*& aBuffer );
       
   401 
       
   402         /**
       
   403         * From CExifEndianBase Locates the offset of the next specified 16-bit 
       
   404         * unsigned integer 
       
   405         * @since 2.6 
       
   406         * @param aSearch Queried 16-bit integer
       
   407         * @param aOffset The offset of the found location.
       
   408         * @return Error code.
       
   409         */        
       
   410         TInt Locate16( TUint16 aSearch, TUint32& aOffset );
       
   411     
       
   412     private:
       
   413     
       
   414         /**
       
   415         * By default Symbian 2nd phase constructor is private.
       
   416         */
       
   417         void ConstructL( 
       
   418             TUint8* aDataStartPtr, 
       
   419             TUint8* aExifStartPtr, 
       
   420             TUint8* aExifEndPtr, 
       
   421             TBool aIsExif );
       
   422     };
       
   423 
       
   424 #endif // EXIFENDIAN_H
       
   425 
       
   426 // End of File