1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Software License Agreement (BSD License)
5 * Copyright (c) 2006, ScalingWeb.com
8 * Redistribution and use of this software in source and binary forms, with or without modification, are
9 * permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above
12 * copyright notice, this list of conditions and the
13 * following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the
17 * following disclaimer in the documentation and/or other
18 * materials provided with the distribution.
20 * * Neither the name of ScalingWeb.com nor the names of its
21 * contributors may be used to endorse or promote products
22 * derived from this software without specific prior
23 * written permission of ScalingWeb.com.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MORKPARSER_HXX
36 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MORKPARSER_HXX
38 #include <sal/types.h>
49 typedef std::map
< int, std::string
> MorkDict
;
50 typedef std::map
< int, int > MorkCells
; // ColumnId : ValueId
51 typedef std::map
< int, MorkCells
> MorkRowMap
; // Row id
52 typedef std::map
< int, MorkRowMap
> RowScopeMap
; // Row scope
53 typedef std::map
< int, RowScopeMap
> MorkTableMap
; // Table id
54 typedef std::map
< int, MorkTableMap
> TableScopeMap
; // Table Scope
81 class LO_DLLPUBLIC_MORK MorkParser
85 MorkParser( int defaultScope
= 0x80 );
87 /// Open and parse mork file
89 bool open( const std::string
&path
);
91 /// Return error status
95 /// Returns all tables of specified scope
97 MorkTableMap
*getTables( int tableScope
);
99 /// Rerturns all rows under specified scope
101 MorkRowMap
*getRows( int rowScope
, RowScopeMap
*table
);
103 /// Return value of specified value oid
105 std::string
&getValue( int oid
);
107 /// Return value of specified column oid
109 std::string
&getColumn( int oid
);
111 void retrieveLists(std::set
<std::string
>& lists
);
112 void getRecordKeysForListTable(std::string
& listName
, std::set
<int>& records
);
116 protected: // Members
120 bool isWhiteSpace( char c
);
123 void parseScopeId( const std::string
&TextId
, int *Id
, int *Scope
);
124 void setCurrentRow( int TableScope
, int TableId
, int RowScope
, int RowId
);
132 bool parseMeta( char c
);
133 bool parseRow( int TableId
, int TableScope
);
138 // Columns in mork means value names
142 // All mork file data
144 MorkCells
*currentCells_
;
146 // Error status of last operation
150 std::string morkData_
;
155 int defaultListScope_
;
158 // Indicates intity is being parsed
159 enum { NPColumns
, NPValues
, NPRows
} nowParsing_
;
162 MorkParser(const MorkParser
&);
163 MorkParser
&operator=(const MorkParser
&);
167 #endif // __MorkParser_h__
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */