summaryrefslogtreecommitdiff
path: root/soltools/giparser
diff options
context:
space:
mode:
authorNikolai Pretzell <np@openoffice.org>2001-06-11 15:05:18 +0000
committerNikolai Pretzell <np@openoffice.org>2001-06-11 15:05:18 +0000
commit86b90004378f05dd3560203e82cddf5d317d10a1 (patch)
treedac75040686825d63cc8a903be6028444c542739 /soltools/giparser
parent25b9d581a07a589c61b8b1d39f8bf931308deb02 (diff)
New parser for generic info lists.
Diffstat (limited to 'soltools/giparser')
-rw-r--r--soltools/giparser/gen_info.cxx119
-rw-r--r--soltools/giparser/gi_list.cxx267
-rw-r--r--soltools/giparser/gi_parse.cxx411
-rw-r--r--soltools/giparser/makefile.mk95
-rw-r--r--soltools/giparser/st_gilrw.cxx211
5 files changed, 1103 insertions, 0 deletions
diff --git a/soltools/giparser/gen_info.cxx b/soltools/giparser/gen_info.cxx
new file mode 100644
index 000000000000..2fd69ac76227
--- /dev/null
+++ b/soltools/giparser/gen_info.cxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: gen_info.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:04:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <gen_info.hxx>
+#include <gi_list.hxx>
+
+
+GenericInfo::GenericInfo( const Simstr & i_sKey,
+ const Simstr & i_sValue,
+ const Simstr & i_sComment )
+ : sKey(i_sKey),
+ sValue(i_sValue),
+ sComment(i_sComment),
+ dpSubList(0)
+{
+}
+
+GenericInfo::GenericInfo( const GenericInfo & i_rInfo )
+ : sKey(i_rInfo.sKey),
+ sValue(i_rInfo.sValue),
+ sComment(i_rInfo.sComment),
+ dpSubList(0)
+{
+ if ( i_rInfo.HasSubList() )
+ {
+ dpSubList = new List_GenericInfo(i_rInfo.SubList());
+ }
+}
+
+GenericInfo::~GenericInfo()
+{
+ if ( dpSubList != 0 )
+ delete dpSubList;
+}
+
+GenericInfo &
+GenericInfo::operator=( const GenericInfo & i_rInfo )
+{
+ sKey = i_rInfo.sKey;
+ sValue = i_rInfo.sValue;
+ sComment = i_rInfo.sComment;
+
+ if ( dpSubList != 0 )
+ delete dpSubList;
+ if ( i_rInfo.HasSubList() )
+ {
+ dpSubList = new List_GenericInfo(i_rInfo.SubList());
+ }
+ else
+ dpSubList = 0;
+
+ return *this;
+}
+
+List_GenericInfo &
+GenericInfo::CreateMyList() const
+{
+ return * ( const_cast<GenericInfo&>(*this).dpSubList = new List_GenericInfo);
+
+}
+
diff --git a/soltools/giparser/gi_list.cxx b/soltools/giparser/gi_list.cxx
new file mode 100644
index 000000000000..f81361e8737a
--- /dev/null
+++ b/soltools/giparser/gi_list.cxx
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * $RCSfile: gi_list.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:04:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <gi_list.hxx>
+
+
+#include <gen_info.hxx>
+
+
+
+const char C_cKeySeparator = '/';
+
+
+List_GenericInfo::List_GenericInfo()
+{
+}
+
+List_GenericInfo::List_GenericInfo( const List_GenericInfo & i_rList )
+ : aChildren(i_rList.aChildren)
+{
+}
+
+List_GenericInfo::~List_GenericInfo()
+{
+}
+
+List_GenericInfo &
+List_GenericInfo::operator=( const List_GenericInfo & i_rList )
+{
+ aChildren = i_rList.aChildren;
+ return *this;
+}
+
+const GenericInfo *
+List_GenericInfo::operator[]( KeyPath i_sKeyPath ) const
+{
+ return const_cast< List_GenericInfo& >(*this)[i_sKeyPath];
+}
+
+GenericInfo *
+List_GenericInfo::operator[]( KeyPath i_sKeyPath )
+{
+ bool bExists = false;
+ const char * sNextPathSegment = 0;
+ sub_iterator it = lower_bound(bExists, sNextPathSegment, i_sKeyPath);
+
+ if ( bExists )
+ {
+ if ( sNextPathSegment == 0 )
+ return (*it);
+ else
+ return (*it)->SubList()[sNextPathSegment];
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+bool
+List_GenericInfo::InsertInfo( GenericInfo * let_dpInfo,
+ bool i_bOverwrite )
+{
+ if ( let_dpInfo == 0 )
+ return false;
+
+ bool bExists = false;
+ const char * sNextPathSegment = 0;
+ sub_iterator it = lower_bound(bExists, sNextPathSegment, let_dpInfo->Key() );
+
+ if ( ! bExists )
+ {
+ aChildren.insert( it, let_dpInfo );
+ }
+ else if ( i_bOverwrite )
+ {
+ delete (*it);
+ (*it) = let_dpInfo;
+ }
+ else
+ {
+ delete let_dpInfo;
+ return false;
+ }
+
+ return true;
+}
+
+bool
+List_GenericInfo::InsertInfoByPath( GenericInfo * let_dpInfo,
+ KeyPath i_sKeyPath,
+ bool i_bCreatePath,
+ bool i_bOverwrite )
+{
+ if ( let_dpInfo == 0 )
+ return false;
+
+ if ( i_sKeyPath == 0 ? true : *i_sKeyPath == 0 )
+ return InsertInfo(let_dpInfo, i_bOverwrite);
+
+ bool bExists = false;
+ const char * sNextPathSegment = 0;
+ sub_iterator it = lower_bound(bExists, sNextPathSegment, i_sKeyPath);
+
+ if ( bExists )
+ {
+ return (*it)->SubList().InsertInfoByPath(
+ let_dpInfo,
+ sNextPathSegment,
+ i_bCreatePath,
+ i_bOverwrite );
+ }
+ else if ( i_bCreatePath )
+ {
+ Simstr aKey( i_sKeyPath,
+ 0,
+ sNextPathSegment -
+ ( *sNextPathSegment == 0 ? 0 : 1)
+ - i_sKeyPath );
+
+ GenericInfo * pNew = new GenericInfo(aKey);
+ InsertInfo(pNew,false);
+
+ return pNew->SubList().InsertInfoByPath(
+ let_dpInfo,
+ sNextPathSegment,
+ i_bCreatePath,
+ i_bOverwrite );
+ }
+ else
+ {
+ delete let_dpInfo;
+ return false;
+ }
+
+ return true;
+}
+
+GenericInfo *
+List_GenericInfo::ReleaseInfo( KeyPath i_sKeyPath )
+{
+ bool bExists = false;
+ const char * sNextPathSegment = 0;
+ sub_iterator it = lower_bound(bExists, sNextPathSegment, i_sKeyPath );
+
+ if ( bExists )
+ {
+ if ( *sNextPathSegment == 0 )
+ return (*it);
+ else
+ return (*it)->SubList().ReleaseInfo(sNextPathSegment);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+void
+List_GenericInfo::DeleteInfo( KeyPath i_sKeyPath )
+{
+ bool bExists = false;
+ const char * sNextPathSegment = 0;
+ sub_iterator it = lower_bound(bExists, sNextPathSegment, i_sKeyPath );
+
+ if ( bExists )
+ {
+ if ( *sNextPathSegment == 0 )
+ {
+ aChildren.remove(it);
+ }
+ else
+ {
+ (*it)->SubList().DeleteInfo(sNextPathSegment);
+ }
+ }
+}
+
+List_GenericInfo::sub_iterator
+List_GenericInfo::lower_bound( bool & o_bExists,
+ const char * & o_sNextPathSegment,
+ KeyPath i_sKeyPath )
+{
+ o_sNextPathSegment = strchr(i_sKeyPath, '/');
+ Simstr sKey( i_sKeyPath, (o_sNextPathSegment == 0 ? strlen(i_sKeyPath) : o_sNextPathSegment++ - i_sKeyPath) );
+ GenericInfo aSearch(sKey);
+
+ unsigned low = 0;
+ unsigned high = aChildren.size();
+
+ for ( unsigned cur = high / 2; high > low; cur = (low + high) / 2 )
+ {
+ if ( *aChildren[cur] < aSearch )
+ {
+ low = cur+1;
+ }
+ else
+ {
+ high = cur;
+ }
+ } // end for
+
+ o_bExists = low < aChildren.size()
+ ? !(aSearch < *aChildren[low] )
+ : false;
+ return &aChildren[low];
+}
+
diff --git a/soltools/giparser/gi_parse.cxx b/soltools/giparser/gi_parse.cxx
new file mode 100644
index 000000000000..5ba7060df7aa
--- /dev/null
+++ b/soltools/giparser/gi_parse.cxx
@@ -0,0 +1,411 @@
+/*************************************************************************
+ *
+ * $RCSfile: gi_parse.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:04:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <gi_parse.hxx>
+
+#include <stdio.h>
+#include <string.h>
+#include <fstream>
+#include <gilacces.hxx>
+
+
+using namespace std;
+
+
+const char * C_sLineEnd = "\r\n";
+
+
+
+inline void
+WriteStr( ostream & o_rOut, const Simstr & i_rStr )
+{
+ o_rOut.write( i_rStr.str(), i_rStr.l() );
+}
+
+inline void
+WriteStr( ostream & o_rOut, const char * i_rStr )
+{
+ o_rOut.write( i_rStr, strlen(i_rStr) );
+}
+
+inline void
+GenericInfo_Parser::SetError( E_Error i_eError )
+{
+ eErrorCode = i_eError;
+ nErrorLine = nCurLine;
+}
+
+
+GenericInfo_Parser::GenericInfo_Parser()
+ : sCurParsePosition(""),
+ nCurLine(0),
+ nLevel(0),
+ bGoon(false),
+ // sCurComment,
+ eErrorCode(ok),
+ nErrorLine(0),
+ pResult(0),
+ pResource(0)
+{
+}
+
+GenericInfo_Parser::~GenericInfo_Parser()
+{
+}
+
+bool
+GenericInfo_Parser::LoadList( GenericInfoList_Builder & o_rResult,
+ const Simstr & i_sSourceFileName )
+{
+ ifstream aFile( i_sSourceFileName.str() );
+ if ( aFile.fail() )
+ {
+ SetError(cannot_open);
+ return false;
+ }
+
+ ResetState(o_rResult);
+
+ for ( ReadLine(aFile); bGoon; ReadLine(aFile) )
+ {
+ bool bOk = InterpretLine();
+ if ( !bOk)
+ {
+ SetError(syntax_error);
+ break;
+ }
+ }
+
+ if ( nLevel > 0 && eErrorCode == ok)
+ {
+ SetError(unexpected_eof);
+ }
+ else if ( nLevel < 0 )
+ {
+ SetError(unexpected_list_end);
+ }
+
+ aFile.close();
+ return eErrorCode == ok;
+}
+
+bool
+GenericInfo_Parser::SaveList( const Simstr & i_rOutputFile,
+ GenericInfoList_Browser & io_rListBrowser )
+{
+ ofstream aFile( i_rOutputFile.str() );
+ if ( aFile.fail() )
+ {
+ SetError(cannot_open);
+ return false;
+ }
+
+ ResetState(io_rListBrowser);
+
+ WriteList(aFile);
+
+ aFile.close();
+ return eErrorCode == ok;
+}
+
+void
+GenericInfo_Parser::ResetState( GenericInfoList_Builder & io_rResult )
+{
+ sCurParsePosition = "";
+ nCurLine = 0;
+ nLevel = 0;
+ bGoon = true;
+ sCurComment = "";
+ eErrorCode = ok;
+ nErrorLine = 0;
+ pResult = &io_rResult;
+ pResource = 0;
+}
+
+void
+GenericInfo_Parser::ResetState( GenericInfoList_Browser & io_rSrc )
+{
+ sCurParsePosition = "";
+ nCurLine = 0;
+ nLevel = 0;
+ bGoon = false;
+ sCurComment = "";
+ eErrorCode = ok;
+ nErrorLine = 0;
+ pResult = 0;
+ pResource = &io_rSrc;
+}
+
+
+void
+GenericInfo_Parser::ReadLine( istream & i_rSrc )
+{
+ const int nInputSize = 32000;
+ static char sInput[nInputSize];
+
+ i_rSrc.get(sInput, nInputSize);
+ UINT32 nGot = UINT32(i_rSrc.gcount());
+ if (nGot == 0)
+ {
+ bGoon = false;
+ return;
+ }
+
+ nCurLine++;
+
+#if 0
+ if ( sInput[ nGot-1 ] == '\r' )
+ sInput[ nGot-1 ] = '\0';
+#endif
+ i_rSrc.get();
+
+ for ( sCurParsePosition = &sInput[0]; *sCurParsePosition > 0 && *sCurParsePosition <= 32; ++sCurParsePosition );
+ for ( char * sEnd = const_cast< char* >(strchr(sCurParsePosition,'\0'));
+ sEnd != sCurParsePosition
+ ? *(sEnd-1) <= 32
+ : false;
+ --sEnd )
+ {
+ *(sEnd-1) = '\0';
+ }
+}
+
+bool
+GenericInfo_Parser::InterpretLine()
+{
+ switch ( ClassifyLine() )
+ {
+ case lt_key: ReadKey();
+ break;
+ case lt_open_list: PushLevel_Read();
+ break;
+ case lt_close_list: PopLevel_Read();
+ break;
+ case lt_comment: AddCurLine2CurComment();
+ break;
+ case lt_empty: AddCurLine2CurComment();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+GenericInfo_Parser::E_LineType
+GenericInfo_Parser::ClassifyLine()
+{
+ switch ( *sCurParsePosition )
+ {
+ case '{': return lt_open_list;
+ case '}': return lt_close_list;
+ case '#': return lt_comment;
+ case '0': return lt_empty;
+ }
+
+ return lt_key;
+}
+
+void
+GenericInfo_Parser::ReadKey()
+{
+ const char * pSearch = sCurParsePosition;
+
+ for ( ; *pSearch > 32; ++pSearch );
+ UINT32 nKeyLength = pSearch - sCurParsePosition;
+
+ for ( ; *pSearch <= 32 && *pSearch > '\0'; ++pSearch );
+
+ pResult->AddKey( sCurParsePosition, nKeyLength,
+ pSearch, strlen(pSearch),
+ sCurComment.str(), sCurComment.l()
+ );
+}
+
+void
+GenericInfo_Parser::PushLevel_Read()
+{
+ nLevel++;
+ pResult->OpenList();
+}
+
+void
+GenericInfo_Parser::PopLevel_Read()
+{
+ nLevel--;
+ pResult->CloseList();
+}
+
+void
+GenericInfo_Parser::AddCurLine2CurComment()
+{
+ sCurComment += sCurParsePosition;
+ sCurComment += C_sLineEnd;
+}
+
+void
+GenericInfo_Parser::WriteList( ostream & o_rFile )
+{
+ static char sBuffer[32000];
+
+ for ( bGoon = pResource->Start_CurList();
+ bGoon;
+ bGoon = pResource->NextOf_CurList() )
+ {
+ pResource->Get_CurComment(&sBuffer[0]);
+ WriteComment(o_rFile,sBuffer);
+
+ pResource->Get_CurKey(&sBuffer[0]);
+ WriteKey(o_rFile,sBuffer);
+
+ pResource->Get_CurValue(&sBuffer[0]);
+ WriteValue(o_rFile,sBuffer);
+
+ if ( pResource->HasSubList_CurKey() )
+ {
+ PushLevel_Write();
+
+/*
+ WriteIndentation();
+ o_rFile.write("{",1);
+ o_rFile.write(C_sLineEnd, C_nLineEndLength);
+*/
+ WriteList(o_rFile);
+
+/*
+ WriteIndentation();
+ o_rFile.write("}",1);
+ o_rFile.write(C_sLineEnd, C_nLineEndLength);
+*/
+ PopLevel_Write();
+ }
+ } // end for
+}
+
+void
+GenericInfo_Parser::PushLevel_Write()
+{
+ nLevel++;
+ pResource->Push_CurList();
+}
+
+void
+GenericInfo_Parser::PopLevel_Write()
+{
+ nLevel--;
+ pResource->Pop_CurList();
+}
+
+void
+GenericInfo_Parser::WriteComment( ostream & o_rFile,
+ const char * i_sStr )
+{
+ WriteStr( o_rFile, i_sStr );
+ if ( i_sStr[ strlen(i_sStr)-1 ] != '\n' )
+ WriteStr( o_rFile, C_sLineEnd );
+}
+
+void
+GenericInfo_Parser::WriteKey( ostream & o_rFile,
+ const char * i_sStr )
+{
+ WriteIndentation(o_rFile);
+ WriteStr( o_rFile, i_sStr );
+}
+
+void
+GenericInfo_Parser::WriteValue( ostream & o_rFile,
+ const char * i_sStr )
+{
+ if ( i_sStr != 0 ? strlen(i_sStr) > 0 : false )
+ {
+ WriteStr(o_rFile," ");
+ WriteStr(o_rFile,i_sStr);
+ }
+
+ WriteStr(o_rFile,C_sLineEnd);
+}
+
+void
+GenericInfo_Parser::WriteIndentation( ostream & o_rFile )
+{
+ const int nIndentBound = 60;
+
+ static const char sIndentation[nIndentBound+1] =
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+
+ if ( nLevel == 0 )
+ return;
+
+ if ( nLevel <= nIndentBound )
+ o_rFile.write( sIndentation, nLevel );
+ else
+ {
+ INT16 iLevel = nLevel;
+ for ( ; iLevel > nIndentBound; iLevel-=nIndentBound )
+ o_rFile.write( sIndentation, nIndentBound );
+ o_rFile.write( sIndentation, iLevel );
+ }
+}
+
+
+
diff --git a/soltools/giparser/makefile.mk b/soltools/giparser/makefile.mk
new file mode 100644
index 000000000000..c89feb9fae6b
--- /dev/null
+++ b/soltools/giparser/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: np $ $Date: 2001-06-11 16:04:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=soltools
+TARGET=soltools_giparser
+TARGETTYPE=CUI
+
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+
+
+# --- Files --------------------------------------------------------
+
+OBJFILES=\
+ $(OBJ)$/gen_info.obj \
+ $(OBJ)$/gi_list.obj \
+ $(OBJ)$/gi_parse.obj \
+ $(OBJ)$/st_gilrw.obj
+
+
+
+
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+
+
diff --git a/soltools/giparser/st_gilrw.cxx b/soltools/giparser/st_gilrw.cxx
new file mode 100644
index 000000000000..ef8d06688b79
--- /dev/null
+++ b/soltools/giparser/st_gilrw.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: st_gilrw.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:04:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <st_gilrw.hxx>
+
+#include <gen_info.hxx>
+#include <gi_list.hxx>
+#include <gi_parse.hxx>
+#include <simstr.hxx>
+#include <st_list.hxx>
+
+
+using namespace std;
+
+
+ST_InfoListReader::ST_InfoListReader()
+{
+ dpParser = new GenericInfo_Parser;
+}
+
+ST_InfoListReader::~ST_InfoListReader()
+{
+ delete dpParser;
+}
+
+
+bool
+ST_InfoListReader::LoadList( List_GenericInfo & o_rList,
+ const Simstr & i_sFileName )
+{
+ aListStack.push_back(&o_rList);
+ return dpParser->LoadList(*this, i_sFileName);
+}
+
+ST_InfoListReader::E_Error
+ST_InfoListReader::GetLastError( UINT32 * o_pErrorLine ) const
+{
+ return dpParser->GetLastError(o_pErrorLine);
+}
+
+void
+ST_InfoListReader::AddKey( const char * i_sKey,
+ UINT32 i_nKeyLength,
+ const char * i_sValue,
+ UINT32 i_nValueLength,
+ const char * i_sComment,
+ UINT32 i_nCommentLength )
+{
+ Simstr sKey(i_sKey, i_nKeyLength);
+ Simstr sValue(i_sValue, i_nValueLength);
+ Simstr sComment(i_sComment, i_nCommentLength);
+
+ pCurKey = new GenericInfo(sKey, sValue, sComment);
+ aListStack.back()->InsertInfo( pCurKey );
+}
+
+void
+ST_InfoListReader::OpenList()
+{
+ if ( pCurKey == 0 )
+ {
+ cerr << "error: '{' without key found." << endl;
+ exit(1);
+ }
+
+ aListStack.push_back( & pCurKey->SubList() );
+}
+
+void
+ST_InfoListReader::CloseList()
+{
+ if ( aListStack.size() == 0 )
+ {
+ cerr << "error: '}' without corresponding '}' found." << endl;
+ exit(1);
+ }
+
+ aListStack.pop_back();
+}
+
+
+#if 0
+ST_InfoListWriter::ST_InfoListWriter()
+{
+
+}
+
+ST_InfoListWriter::~ST_InfoListWriter()
+
+bool
+ST_InfoListWriter::SaveList( const Simstr & i_sFileName,
+ List_GenericInfo & io_rList )
+{
+
+}
+
+E_Error
+ST_InfoListWriter::GetLastError() const
+{
+ return dpParser->GetLastError(o_pErrorLine);
+}
+
+bool
+ST_InfoListWriter::Start_CurList()
+{
+
+}
+
+bool
+ST_InfoListWriter::NextOf_CurList()
+{
+
+}
+
+void
+ST_InfoListWriter::Get_CurKey( char * o_rKey ) const
+{
+
+}
+
+void
+ST_InfoListWriter::Get_CurValue( char * o_rValue ) const
+{
+
+}
+
+void
+ST_InfoListWriter::Get_CurComment( char * o_rComment ) const
+{
+
+}
+
+bool
+ST_InfoListWriter::HasSubList_CurKey() const
+{
+
+}
+
+void
+ST_InfoListWriter::Push_CurList()
+{
+
+}
+
+void
+ST_InfoListWriter::Pop_CurList()
+{
+
+}
+#endif
+
+