datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/inc/Nmea/BTGPSNmeaParser.h
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef BTGPSNMEAPARSER_H
       
    22 #define BTGPSNMEAPARSER_H
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <delimitedparser8.h>
       
    28 
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // DATA TYPES
       
    35 
       
    36 // FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  NMEA sentence parser. This class detects the validity of NMEA sentence. It provides
       
    44 *  functions to get different field value and field data.
       
    45 *  
       
    46 */
       
    47 class TBTGPSNmeaParser: public TDelimitedParserBase8
       
    48     {
       
    49     public: 
       
    50 
       
    51         /**
       
    52         * Construction.
       
    53         */
       
    54         TBTGPSNmeaParser();
       
    55 
       
    56         /**
       
    57         * Set NMEA sentence to parser. This function will check sentence validity.
       
    58 		* @param aNmea Reference to nmea sentences.
       
    59         */
       
    60         void SetNmeaSentence(const TDesC8& aNmea);
       
    61         
       
    62         /**
       
    63         * Get NMEA Sentence
       
    64         */
       
    65         const TDesC8& NmeaSentence() const;
       
    66 
       
    67         /**
       
    68         * Check if the NMEA sentece is valid
       
    69 		* @return ETrue if the sentence is a valid NMEA sentence.
       
    70         */
       
    71         TBool IsValid() const;
       
    72 
       
    73         /**
       
    74         * Get NMEA message Id
       
    75 		* @return The NMEA sentence message id.
       
    76         */
       
    77         TInt MessageId() const;
       
    78 
       
    79         /**
       
    80         * Get the field block
       
    81 		* @param aFieldId Field id
       
    82 		* @param aField On return contains the field string.
       
    83         * @return KErrNone if the field if found. Otherwise system
       
    84         *                  wide error code
       
    85         */
       
    86         TInt GetFieldBlock(TInt aFieldId, TPtrC8& aField) const;
       
    87 
       
    88         /**
       
    89         * Check if filed is null field
       
    90 		* @param aFieldId Field id.
       
    91 		* @return ETrue if the field is NULL field.
       
    92         */
       
    93         TBool IsNullField(TInt aFieldId) const;
       
    94         
       
    95         /**
       
    96         * Get field data.
       
    97 		* @param aFieldId Field id
       
    98 		* @param aData On return contain the field value
       
    99 		* @return KErrNone if the field is found and contain valid information, 
       
   100 		*         otherwise system wide error code.
       
   101         */
       
   102         template <class T> 
       
   103         TInt GetFieldData(TInt aFieldId, T& aData) const;
       
   104 
       
   105         /**
       
   106         * Get next field data. This is iteration function that will get all field
       
   107 		* data
       
   108 		* @param aData On return contains next valid field value.
       
   109 		* @return KErrNone if next field data is retrieved. KErrNotFound if end of 
       
   110 		*         NMEA sentence is reached.
       
   111         */
       
   112         template <class T>
       
   113         TInt NextFieldData(T& aData) const;
       
   114 
       
   115     private:
       
   116         /**
       
   117         * Getmessage id
       
   118         */
       
   119         void GetMessageId();
       
   120         
       
   121         /**
       
   122         * Check validity of NMEA sentence
       
   123         */
       
   124         TBool CheckValidity() const;
       
   125 
       
   126         /**
       
   127         * Remove '$', Checksum delimiter and check sum field
       
   128         */
       
   129         const TPtrC8 TrimSentence() const;
       
   130 
       
   131         /**
       
   132         * Verify checksum
       
   133         */
       
   134         TBool VerifyChecksum(const TDesC8& aSentence) const;
       
   135 
       
   136         /**
       
   137         * Convert char to nibble
       
   138         */
       
   139         TUint8 CharToNibble(const TUint8 aChar) const;
       
   140 
       
   141 
       
   142     private:
       
   143         //NMEA sentence
       
   144         TPtrC8 iNmea;
       
   145 
       
   146         //Message id. //ENmeaNull means message not valid
       
   147         TInt iId;
       
   148 
       
   149     };
       
   150 #endif
       
   151 // End of File
       
   152