browserutilities/favouritesengine/ClientServer/utilinc/BookmarkFileImporter.h
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2003 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 the License "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: 
       
    15 *      Declaration of RUnicodeFile.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef BOOKMARK_FILE_IMPORTER_H
       
    22 #define BOOKMARK_FILE_IMPORTER_H
       
    23 
       
    24 // INCLUDE FILES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <f32file.h>
       
    28 #include <FavouritesDb.h>
       
    29 #include "UnicodeFile.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 class CFavouritesItem;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 * Import bookmark data from unicode text file (comma-separated list).
       
    39 */
       
    40 class CBookmarkFileImporter: public CBase
       
    41     {
       
    42     public:     // Constructors and destructor
       
    43 
       
    44         /**
       
    45         * Two-phased constructor. Leaves on failure.
       
    46         * @return The constructed importer.
       
    47         */
       
    48         static CBookmarkFileImporter* NewL();
       
    49 
       
    50         /**
       
    51         * Destructor.
       
    52         */
       
    53         virtual ~CBookmarkFileImporter();
       
    54 
       
    55     public:     // New methods
       
    56 
       
    57         /**
       
    58         * Import bookmarks from Unicode file (comma-separated list).
       
    59         * @param aFileName File Name.
       
    60         */
       
    61         void ImportL( const TDesC& aFileName );
       
    62 
       
    63     protected:  // Constructors and destructor
       
    64 
       
    65         /**
       
    66         * Constructor.
       
    67         */
       
    68         CBookmarkFileImporter();
       
    69 
       
    70         /**
       
    71         * Second phase constructor. Leaves on failure.
       
    72         */
       
    73         void ConstructL();
       
    74 
       
    75     private:    // New methods
       
    76 
       
    77         /**
       
    78         * Get next character and store it in iCurCh.
       
    79         */
       
    80         inline void GetCharL();
       
    81 
       
    82         /**
       
    83         * Process next line.
       
    84         * @return ETrue if more lines to go, EFalse on EOF.
       
    85         */
       
    86         TBool NextLineL();
       
    87 
       
    88         /**
       
    89         * Parse next token. Next token spans from current character up to (but
       
    90         * excluding) to the next stop character.
       
    91         * @param aStopCharSet Stop characters (terminate the token).
       
    92         * @return Pointer to token. This may be empty string. Note that the
       
    93         * returned pointer is valid until next call (consecutive calls reuse
       
    94         * the same buffer).
       
    95         */
       
    96         TPtrC NextTokenL( const TDesC& aStopCharSet );
       
    97 
       
    98         /**
       
    99         * Parse next token, which expected to be an integer.
       
   100         * @param aStopCharSet Stop characters (terminate the token).
       
   101         * @return Numeric value of token (0 for empty token).
       
   102         */
       
   103         TInt NextIntTokenL( const TDesC& aStopCharSet );
       
   104 
       
   105         /**
       
   106         * Parse next token, which expected to be a hexadecimal number.
       
   107         * @param aStopCharSet Stop characters (terminate the token).
       
   108         * @return Numeric value of token (0 for empty token).
       
   109         */
       
   110         TInt32 NextHexTokenL( const TDesC& aStopCharSet );
       
   111 
       
   112         /**
       
   113         * @param aStopCharSet Stop characters (terminate the token).
       
   114         * @param aStopChar Stop character.
       
   115         */
       
   116         void SkipL( const TDesC& aStopCharSet );
       
   117 
       
   118         /**
       
   119         * Parse comma separated list of bookmark values; create and add a
       
   120         * bookmark to the bookmark database.
       
   121         */
       
   122         void AttrsL();
       
   123 
       
   124         /**
       
   125         * Lookup uid of folder by name.
       
   126         * @param aName Name of folder to be found.
       
   127         * @return Uid of folder with name aName.
       
   128         */
       
   129         TInt FolderByNameL( const TDesC& aName );
       
   130 
       
   131     private:    // data
       
   132 
       
   133         RFavouritesSession iSess;   ///< Favourites Engine session.
       
   134         RFavouritesDb iDb;          ///< Favourites database. Owned.
       
   135         CFavouritesItem* iItem;     ///< Favourites item. Owned.
       
   136         RFs iFs;                    ///< File Server session. Owned.
       
   137         RUnicodeFile iFile;         ///< Input file. Owned.
       
   138         TUint iCurCh;               ///< Current (lookahead) character.
       
   139         TText16* iBuf;              ///< Token buffer.
       
   140         TText16* iNextCh;           ///< Next character is stored here.
       
   141         TText16* iMaxCh;            ///< Points past the buffer.
       
   142     };
       
   143 
       
   144 #endif
       
   145             
       
   146 // End of File