2 * Software License Agreement (BSD License)
4 * Copyright (c) 2006, ScalingWeb.com
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:
10 * * Redistributions of source code must retain the above
11 * copyright notice, this list of conditions and the
12 * following disclaimer.
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.
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.
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.
34 #ifndef _MORK_PARSER_HXX_
35 #define _MORK_PARSER_HXX_
37 #include <sal/types.h>
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
80 class LO_DLLPUBLIC_MORK MorkParser
84 MorkParser( int defaultScope
= 0x80 );
87 /// Open and parse mork file
89 bool open( const std::string
&path
);
92 /// Return error status
97 /// Returns all tables of specified scope
99 MorkTableMap
*getTables( int tableScope
);
102 /// Rerturns all rows under specified scope
104 MorkRowMap
*getRows( int rowScope
, RowScopeMap
*table
);
107 /// Return value of specified value oid
109 std::string
&getValue( int oid
);
112 /// Return value of specified column oid
114 std::string
&getColumn( int oid
);
116 void retrieveLists(std::set
<std::string
>& lists
);
117 void getRecordKeysForListTable(std::string
& listName
, std::set
<int>& records
);
121 protected: // Members
125 bool isWhiteSpace( char c
);
128 void parseScopeId( const std::string
&TextId
, int *Id
, int *Scope
);
129 void setCurrentRow( int TableScope
, int TableId
, int RowScope
, int RowId
);
137 bool parseMeta( char c
);
138 bool parseRow( int TableId
, int TableScope
);
143 // Columns in mork means value names
147 // All mork file data
149 MorkCells
*currentCells_
;
151 // Error status of last operation
155 std::string morkData_
;
160 int defaultListScope_
;
163 // Indicates intity is being parsed
164 enum { NPColumns
, NPValues
, NPRows
} nowParsing_
;
167 MorkParser(const MorkParser
&);
168 MorkParser
&operator=(const MorkParser
&);
172 #endif // __MorkParser_h__