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>
39 #include <rtl/ustring.hxx>
50 typedef std::map
< int, std::string
> MorkDict
;
51 typedef std::map
< int, int > MorkCells
; // ColumnId : ValueId
52 struct MorkRowMap
{ typedef std::map
< int, MorkCells
> Map
; Map map
; }; // Row id
53 struct RowScopeMap
{ typedef std::map
< int, MorkRowMap
> Map
; Map map
; }; // Row scope
54 struct MorkTableMap
{ typedef std::map
< int, RowScopeMap
> Map
; Map map
; }; // Table id
55 struct TableScopeMap
{ typedef std::map
< int, MorkTableMap
> Map
; Map map
; }; // Table Scope
68 class LO_DLLPUBLIC_MORK MorkParser
72 explicit MorkParser();
74 /// Open and parse mork file
76 bool open( const std::string
&path
);
78 /// Returns all tables of specified scope
80 MorkTableMap
*getTables( int tableScope
);
82 /// Returns all rows under specified scope
84 static MorkRowMap
*getRows( int rowScope
, RowScopeMap
*table
);
86 /// Return value of specified value oid
88 std::string
&getValue( int oid
);
90 /// Return value of specified column oid
92 std::string
&getColumn( int oid
);
94 void retrieveLists(std::set
<std::string
>& lists
);
95 void getRecordKeysForListTable(std::string
& listName
, std::set
<int>& records
);
100 std::vector
<OUString
> lists_
;
102 protected: // Members
106 static bool isWhiteSpace( char c
);
109 static void parseScopeId( const std::string
&TextId
, int *Id
, int *Scope
);
110 void setCurrentRow( int TableScope
, int TableId
, int RowScope
, int RowId
);
118 bool parseMeta( char c
);
119 bool parseRow( int TableId
, int TableScope
);
124 // Columns in mork means value names
128 // All mork file data
130 MorkCells
*currentCells_
;
132 // Error status of last operation
136 std::string morkData_
;
143 // Indicates entity is being parsed
144 enum { NPColumns
, NPValues
, NPRows
} nowParsing_
;
147 MorkParser(const MorkParser
&) = delete;
148 MorkParser
&operator=(const MorkParser
&) = delete;
152 #endif // __MorkParser_h__
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */