1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: st_gilrw.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_soltools.hxx"
35 #include <st_gilrw.hxx>
37 #include <gen_info.hxx>
38 #include <gi_list.hxx>
39 #include <gi_parse.hxx>
41 #include <st_list.hxx>
47 ST_InfoListReader::ST_InfoListReader()
49 dpParser
= new GenericInfo_Parser
;
52 ST_InfoListReader::~ST_InfoListReader()
59 ST_InfoListReader::LoadList( List_GenericInfo
& o_rList
,
60 const Simstr
& i_sFileName
)
62 aListStack
.push_back(&o_rList
);
63 return dpParser
->LoadList(*this, i_sFileName
);
66 ST_InfoListReader::E_Error
67 ST_InfoListReader::GetLastError( UINT32
* o_pErrorLine
) const
69 return dpParser
->GetLastError(o_pErrorLine
);
73 ST_InfoListReader::AddKey( const char * i_sKey
,
75 const char * i_sValue
,
76 UINT32 i_nValueLength
,
77 const char * i_sComment
,
78 UINT32 i_nCommentLength
)
80 Simstr
sKey(i_sKey
, i_nKeyLength
);
81 Simstr
sValue(i_sValue
, i_nValueLength
);
82 Simstr
sComment(i_sComment
, i_nCommentLength
);
84 pCurKey
= new GenericInfo(sKey
, sValue
, sComment
);
85 aListStack
.back()->InsertInfo( pCurKey
);
89 ST_InfoListReader::OpenList()
93 cerr
<< "error: '{' without key found." << endl
;
97 aListStack
.push_back( & pCurKey
->SubList() );
101 ST_InfoListReader::CloseList()
103 if ( aListStack
.size() == 0 )
105 cerr
<< "error: '}' without corresponding '}' found." << endl
;
109 aListStack
.pop_back();
114 ST_InfoListWriter::ST_InfoListWriter()
119 ST_InfoListWriter::~ST_InfoListWriter()
122 ST_InfoListWriter::SaveList( const Simstr
& i_sFileName
,
123 List_GenericInfo
& io_rList
)
129 ST_InfoListWriter::GetLastError() const
131 return dpParser
->GetLastError(o_pErrorLine
);
135 ST_InfoListWriter::Start_CurList()
141 ST_InfoListWriter::NextOf_CurList()
147 ST_InfoListWriter::Get_CurKey( char * o_rKey
) const
153 ST_InfoListWriter::Get_CurValue( char * o_rValue
) const
159 ST_InfoListWriter::Get_CurComment( char * o_rComment
) const
165 ST_InfoListWriter::HasSubList_CurKey() const
171 ST_InfoListWriter::Push_CurList()
177 ST_InfoListWriter::Pop_CurList()