fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / connectivity / source / drivers / mork / MorkParser.hxx
blob789e569eb191e113e64a592e8061863b72fa08c0
1 /*
2 * Software License Agreement (BSD License)
4 * Copyright (c) 2006, ScalingWeb.com
5 * All rights reserved.
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>
39 #include <string>
40 #include <map>
41 #include <set>
42 #include <vector>
44 #include "dllapi.h"
46 // Types
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
55 // Error codes
56 enum MorkErrors
58 NoError = 0,
59 FailedToOpen,
60 UnsupportedVersion,
61 DefectedFormat
64 // Mork term types
65 enum MorkTerm
67 NoneTerm = 0,
68 DictTerm,
69 GroupTerm,
70 TableTerm,
71 RowTerm,
72 CellTerm,
73 CommentTerm,
74 LiteralTerm
78 /// Class MorkParser
80 class LO_DLLPUBLIC_MORK MorkParser
82 public:
84 MorkParser( int defaultScope = 0x80 );
86 ///
87 /// Open and parse mork file
89 bool open( const std::string &path );
91 ///
92 /// Return error status
94 MorkErrors error();
96 ///
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);
119 void dump();
121 protected: // Members
123 void initVars();
125 bool isWhiteSpace( char c );
126 char nextChar();
128 void parseScopeId( const std::string &TextId, int *Id, int *Scope );
129 void setCurrentRow( int TableScope, int TableId, int RowScope, int RowId );
131 // Parse methods
132 bool parse();
133 bool parseDict();
134 bool parseComment();
135 bool parseCell();
136 bool parseTable();
137 bool parseMeta( char c );
138 bool parseRow( int TableId, int TableScope );
139 bool parseGroup();
141 protected: // Data
143 // Columns in mork means value names
144 MorkDict columns_;
145 MorkDict values_;
147 // All mork file data
148 TableScopeMap mork_;
149 MorkCells *currentCells_;
151 // Error status of last operation
152 MorkErrors error_;
154 // All Mork data
155 std::string morkData_;
157 unsigned morkPos_;
158 int nextAddValueId_;
159 int defaultScope_;
160 int defaultListScope_;
161 int defaultTableId_;
163 // Indicates intity is being parsed
164 enum { NPColumns, NPValues, NPRows } nowParsing_;
166 private:
167 MorkParser(const MorkParser &);
168 MorkParser &operator=(const MorkParser &);
172 #endif // __MorkParser_h__