homescreenpluginsrv/inc/hspsdomstringpool.h
branchRCL_3
changeset 11 bd874ee5e5e2
parent 0 79c6a41cd166
child 12 502e5d91ad42
equal deleted inserted replaced
8:d0529222e3f0 11:bd874ee5e5e2
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005,2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  Flyweigth pattern implementation for dom strings.
    14 * Description:  Flyweigth pattern implementation for dom strings.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 #ifndef HSPS_DOM_STRING_POOL_H
    19 
    19 #define HSPS_DOM_STRING_POOL_H
    20 #ifndef hsps_DOM_STRING_POOL_H
       
    21 #define hsps_DOM_STRING_POOL_H
       
    22 
    20 
    23 //  INCLUDES
    21 //  INCLUDES
    24 #include <e32base.h>
    22 #include <e32base.h>
    25 #include <s32strm.h>
    23 #include <s32strm.h>
       
    24 #include "hspsdomstringpooloptimizer.h"
    26 
    25 
    27 // CLASS DECLARATION
    26 // CLASS DECLARATION
    28 
    27 
    29 /**
    28 /**
    30  * Class utilize flyweight pattern. Dom strings are stored once 
    29 *  @ingroup group_hspsdom
    31  * and referred with index. Class can be serialized.
    30 *  Class utilize flyweight pattern. Dom strings are stored once 
    32  *
    31 *  and referred with index. Class can be serialized.
    33  * @lib hspsdomdocument.lib
    32 *
    34  * @since S60 5.0
    33 *  @lib xndomdocument.lib
    35  * @ingroup group_hspsdom
    34 *  @since Series 60 3.1
    36  */
    35 */
    37 class ChspsDomStringPool : public CBase
    36 class ChspsDomStringPool : public CBase
    38     {
    37     {
    39     public:  // Constructors and destructor
    38     public:  // Constructors and destructor
    40         
    39         
    41         /**
    40         /**
    42         * Two-phased constructor.
    41         * Two-phased constructor.
    43         * 
    42         * 
    44         * @since S60 5.0
    43         * @param    aAllowDuplicates        ETrue if duplicates are to be allowed.
       
    44         *                                   Supported for legacy reasons. 
    45         */
    45         */
    46         static ChspsDomStringPool* NewL();
    46         static ChspsDomStringPool* NewL( const TBool aAllowDuplicates = EFalse );
    47         
    47 
    48         /**
    48         /**
    49         * Two-phased stream constructor.
    49         * Two-phased stream constructor.
    50         * 
    50         * 
    51         * @since S60 5.0
    51         * @param    aStream                 Stream where string pool is internalized.
    52         * @param aStream Source stream.
    52         * @param    aAllowDuplicates        ETrue if duplicates are to be allowed.
    53         */        
    53         *                                   Supported for legacy reasons. 
    54         static ChspsDomStringPool* NewL( RReadStream& aStream );
    54         */
       
    55         static ChspsDomStringPool* NewL( RReadStream& aStream,
       
    56                 const TBool aAllowDuplicates = EFalse );
    55         
    57         
    56         /**
    58         /**
    57         * Destructor.
    59         * Destructor.
    58         */
    60         */
    59         virtual ~ChspsDomStringPool();
    61         virtual ~ChspsDomStringPool();
    60 
    62         
    61    public: 
    63    public: 
    62         /**
    64         /**
    63         * Make a copy from original StringPool.
    65         * Make a copy from original StringPool.
    64         * @since Series 60 3.1
    66         * @since Series 60 3.1
    65         * @return Pointer to a string pool. Ownership is transferred to a caller.
    67         * @return Pointer to a string pool. Ownership is transferred to a caller.
    66         */
    68         */
    67         ChspsDomStringPool* CloneL(); 
    69         ChspsDomStringPool* CloneL(); 
       
    70         
    68    public: //Adding
    71    public: //Adding
    69         
    72         
    70         /**
    73         /**
    71         * Set dom string into string pool.
    74         * Set dom string into string pool.
    72         * 
    75         * 
    73         * @since S60 5.0
       
    74         * @param aString String to add to string pool
    76         * @param aString String to add to string pool
    75         * @return Index (reference) to string pool
    77         * @return Index (reference) to string pool
    76         */
    78         */
    77         IMPORT_C TInt AddStringL( const TDesC8& aString ); 
    79         IMPORT_C TInt AddStringL( const TDesC8& aString ); 
    78    
    80 
       
    81         /**
       
    82         * Set dom string into string pool.
       
    83         * 
       
    84         * @param aString String to add to string pool. OWNERSHIP TRANSFERRED!
       
    85         * @return Index (reference) to string pool
       
    86         */
       
    87         TInt AddStringL( HBufC8* aString );         
       
    88 
       
    89         /**
       
    90         * Add all string from another string pool.
       
    91         * 
       
    92         * @param aStringPool    Source string pool.
       
    93         */
       
    94         void AddAllL( ChspsDomStringPool& aStringPool );        
       
    95         
    79    public: //Accessing     
    96    public: //Accessing     
    80         /**
    97         /**
    81         * Get pointer to the node element name.
    98         * Get reference to string.
    82         * @param aStringRef StringRef.
    99         * 
       
   100         * @param aMap Map object which has index to name string
    83         * @return Pointer to the name
   101         * @return Pointer to the name
    84         */
   102         */
    85         const TDesC8& String( const TInt aStringRef ); 
   103         const TDesC8& String( const TInt aStringRef ); 
    86         
   104         
    87         /**
   105         /**
    88         * Get object's data size in bytes.
   106         * Get object's data size in bytes.
       
   107         * 
    89         * @return Data size in bytes
   108         * @return Data size in bytes
    90         */
   109         */
    91         TInt Size() const;
   110         TInt Size() const;
       
   111 
       
   112         /**
       
   113         * Get amount of strings.
       
   114         */
       
   115         TInt Count() const;        
    92         
   116         
    93         /**
   117         /**
    94         * Externalize object
   118         * Externalize object.
       
   119         * 
    95         * @param aStream Output stream
   120         * @param aStream Output stream
    96         */
   121         */
    97         void ExternalizeL( RWriteStream& aStream ) const;
   122         void ExternalizeL( RWriteStream& aStream ) const;
    98        
   123        
    99         /**
   124         /**
   100         * Internalize object
   125         * Internalize object.
       
   126         * 
   101         * @param aStream Input stream
   127         * @param aStream Input stream
   102         */
   128         */
   103         void InternalizeL( RReadStream& aStream );          
   129         void InternalizeL( RReadStream& aStream );          
   104         
   130         
   105    private:
   131    private:
   106 
   132 
   107         /**
   133         /**
   108         * C++ default constructor.
   134         * C++ default constructor.
       
   135         * 
       
   136         * @param    aAllowDuplicates        ETrue if duplicates are to be allowed.
       
   137         *                                   Supported for legacy reasons.
   109         */
   138         */
   110         ChspsDomStringPool();
   139         ChspsDomStringPool( const TBool aAllowDuplicates );
   111 
   140 
   112         /**
   141         /**
   113         * By default Symbian 2nd phase constructor is private.
   142         * By default Symbian 2nd phase constructor is private. 
   114         */
   143         */
   115         void ConstructL();
   144         void ConstructL();    
   116      
   145         
   117     private:    
   146         /**
       
   147         * Add string to string pool and to optimizer also.
       
   148         * 
       
   149         * @param aNewString     String to be added. OWNERSHIP TRANSFERRED.
       
   150         * @param TInt           Index to added string.
       
   151         */
       
   152         TInt DoAddStringL( HBufC8* aNewString ) ;
       
   153         
       
   154     private:            
   118         //String pool
   155         //String pool
   119         RPointerArray<HBufC8>       iStringPool;
   156         RPointerArray<HBufC8>       iStringPool;
   120        
       
   121         
   157         
       
   158         /**
       
   159          * String pool optimizer.
       
   160          */
       
   161         ThspsDomStringPoolOptimizer iStringPoolOptimizer;
       
   162         
       
   163         /**
       
   164          * ETrue if string pool can contain duplicate entries. Must
       
   165          * be supported for legacy reasons while loading xuikon odts.
       
   166          */
       
   167         TBool iAllowDuplicates;
   122     };
   168     };
   123 
   169 
   124 #endif      // hsps_DOM_STRING_POOL_H  
   170 #endif      // HSPS_DOM_STRING_POOL_H  
   125             
   171             
   126 // End of File
   172 // End of File