phonesrv_plat/string_parser_api/inc/CPhoneGsmParserBase.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  It is base class for parsers.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHONEGSMPARSERBASE_H
       
    20 #define CPHONEGSMPARSERBASE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include    <e32base.h>
       
    24 
       
    25 // MACROS
       
    26 
       
    27 /**
       
    28 * It defines macro that can be used to create a single uid.
       
    29 * 
       
    30 * Parameters main and sub should be positive integers, range of
       
    31 * main is 0..255 and sub is 0..2^16-1. 
       
    32 *
       
    33 * Macro is equivalent to (main mod 256)*2**16 + sub.
       
    34 */
       
    35 #define PHONE_MAKE_UID( main, sub ) (TUint32)((((main) & 0xFF) << 16) + ((sub) & 0xFFFF))
       
    36 
       
    37 /**
       
    38 * Extracts main part from uid.
       
    39 *
       
    40 * Macro is equivalent to (main / 2**16) mod 256.
       
    41 */
       
    42 #define PHONE_EXTRACT_MAIN( uid ) (((uid) >> 16) & 0xFF)
       
    43 
       
    44 // CONSTANTS
       
    45 
       
    46 /**
       
    47 * ALL MAIN UIDS ARE LISTED HERE.
       
    48 *
       
    49 * Please, do not change unless you know what you are doing!
       
    50 */
       
    51 
       
    52 /**
       
    53 * Invalid string.
       
    54 */
       
    55 const TUint32 KPhoneGsmUidInvalid = 0;
       
    56 
       
    57 /**
       
    58 * Supplementary services.
       
    59 */
       
    60 const TUint32 KPhoneGsmUidSupplementaryService = 1;
       
    61 
       
    62 /**
       
    63 * Sim control procedure.
       
    64 */
       
    65 const TUint32 KPhoneGsmUidSimControlProcedure = 2;
       
    66 
       
    67 /**
       
    68 * Phone number
       
    69 */
       
    70 const TUint32 KPhoneGsmUidDialPhoneNumber = 3;
       
    71 
       
    72 /**
       
    73 * Misc GSM required strings, most notably USSD.
       
    74 */
       
    75 const TUint32 KPhoneGsmUidMisc = 4;
       
    76 
       
    77 /**
       
    78 * Supplementary service, during calls.
       
    79 */
       
    80 const TUint32 KPhoneGsmUidSupplementaryServiceDuringCall = 5;
       
    81 
       
    82 /**
       
    83 * Manufacturer specific codes.
       
    84 */
       
    85 const TUint32 KPhoneGsmUidManufacturer = 6;
       
    86 
       
    87 /**
       
    88 * PCN specific codes.
       
    89 */
       
    90 const TUint32 KPhoneGsmUidPcnProcedures = 7;
       
    91 
       
    92 /**
       
    93 * Emergency number
       
    94 */
       
    95 const TUint32 KPhoneGsmUidDialEmergencyNumber = 8;
       
    96 
       
    97 /**
       
    98 * Voip number
       
    99 */
       
   100 const TUint32 KPhoneUidDialVoipyNumber = 9;
       
   101 
       
   102 /**
       
   103 * ALL MISC UIDS:
       
   104 */
       
   105 const TUint32 KPhoneUidUnstructuredService = 
       
   106     PHONE_MAKE_UID( KPhoneGsmUidMisc, 0 );
       
   107 
       
   108 // FORWARD DECLARATIONS
       
   109 class CPhoneGsmParserResult;
       
   110 class CPhoneGsmOptionContainerBase;
       
   111 
       
   112 // CLASS DECLARATION
       
   113 
       
   114 /**
       
   115 * It is base class for parsers.
       
   116 *
       
   117 * @since 1.0
       
   118 * @lib phoneparser.lib
       
   119 */
       
   120 class CPhoneGsmParserBase 
       
   121     : public CBase
       
   122     {
       
   123     public: // New functions
       
   124         
       
   125         /**
       
   126         * Parses string.
       
   127         *
       
   128         * String must not contain other characters than from set
       
   129         * { 0..9, *, #, +, p, w }. If method leaves, then result
       
   130         * may contain something that is not valid.
       
   131         *
       
   132         * @param aString string to be parsed.
       
   133         * @param aResult It will contain result.
       
   134         * @param aOptions It contains all options related to parsing.
       
   135         * @return It returns boolean value indicating success of parsing.
       
   136         */
       
   137         virtual TBool ParseL( 
       
   138             const TDesC& aString,
       
   139             CPhoneGsmParserResult& aResult,
       
   140             CPhoneGsmOptionContainerBase& aOptions ) = 0;
       
   141 
       
   142         // SOME COMMON STATIC FUNCTIONS
       
   143 
       
   144         /**
       
   145         * Checks if string is prefix of another.
       
   146         *
       
   147         * @param aString original string.
       
   148         * @param aPrefix possibly prefix of aString.
       
   149         * @return ETrue iff aPrefix is prefix of aString.
       
   150         */
       
   151         static TBool IsPrefixOf( 
       
   152             const TDesC& aString, 
       
   153             const TDesC& aPrefix );
       
   154         
       
   155         /**
       
   156         * Checks if string is postfix of another.
       
   157         *
       
   158         * @param aString original string.
       
   159         * @param aPrefix possibly postfix of aString.
       
   160         * @return ETrue iff aPostfix is postfix of aString.
       
   161         */
       
   162         static TBool IsPostfixOf(
       
   163             const TDesC& aString,
       
   164             const TDesC& aPostfix );
       
   165 
       
   166         /**
       
   167         * Extracts sequence of digits.
       
   168         *
       
   169         * @param aString input.
       
   170         * @return sequence of digits, prefix of aString.
       
   171         */
       
   172         static TPtrC ExtractNumber( 
       
   173             const TDesC& aString );
       
   174 
       
   175     };
       
   176 
       
   177 #endif      // CPHONEGSMPARSERBASE_H
       
   178             
       
   179 // End of File