Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / soltools / inc / gi_parse.hxx
bloba807ed6e2cc06062f22113aaad55ff8012bd7ea5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef SOLTOOLS_GI_PARSE_HXX
29 #define SOLTOOLS_GI_PARSE_HXX
31 #include "simstr.hxx"
32 #include "gilacces.hxx"
33 #include <fstream>
35 class GenericInfoList_Builder;
36 class GenericInfoList_Browser;
38 /** Reads generic information files into a simple structure in memory.
40 Information files used by this parser have the following format:
42 key [value]
44 key [value]
45 key [value]
47 key [value]
48 ...
49 ...
52 key [value]
53 ...
54 ...
59 class GenericInfo_Parser : public GenericInfoParseTypes
61 public:
62 typedef unsigned long UINT32;
63 typedef short INT16;
65 GenericInfo_Parser();
66 ~GenericInfo_Parser();
68 /** reads a information file and stores the data in a
69 List_GenericInfo
71 bool LoadList(
72 GenericInfoList_Builder &
73 o_rResult,
74 const Simstr & i_sSourceFileName );
76 /** save the InformationList to rSourceFile
77 returns false on error
79 bool SaveList(
80 const Simstr & i_rOutputFile,
81 GenericInfoList_Browser &
82 io_rListBrowser );
84 E_Error GetLastError(
85 UINT32 * o_pErrorLine = 0 ) const;
87 private:
88 enum E_LineType
90 lt_empty = 0,
91 lt_key,
92 lt_open_list,
93 lt_close_list,
94 lt_comment
97 void SetError(
98 E_Error i_eError );
99 void ResetState(
100 GenericInfoList_Builder &
101 io_rResult );
102 void ResetState(
103 GenericInfoList_Browser &
104 io_rSrc );
106 void ReadLine();
107 bool InterpretLine();
108 E_LineType ClassifyLine();
110 void ReadKey();
111 void PushLevel_Read(); /// When list is opened by '{':
112 void PopLevel_Read(); /// When list is closed by '}':
113 void AddCurLine2CurComment();
115 void WriteList(
116 std::ostream & o_rFile );
118 void PushLevel_Write(); /// When SubList is pushed in pResource
119 void PopLevel_Write(); /// When SubList is popped in pResource
121 void WriteComment(
122 std::ostream & o_rFile,
123 const char * i_sStr );
124 void WriteKey(
125 std::ostream & o_rFile,
126 const char * i_sStr );
127 void WriteValue(
128 std::ostream & o_rFile,
129 const char * i_sStr );
130 void WriteIndentation(
131 std::ostream & o_rFile );
133 // DATA
134 const char * sCurParsePosition;
136 UINT32 nCurLine;
137 INT16 nLevel;
138 bool bGoon;
140 Simstr sCurComment;
142 E_Error eErrorCode;
143 UINT32 nErrorLine;
145 GenericInfoList_Builder *
146 pResult;
147 GenericInfoList_Browser *
148 pResource;
150 char * dpBuffer;
151 char * sFilePtr;
155 inline GenericInfo_Parser::E_Error
156 GenericInfo_Parser::GetLastError( UINT32 * o_pErrorLine ) const
158 if ( o_pErrorLine != 0 )
159 *o_pErrorLine = nErrorLine;
160 return eErrorCode;
164 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */