LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MorkParser.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Software License Agreement (BSD License)
       3             :  *
       4             :  * Copyright (c) 2006, ScalingWeb.com
       5             :  * All rights reserved.
       6             :  *
       7             :  * Redistribution and use of this software in source and binary forms, with or without modification, are
       8             :  * permitted provided that the following conditions are met:
       9             :  *
      10             :  * * Redistributions of source code must retain the above
      11             :  *   copyright notice, this list of conditions and the
      12             :  *   following disclaimer.
      13             :  *
      14             :  * * Redistributions in binary form must reproduce the above
      15             :  *   copyright notice, this list of conditions and the
      16             :  *   following disclaimer in the documentation and/or other
      17             :  *   materials provided with the distribution.
      18             :  *
      19             :  * * Neither the name of ScalingWeb.com nor the names of its
      20             :  *   contributors may be used to endorse or promote products
      21             :  *   derived from this software without specific prior
      22             :  *   written permission of ScalingWeb.com.
      23             : 
      24             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
      25             :  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
      26             :  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
      27             :  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      28             :  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      29             :  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
      30             :  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
      31             :  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      32             :  */
      33             : 
      34             : #ifndef _MORK_PARSER_HXX_
      35             : #define _MORK_PARSER_HXX_
      36             : 
      37             : #include <sal/types.h>
      38             : 
      39             : #include <string>
      40             : #include <map>
      41             : #include <set>
      42             : #include <vector>
      43             : 
      44             : #include "dllapi.h"
      45             : 
      46             : // Types
      47             : 
      48             : typedef std::map< int, std::string > MorkDict;
      49             : typedef std::map< int, int > MorkCells;               // ColumnId : ValueId
      50             : typedef std::map< int, MorkCells > MorkRowMap;        // Row id
      51             : typedef std::map< int, MorkRowMap > RowScopeMap;      // Row scope
      52             : typedef std::map< int, RowScopeMap > MorkTableMap;    // Table id
      53             : typedef std::map< int, MorkTableMap > TableScopeMap;  // Table Scope
      54             : 
      55             : // Error codes
      56             : enum MorkErrors
      57             : {
      58             :     NoError = 0,
      59             :     FailedToOpen,
      60             :     UnsupportedVersion,
      61             :     DefectedFormat
      62             : };
      63             : 
      64             : // Mork term types
      65             : enum MorkTerm
      66             : {
      67             :     NoneTerm = 0,
      68             :     DictTerm,
      69             :     GroupTerm,
      70             :     TableTerm,
      71             :     RowTerm,
      72             :     CellTerm,
      73             :     CommentTerm,
      74             :     LiteralTerm
      75             : };
      76             : 
      77             : 
      78             : /// Class MorkParser
      79             : 
      80           0 : class LO_DLLPUBLIC_MORK MorkParser
      81             : {
      82             : public:
      83             : 
      84             :     MorkParser( int defaultScope = 0x80 );
      85             : 
      86             :     /// Open and parse mork file
      87             : 
      88             :     bool open( const std::string &path );
      89             : 
      90             :     /// Return error status
      91             : 
      92             :     MorkErrors error();
      93             : 
      94             :     /// Returns all tables of specified scope
      95             : 
      96             :     MorkTableMap *getTables( int tableScope );
      97             : 
      98             :     /// Rerturns all rows under specified scope
      99             : 
     100             :     MorkRowMap *getRows( int rowScope, RowScopeMap *table );
     101             : 
     102             :     /// Return value of specified value oid
     103             : 
     104             :     std::string &getValue( int oid );
     105             : 
     106             :     /// Return value of specified column oid
     107             : 
     108             :     std::string &getColumn( int oid );
     109             : 
     110             :     void retrieveLists(std::set<std::string>& lists);
     111             :     void getRecordKeysForListTable(std::string& listName, std::set<int>& records);
     112             : 
     113             :     void dump();
     114             : 
     115             : protected: // Members
     116             : 
     117             :     void initVars();
     118             : 
     119             :     bool isWhiteSpace( char c );
     120             :     char nextChar();
     121             : 
     122             :     void parseScopeId( const std::string &TextId, int *Id, int *Scope );
     123             :     void setCurrentRow( int TableScope, int TableId, int RowScope, int RowId );
     124             : 
     125             :     // Parse methods
     126             :     bool parse();
     127             :     bool parseDict();
     128             :     bool parseComment();
     129             :     bool parseCell();
     130             :     bool parseTable();
     131             :     bool parseMeta( char c );
     132             :     bool parseRow( int TableId, int TableScope );
     133             :     bool parseGroup();
     134             : 
     135             : protected: // Data
     136             : 
     137             :     // Columns in mork means value names
     138             :     MorkDict columns_;
     139             :     MorkDict values_;
     140             : 
     141             :     // All mork file data
     142             :     TableScopeMap mork_;
     143             :     MorkCells *currentCells_;
     144             : 
     145             :     // Error status of last operation
     146             :     MorkErrors error_;
     147             : 
     148             :     // All Mork data
     149             :     std::string morkData_;
     150             : 
     151             :     unsigned morkPos_;
     152             :     int nextAddValueId_;
     153             :     int defaultScope_;
     154             :     int defaultListScope_;
     155             :     int defaultTableId_;
     156             : 
     157             :     // Indicates intity is being parsed
     158             :     enum { NPColumns, NPValues, NPRows } nowParsing_;
     159             : 
     160             : private:
     161             :     MorkParser(const MorkParser &);
     162             :     MorkParser &operator=(const MorkParser &);
     163             : 
     164             : };
     165             : 
     166             : #endif // __MorkParser_h__
     167             : 

Generated by: LCOV version 1.10