summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--soltools/inc/gen_info.hxx123
-rw-r--r--soltools/inc/gi_list.hxx239
-rw-r--r--soltools/inc/gi_parse.hxx197
-rw-r--r--soltools/inc/gilacces.hxx138
-rw-r--r--soltools/inc/simstr.hxx257
-rw-r--r--soltools/inc/st_gilrw.hxx159
-rw-r--r--soltools/inc/st_list.hxx364
-rw-r--r--soltools/inc/st_types.hxx74
-rw-r--r--soltools/support/makefile.mk90
-rw-r--r--soltools/support/simstr.cxx864
15 files changed, 3608 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
+
+
diff --git a/soltools/inc/gen_info.hxx b/soltools/inc/gen_info.hxx
new file mode 100644
index 000000000000..b1e5b8e97ab7
--- /dev/null
+++ b/soltools/inc/gen_info.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: gen_info.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef GEN_INFO_HXX
+#define GEN_INFO_HXX
+
+
+#include "simstr.hxx"
+#include <string.h>
+
+
+
+class List_GenericInfo;
+
+
+/** Holds generic informations in a simple hierarchical format.
+*/
+class GenericInfo
+{
+ public:
+ // LIFECFYCLE
+ GenericInfo(
+ const Simstr & i_sKey,
+ const Simstr & i_sValue = Simstr::null_(),
+ const Simstr & i_sComment = Simstr::null_() );
+ GenericInfo(
+ const GenericInfo & i_rInfo );
+ ~GenericInfo();
+
+ // OPERATORS
+ GenericInfo & operator=(
+ const GenericInfo & i_rInfo );
+ bool operator<(
+ const GenericInfo & i_rInfo ) const
+#ifdef UNX
+ { return strcasecmp(sKey.str(),i_rInfo.sKey.str()) < 0; }
+#else
+ { return stricmp(sKey.str(),i_rInfo.sKey.str()) < 0; }
+#endif
+ // INFO
+ const Simstr & Key() const { return sKey; }
+ const Simstr & Value() const { return sValue; }
+ const Simstr & Comment() const { return sComment; }
+ bool HasSubList() const { return dpSubList != 0; }
+
+ virtual const List_GenericInfo &
+ SubList() const { return HasSubList() ? *dpSubList : CreateMyList(); }
+ // ACCESS
+ virtual List_GenericInfo &
+ SubList() { return HasSubList() ? *dpSubList : CreateMyList(); }
+
+ private:
+ /// @precond dpSubList == 0 .
+ List_GenericInfo & CreateMyList() const;
+
+ // DATA
+ Simstr sKey;
+ Simstr sValue;
+ Simstr sComment;
+ List_GenericInfo * dpSubList; /// Owned by this object.
+};
+
+
+#endif
+
diff --git a/soltools/inc/gi_list.hxx b/soltools/inc/gi_list.hxx
new file mode 100644
index 000000000000..3e417f44c1cb
--- /dev/null
+++ b/soltools/inc/gi_list.hxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * $RCSfile: gi_list.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_GI_LIST_HXX
+#define SOLTOOLS_GI_LIST_HXX
+
+
+#include "st_list.hxx"
+
+
+class GenericInfo;
+
+/** Holds set of generic informations in a sorted list.
+
+ At different places, methods of this class have a parameter,
+ whose name includes "path". Those are paths like this:
+
+ src370/drives/o:
+
+ which are used to access GenericInfo keys in deep search through
+ the lists and their sublists.
+*/
+class List_GenericInfo
+{
+ public:
+ // TYPES
+ class const_iterator
+ {
+ public:
+ const GenericInfo & operator*() const;
+ const_iterator & operator++();
+ bool operator==( const const_iterator & ) const;
+ bool operator!=( const const_iterator & ) const;
+
+ const_iterator( const DynamicList< GenericInfo >::const_iterator & );
+ private: DynamicList< GenericInfo >::const_iterator it;
+ };
+ class iterator
+ { public:
+ GenericInfo & operator*() const;
+ iterator & operator++();
+ bool operator==( const iterator & ) const;
+ bool operator!=( const iterator & ) const;
+
+ iterator( const DynamicList< GenericInfo >::iterator & );
+ private: DynamicList< GenericInfo >::iterator it;
+ };
+
+ typedef const char * KeyPath;
+
+ // LIFECYCLE
+ List_GenericInfo();
+ List_GenericInfo(
+ const List_GenericInfo &
+ i_rList );
+ ~List_GenericInfo();
+
+ // OPERATORS
+ List_GenericInfo & operator=(
+ const List_GenericInfo &
+ i_rList );
+ const GenericInfo * operator[](
+ KeyPath i_sKeyPath ) const;
+ GenericInfo * operator[](
+ KeyPath i_sKeyPath );
+
+ // OPERATIONS
+ bool InsertInfo(
+ GenericInfo * let_dpInfo, /// Will be owned by this object.
+ bool i_bOverwrite = true );
+ bool InsertInfoByPath(
+ GenericInfo * let_dpInfo, /// Will be owned by this object.
+ KeyPath i_sKeyPath,
+ bool i_bCreatePath,
+ bool i_bOverwrite = true );
+
+ GenericInfo * ReleaseInfo( /// Removes the GenericInfo from its parent.
+ KeyPath i_sKeyPath );
+
+ void DeleteInfo(
+ KeyPath i_sKeyPath );
+
+ // INFO
+ unsigned Size() const;
+
+ const_iterator Begin() const;
+ const_iterator End() const;
+
+ // ACCESS
+ iterator Begin();
+ iterator End();
+
+ private:
+ typedef DynamicList< GenericInfo >::iterator sub_iterator;
+
+ sub_iterator lower_bound(
+ bool & o_bExists,
+ const char * & o_sNextPathSegment,
+ KeyPath i_sKeyPath );
+
+ DynamicList< GenericInfo >
+ aChildren;
+};
+
+
+// IMPLEMENTATION
+
+
+inline const GenericInfo &
+List_GenericInfo::
+const_iterator::operator*() const
+ { return *(*it); }
+
+inline List_GenericInfo::const_iterator &
+List_GenericInfo::
+const_iterator::operator++()
+ { ++it; return *this; }
+
+inline bool
+List_GenericInfo::
+const_iterator::operator==( const const_iterator & i_rIter ) const
+ { return it == i_rIter.it; }
+
+inline bool
+List_GenericInfo::
+const_iterator::operator!=( const const_iterator & i_rIter ) const
+ { return it != i_rIter.it; }
+
+inline List_GenericInfo::
+const_iterator::const_iterator( const DynamicList< GenericInfo >::const_iterator & i_rDynListIter )
+ : it(i_rDynListIter) { }
+
+
+inline GenericInfo &
+List_GenericInfo::
+iterator::operator*() const
+ { return *(*it); }
+
+inline List_GenericInfo::iterator &
+List_GenericInfo::
+iterator::operator++()
+ { ++it; return *this; }
+
+inline bool
+List_GenericInfo::
+iterator::operator==( const iterator & i_rIter ) const
+ { return it == i_rIter.it; }
+
+inline bool
+List_GenericInfo::
+iterator::operator!=( const iterator & i_rIter ) const
+ { return it != i_rIter.it; }
+
+inline List_GenericInfo::
+iterator::iterator( const DynamicList< GenericInfo >::iterator & i_rDynListIter )
+ : it(i_rDynListIter) { }
+
+inline unsigned
+List_GenericInfo::Size() const
+ { return aChildren.size(); }
+
+inline List_GenericInfo::const_iterator
+List_GenericInfo::Begin() const
+ { return aChildren.begin(); }
+
+inline List_GenericInfo::const_iterator
+List_GenericInfo::End() const
+ { return aChildren.end(); }
+
+inline List_GenericInfo::iterator
+List_GenericInfo::Begin()
+ { return aChildren.begin(); }
+
+inline List_GenericInfo::iterator
+List_GenericInfo::End()
+ { return aChildren.end(); }
+
+
+
+#endif
+
diff --git a/soltools/inc/gi_parse.hxx b/soltools/inc/gi_parse.hxx
new file mode 100644
index 000000000000..7d2666438da3
--- /dev/null
+++ b/soltools/inc/gi_parse.hxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * $RCSfile: gi_parse.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef SOLTOOLS_GI_PARSE_HXX
+#define SOLTOOLS_GI_PARSE_HXX
+
+#include "simstr.hxx"
+#include "gilacces.hxx"
+#include <fstream>
+
+class GenericInfoList_Builder;
+class GenericInfoList_Browser;
+
+/** Reads generic information files into a simple structure in memory.
+
+Information files used by this parser have the following format:
+
+key [value]
+{
+ key [value]
+ key [value]
+ {
+ key [value]
+ ...
+ ...
+ }
+}
+key [value]
+...
+...
+
+*/
+
+
+class GenericInfo_Parser : public GenericInfoParseTypes
+{
+ public:
+ typedef unsigned long UINT32;
+ typedef short INT16;
+
+ GenericInfo_Parser();
+ ~GenericInfo_Parser();
+
+ /** reads a information file and stores the data in a
+ List_GenericInfo
+ */
+ bool LoadList(
+ GenericInfoList_Builder &
+ o_rResult,
+ const Simstr & i_sSourceFileName );
+
+ /** save the InformationList to rSourceFile
+ returns false on error
+ */
+ bool SaveList(
+ const Simstr & i_rOutputFile,
+ GenericInfoList_Browser &
+ io_rListBrowser );
+
+ E_Error GetLastError(
+ UINT32 * o_pErrorLine = 0 ) const;
+
+ private:
+ enum E_LineType
+ {
+ lt_empty = 0,
+ lt_key,
+ lt_open_list,
+ lt_close_list,
+ lt_comment
+ };
+
+ void SetError(
+ E_Error i_eError );
+ void ResetState(
+ GenericInfoList_Builder &
+ io_rResult );
+ void ResetState(
+ GenericInfoList_Browser &
+ io_rSrc );
+
+ void ReadLine(
+ std::istream & i_rSrc );
+ bool InterpretLine();
+ E_LineType ClassifyLine();
+
+ void ReadKey();
+ void PushLevel_Read(); /// When list is opened by '{':
+ void PopLevel_Read(); /// When list is closed by '}':
+ void AddCurLine2CurComment();
+
+ void WriteList(
+ std::ostream & o_rFile );
+
+ void PushLevel_Write(); /// When SubList is pushed in pResource
+ void PopLevel_Write(); /// When SubList is popped in pResource
+
+ void WriteComment(
+ std::ostream & o_rFile,
+ const char * i_sStr );
+ void WriteKey(
+ std::ostream & o_rFile,
+ const char * i_sStr );
+ void WriteValue(
+ std::ostream & o_rFile,
+ const char * i_sStr );
+ void WriteIndentation(
+ std::ostream & o_rFile );
+
+ // DATA
+ const char * sCurParsePosition;
+
+ UINT32 nCurLine;
+ INT16 nLevel;
+ bool bGoon;
+
+ Simstr sCurComment;
+
+ E_Error eErrorCode;
+ UINT32 nErrorLine;
+
+ GenericInfoList_Builder *
+ pResult;
+ GenericInfoList_Browser *
+ pResource;
+};
+
+
+inline GenericInfo_Parser::E_Error
+GenericInfo_Parser::GetLastError( UINT32 * o_pErrorLine ) const
+{
+ if ( o_pErrorLine != 0 )
+ *o_pErrorLine = nErrorLine;
+ return eErrorCode;
+}
+
+
+#endif
+
+
diff --git a/soltools/inc/gilacces.hxx b/soltools/inc/gilacces.hxx
new file mode 100644
index 000000000000..bfc08b6cad18
--- /dev/null
+++ b/soltools/inc/gilacces.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: gilacces.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_GILACCES_HXX
+#define SOLTOOLS_GILACCES_HXX
+
+
+
+class GenericInfoParseTypes
+{
+ public:
+ enum E_Error
+ {
+ ok = 0,
+ cannot_open,
+ unexpected_eof,
+ syntax_error,
+ unexpected_list_end
+ };
+};
+
+
+
+/** This class is an abstract interface for a service, which
+ builds a memory structure out of a generic information
+ structure, read from a file or other stream.
+
+ There may be different implementations, which build different kinds
+ of memory structures.
+*/
+class GenericInfoList_Builder
+{
+ public:
+ typedef unsigned long UINT32;
+
+ virtual ~GenericInfoList_Builder() {}
+
+ virtual void AddKey(
+ const char * i_sKey,
+ UINT32 i_nKeyLength,
+ const char * i_sValue,
+ UINT32 i_nValueLength,
+ const char * i_sComment,
+ UINT32 i_nCommentLength ) = 0;
+
+ virtual void OpenList() = 0;
+ virtual void CloseList() = 0;
+};
+
+
+/** This class is an abstract interface for a service, which
+ returns the values of a generic information tree out of
+ a memory structure.
+
+ There may be different implementations, which browse different
+ kinds of memory structures.
+*/
+class GenericInfoList_Browser
+{
+ public:
+ virtual ~GenericInfoList_Browser() {}
+
+ virtual bool Start_CurList() = 0;
+ virtual bool NextOf_CurList() = 0;
+
+ virtual void Get_CurKey(
+ char * o_rKey ) const = 0;
+ virtual void Get_CurValue(
+ char * o_rValue ) const = 0;
+ virtual void Get_CurComment(
+ char * o_rComment ) const = 0;
+ virtual bool HasSubList_CurKey() const = 0;
+
+ virtual void Push_CurList() = 0;
+ virtual void Pop_CurList() = 0;
+};
+
+
+#endif
+
diff --git a/soltools/inc/simstr.hxx b/soltools/inc/simstr.hxx
new file mode 100644
index 000000000000..5081e32b58d0
--- /dev/null
+++ b/soltools/inc/simstr.hxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * $RCSfile: simstr.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_SIMSTR_HXX
+#define SOLTOOLS_SIMSTR_HXX
+
+
+class Simstr /// Simple string class.
+{
+// INTERFACE
+ public:
+ // LIFECYCLE
+ Simstr(
+ const char * str = 0);
+ Simstr( /** Creates Simstr out of a copy of the first
+ 'nrOfBytes' bytes of 'anyBytes'.
+ Adds a '\0' at the end. */
+ const char * anybytes,
+ int nrOfBytes);
+ Simstr( /** Creates Simstr out of a copy of the described bytes within 'anyBytes'.
+ Adds a '\0' at the end. */
+ const char * anybytes,
+ int firstBytesPos,
+ int nrOfBytes );
+ Simstr( /// Creates Simstr of 'anzahl' times 'c'.
+ char c,
+ int anzahl);
+ Simstr(
+ const Simstr & S);
+ ~Simstr();
+
+
+ // OPERATORS
+ operator const char*() const;
+
+ Simstr & operator=(
+ const Simstr & S );
+
+ Simstr operator+(
+ const Simstr & S ) const;
+ Simstr & operator+=(
+ const Simstr & S );
+ Simstr & operator+=(
+ const char * s );
+
+ bool operator==(
+ const Simstr & S ) const;
+ bool operator!=(
+ const Simstr & S ) const;
+ bool operator<(
+ const Simstr & S ) const;
+ bool operator>(
+ const Simstr & S ) const;
+ bool operator<=(
+ const Simstr & S ) const;
+ bool operator>=(
+ const Simstr & S ) const;
+ // INFO
+ static const Simstr &
+ null_();
+
+ const char * str() const;
+ int l() const; // Length of string without '\0' at end.
+ char * s(); // ATTENTION !!! // Only to be used, when a function needs a 'char*' but
+ // nevertheless THAT WILL BE NOT CHANGED!
+ // Typecasts to 'const char*' are performed automatically.
+ char get(
+ int n) const;
+ char get_front() const;
+ char get_back() const;
+ Simstr get(
+ int startPos,
+ int anzahl ) const;
+ Simstr get_front(
+ int anzahl ) const;
+ Simstr get_back(
+ int anzahl ) const;
+
+ int pos_first(
+ char c ) const;
+ int pos_first_after(
+ char c,
+ int startSearchPos ) const;
+ int pos_last(
+ char c ) const;
+ int pos_first(
+ const Simstr & S ) const;
+ int pos_last(
+ const Simstr & S ) const;
+ int count(
+ char c ) const;
+ bool is_empty() const; // Only true if object == "".
+ bool is_no_text() const; // String may contain spaces or tabs.
+
+ Simstr get_first_token(
+ char c ) const;
+ Simstr get_last_token(
+ char c ) const;
+
+ // ACCESS
+ char & ch( /** Reference to sz[n]. Allows change of this char.
+ !!! No safety, if n is out of the allowed range! */
+ int n );
+
+ // OPERATIONS
+ void insert(
+ int pos,
+ char c );
+ void push_front(
+ char c );
+ void push_back(
+ char c );
+ void insert(
+ int pos,
+ const Simstr & S );
+ void push_front(
+ const Simstr & S );
+ void push_back(
+ const Simstr & S );
+
+ void remove(
+ int pos,
+ int anzahl = 1 );
+ void remove_trailing_blanks();
+ void pop_front(
+ int anzahl = 1 );
+ void pop_back(
+ int anzahl = 1 );
+ void rem_back_from(
+ int removeStartPos );
+ void remove_all(
+ char c );
+ void remove_all( // Starts search left.
+ const Simstr & S );
+ void strip(
+ char c ); // Removes all characters == c from front and back.
+ // c == ' ' removes also TABs !!!
+ void empty(); // Changes object to the value "".
+
+ void replace(
+ int pos,
+ char c );
+ void replace(
+ int startPos,
+ int anzahl,
+ const Simstr & S );
+ void replace_all(
+ char oldCh,
+ char newCh );
+ void replace_all(
+ const Simstr & oldS,
+ const Simstr & newS );
+ void to_lower();
+
+ Simstr take_first_token( /// Token is removed from the Simstr.
+ char c );
+ Simstr take_last_token( /// Token is removed from the Simstr.
+ char c );
+ private:
+ // DATA
+ char * sz;
+ int len;
+};
+
+// Simstr - char* / char - concatenations
+Simstr operator+(const char * str, const Simstr & S);
+Simstr operator+(const Simstr & S, const char * str);
+Simstr operator+(char c, const Simstr & S);
+Simstr operator+(const Simstr & S, char c);
+
+// Simstr - char* - comparison operators
+bool operator==(const Simstr & S, const char * str);
+bool operator!=(const Simstr & S, const char * str);
+bool operator<(const Simstr & S, const char * str);
+bool operator>(const Simstr & S, const char * str);
+bool operator<=(const Simstr & S, const char * str);
+bool operator>=(const Simstr & S, const char * str);
+bool operator==(const char * str, const Simstr & S);
+bool operator!=(const char * str, const Simstr & S);
+bool operator<(const char * str, const Simstr & S);
+bool operator>(const char * str, const Simstr & S);
+bool operator<=(const char * str, const Simstr & S);
+bool operator>=(const char * str, const Simstr & S);
+
+
+inline const char *
+Simstr::str() const { return sz; }
+inline char *
+Simstr::s() { return sz; }
+inline int
+Simstr::l() const { return len; }
+inline
+Simstr::operator const char*() const { return sz; }
+inline bool
+Simstr::is_empty() const { return len == 0; }
+
+
+#endif
+
diff --git a/soltools/inc/st_gilrw.hxx b/soltools/inc/st_gilrw.hxx
new file mode 100644
index 000000000000..5213af3ae7e9
--- /dev/null
+++ b/soltools/inc/st_gilrw.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * $RCSfile: st_gilrw.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_ST_GILRW_HXX
+#define SOLTOOLS_ST_GILRW_HXX
+
+
+#include "gilacces.hxx"
+#include "st_list.hxx"
+
+class Simstr;
+class List_GenericInfo;
+class GenericInfo;
+class GenericInfo_Parser;
+
+class ST_InfoListReader : public GenericInfoParseTypes,
+ private GenericInfoList_Builder
+{
+ public:
+ // LIFECYCLE
+ ST_InfoListReader();
+ ~ST_InfoListReader();
+ // OPERATIONS
+ bool LoadList(
+ List_GenericInfo & o_rList,
+ const Simstr & i_sFileName );
+ // INFO
+ E_Error GetLastError(
+ UINT32 * o_pErrorLine = 0 ) const;
+ private:
+ // Interface GenericInfoList_Builder
+ virtual void AddKey(
+ const char * i_sKey,
+ UINT32 i_nKeyLength,
+ const char * i_sValue,
+ UINT32 i_nValueLength,
+ const char * i_sComment,
+ UINT32 i_nCommentLength );
+
+ virtual void OpenList();
+ virtual void CloseList();
+
+ // Forbid copies:
+ ST_InfoListReader( const ST_InfoListReader & );
+ ST_InfoListReader & operator=( const ST_InfoListReader & );
+
+ // DATA
+ GenericInfo_Parser *
+ dpParser;
+
+ ST_List< List_GenericInfo * >
+ aListStack;
+ GenericInfo * pCurKey;
+};
+
+class ST_InfoListWriter : public GenericInfoParseTypes,
+ private GenericInfoList_Browser
+{
+ public:
+ // LIFECYCLE
+ ST_InfoListWriter();
+ ~ST_InfoListWriter();
+ // OPERATIONS
+ bool SaveList(
+ const Simstr & i_sFileName,
+ List_GenericInfo & io_rList );
+
+ // INFO
+ E_Error GetLastError() const;
+
+ private:
+ // Interface GenericInfoList_Browser
+ virtual bool Start_CurList();
+ virtual bool NextOf_CurList();
+
+ virtual void Get_CurKey(
+ char * o_rKey ) const;
+ virtual void Get_CurValue(
+ char * o_rValue ) const;
+ virtual void Get_CurComment(
+ char * o_rComment ) const;
+ virtual bool HasSubList_CurKey() const;
+
+ virtual void Push_CurList();
+ virtual void Pop_CurList();
+
+ // Forbid copies:
+ ST_InfoListWriter( const ST_InfoListWriter & );
+ ST_InfoListWriter & operator=( const ST_InfoListWriter & );
+
+ // DATA
+ GenericInfo_Parser *
+ dpParser;
+
+ ST_List< List_GenericInfo * >
+ aListStack;
+ GenericInfo * pCurKey;
+};
+
+#endif
+
diff --git a/soltools/inc/st_list.hxx b/soltools/inc/st_list.hxx
new file mode 100644
index 000000000000..885ae862886d
--- /dev/null
+++ b/soltools/inc/st_list.hxx
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * $RCSfile: st_list.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_ST_LIST_HXX
+#define SOLTOOLS_ST_LIST_HXX
+
+#include <string.h>
+#include <iostream>
+#include <stdlib.h>
+
+template <class XX>
+class ST_List /// Soltools-List.
+{
+ public :
+ typedef XX * iterator;
+ typedef const XX * const_iterator;
+
+ // LIFECYCLE
+ ST_List();
+ ST_List(
+ const ST_List<XX> & i_rList );
+ virtual ~ST_List() { }
+
+ // OPERATORS
+ ST_List<XX> & operator=(
+ const ST_List<XX> & i_rList );
+
+ const XX & operator[](
+ unsigned n) const
+ { return elem(n); }
+ XX & operator[](
+ unsigned n)
+ { return elem(n); }
+ // OPERATIONS
+ void reserve(
+ unsigned i_nSize )
+ { alloc(i_nSize,true); }
+ void insert(
+ iterator i_aPos,
+ const XX & elem )
+ { Insert(i_aPos-begin(), elem); }
+ virtual void Insert(
+ unsigned pos,
+ const XX & elem );
+ void push_back(
+ const XX & elem)
+ { Insert(size(),elem); }
+ void remove(
+ iterator i_aPos )
+ { Remove(i_aPos-begin()); }
+ virtual void Remove(
+ unsigned pos );
+ void pop_back() { Remove(size()-1); }
+ void erase_all() { while (size()) Remove(size()-1); }
+
+ // INQUIRY
+ const_iterator begin() const { return &inhalt[0]; }
+ const_iterator end() const { return &inhalt[len]; }
+
+ const XX & front() const { return elem(0); }
+ const XX & back() const { return elem(len-1); }
+
+ unsigned size() const { return len; }
+ unsigned space() const { return allocated; }
+ bool is_valid_index(
+ unsigned n) const
+ { return n < len; }
+ // ACCESS
+ iterator begin() { return &inhalt[0]; }
+ iterator end() { return &inhalt[len]; }
+
+ XX & front() { return elem(0); }
+ XX & back() { return elem(len-1); }
+
+ protected:
+ void checkSize(
+ unsigned newLength);
+ void alloc(
+ unsigned newSpace,
+ bool re = false );
+
+ const XX & elem(
+ unsigned n ) const
+ { return inhalt[n]; }
+ XX & elem(
+ unsigned n )
+ { return inhalt[n]; }
+ // DATA
+ XX * inhalt;
+ unsigned len;
+ unsigned allocated;
+};
+
+
+
+template <class XY>
+class DynamicList : public ST_List< XY* >
+{
+ public:
+ DynamicList();
+ DynamicList(
+ const DynamicList<XY> &
+ i_rList );
+ virtual ~DynamicList(); /// Deletes all member pointers
+
+ DynamicList<XY> & operator=(
+ const DynamicList<XY> &
+ i_rList );
+
+ virtual void Insert(
+ unsigned pos,
+ XY * const & elem );
+ virtual void Remove(
+ unsigned pos );
+};
+
+
+
+template <class XX>
+ST_List<XX>::ST_List()
+ : len(0),
+ inhalt(0),
+ allocated(0)
+{
+ alloc(1);
+}
+
+template <class XX>
+ST_List<XX>::ST_List( const ST_List<XX> & i_rList )
+ : len(0),
+ inhalt(0),
+ allocated(0)
+{
+ alloc(i_rList.size());
+
+ for ( const_iterator it = i_rList.begin();
+ it != i_rList.end();
+ ++it )
+ {
+ push_back(*it);
+ }
+}
+
+template <class XX>
+ST_List<XX> &
+ST_List<XX>::operator=( const ST_List<XX> & i_rList )
+{
+ for ( const_iterator it = i_rList.begin();
+ it != i_rList.end();
+ ++it )
+ {
+ push_back(*it);
+ }
+ return *this;
+}
+
+template <class XX>
+void
+ST_List<XX>::Insert(unsigned pos, const XX & elem)
+{
+ if ( pos > len )
+ return;
+
+ checkSize(len+2);
+ for ( unsigned p = len; p > pos; --p)
+ {
+ inhalt[p] = inhalt[p-1];
+ }
+ inhalt[pos] = elem;
+ len++;
+}
+
+
+template <class XX>
+void
+ST_List<XX>::Remove(unsigned pos)
+{
+ if ( pos >= len )
+ return;
+ len--;
+ for ( unsigned p = pos; p < len; ++p)
+ {
+ inhalt[p] = inhalt[p+1];
+ }
+}
+
+
+// Protected:
+template <class XX>
+void
+ST_List<XX>::checkSize(unsigned newLength)
+{
+ // neuen Platzbedarf pruefen:
+ unsigned newSpace = space();
+ if (newLength >= newSpace)
+ {
+ if (!newSpace)
+ newSpace = 1;
+ const unsigned nBorder = 2000000000;
+ while(newLength >= newSpace)
+ {
+ if (newSpace < nBorder)
+ newSpace <<= 1;
+ else
+ {
+ std::cerr << "List becomes too big" << std::endl;
+ exit(1);
+ }
+ }
+ }
+
+ // Veraenderung ?:
+ if (newSpace != space())
+ alloc(newSpace,true);
+}
+
+template <class XX>
+void
+ST_List<XX>::alloc( unsigned newSpace,
+ bool re )
+{
+ XX * pNew = new XX[newSpace];
+
+ if (inhalt != 0)
+ {
+ if (re)
+ {
+ for (unsigned i = 0; i < len; ++i)
+ {
+ pNew[i] = inhalt[i];
+ } // end for
+ }
+ delete [] inhalt;
+ }
+
+ inhalt = pNew;
+ allocated = newSpace;
+}
+
+
+template <class XY>
+DynamicList<XY>::DynamicList()
+{
+}
+
+template <class XY>
+DynamicList<XY>::DynamicList( const DynamicList<XY> & i_rList )
+ : ST_List< XY* >(i_rList)
+{
+ for ( iterator it = begin();
+ it != end();
+ ++it )
+ {
+ // Copying the contents the pointers point at:
+ (*it) = new XY( *(*it) );
+ }
+}
+
+template <class XY>
+DynamicList<XY>::~DynamicList()
+{
+ erase_all();
+}
+
+template <class XY>
+DynamicList<XY> &
+DynamicList<XY>::operator=( const DynamicList<XY> & i_rList )
+{
+ for ( const_iterator it = i_rList.begin();
+ it != i_rList.end();
+ ++it )
+ {
+ push_back( new XY(*(*it)) );
+ }
+ return *this;
+}
+
+
+template <class XY>
+void
+DynamicList<XY>::Insert(unsigned pos, XY * const & elem)
+{
+ if ( pos > len )
+ return;
+
+ checkSize(len+2);
+ memmove( inhalt+pos+1, inhalt+pos, (len-pos) * sizeof(XY*) );
+ inhalt[pos] = elem;
+ len++;
+}
+
+template <class XY>
+void
+DynamicList<XY>::Remove( unsigned pos )
+{
+ if (!is_valid_index(pos) )
+ return;
+ len--;
+ delete inhalt[pos];
+ memmove(inhalt+pos, inhalt+pos+1, (len-pos) * sizeof(XY*) );
+}
+
+
+
+#endif
+
diff --git a/soltools/inc/st_types.hxx b/soltools/inc/st_types.hxx
new file mode 100644
index 000000000000..43bba9540b85
--- /dev/null
+++ b/soltools/inc/st_types.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * $RCSfile: st_types.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:17 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef SOLTOOLS_ST_TYPES_HXX
+#define SOLTOOLS_ST_TYPES_HXX
+
+typedef unsigned long UINT32;
+typedef long INT32;
+typedef unsigned short UINT16;
+typedef short INT16;
+
+
+
+
+#endif
+
diff --git a/soltools/support/makefile.mk b/soltools/support/makefile.mk
new file mode 100644
index 000000000000..297cb88f96a1
--- /dev/null
+++ b/soltools/support/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: np $ $Date: 2001-06-11 16:05:18 $
+#
+# 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_support
+TARGETTYPE=CUI
+
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= \
+ $(OBJ)$/simstr.obj
+
+
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+
diff --git a/soltools/support/simstr.cxx b/soltools/support/simstr.cxx
new file mode 100644
index 000000000000..aca6ddee7380
--- /dev/null
+++ b/soltools/support/simstr.cxx
@@ -0,0 +1,864 @@
+/*************************************************************************
+ *
+ * $RCSfile: simstr.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: np $ $Date: 2001-06-11 16:05:18 $
+ *
+ * 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 <simstr.hxx>
+
+#include <string.h> // strlen(), memcpy(), memset()
+#include <ctype.h> // tolower()
+#include <limits.h> // INT_MAX
+
+const char NULCH = '\0';
+const int NO_POS = -1;
+
+
+Simstr::Simstr(const char * str)
+{
+ if (str == 0)
+ {
+ len = 0;
+ sz = new char[1];
+ *sz = 0;
+ }
+ else
+ {
+ len = strlen(str);
+ sz = new char[len+1];
+ memcpy(sz,str,len+1);
+ }
+}
+
+Simstr::Simstr(const char * anybytes, int nrOfBytes)
+{
+ if (anybytes == 0)
+ {
+ len = 0;
+ sz = new char[1];
+ *sz = 0;
+ return;
+ }
+
+ int slen = static_cast<int>( strlen(anybytes) );
+
+ len = slen < nrOfBytes
+ ? slen
+ : nrOfBytes;
+ sz = new char[len+1];
+ memcpy( sz, anybytes, len );
+ *( sz + len ) = 0;
+}
+
+Simstr::Simstr(char c, int anzahl)
+{
+ if (anzahl < 1)
+ {
+ len = 0;
+ sz = new char[1];
+ *sz = 0;
+ }
+ else
+ {
+ len = anzahl;
+ sz = new char[len+1];
+ memset(sz,c,anzahl);
+ sz[len] = 0;
+ }
+}
+
+Simstr::Simstr( const char * anybytes,
+ int firstBytesPos,
+ int nrOfBytes)
+{
+ unsigned slen = strlen(anybytes);
+ if (anybytes == 0 || slen <= unsigned(firstBytesPos))
+ {
+ len = 0;
+ sz = new char[1];
+ *sz = 0;
+ }
+ else
+ {
+ int maxLen = slen - unsigned(firstBytesPos);
+ len = maxLen < nrOfBytes
+ ? maxLen
+ : nrOfBytes;
+ sz = new char[len+1];
+ memcpy(sz,anybytes+firstBytesPos,len);
+ *(sz+len) = 0;
+ }
+}
+
+
+Simstr::Simstr(const Simstr & S)
+{
+ len = S.len;
+ sz = new char[len+1];
+ memcpy(sz,S.sz,len+1);
+}
+
+Simstr & Simstr::operator=(const Simstr & S)
+{
+ if (sz == S.sz)
+ return *this;
+
+ delete [] sz;
+
+ len = S.len;
+ sz = new char[len+1];
+ memcpy(sz,S.sz,len+1);
+
+ return *this;
+}
+
+Simstr::~Simstr()
+{
+ delete [] sz;
+}
+
+char &
+Simstr::ch(int n)
+{
+ static char nullCh = NULCH;
+ nullCh = NULCH;
+ if (n >= long(len) || n < 0)
+ return nullCh;
+ else
+ return sz[unsigned(n)];
+}
+
+const Simstr &
+Simstr::null_()
+{
+ static Simstr aNull_;
+ return aNull_;
+}
+
+
+Simstr
+Simstr::operator+(const Simstr & S) const
+{
+ Simstr ret = sz;
+ ret.push_back(S);
+ return ret;
+}
+
+Simstr &
+Simstr::operator+=(const Simstr & S)
+{
+ push_back(S);
+ return *this;
+}
+
+Simstr &
+Simstr::operator+=(const char * s)
+{
+ Simstr a(s);
+ push_back(a);
+ return *this;
+}
+
+
+// REL
+
+bool
+Simstr::operator==(const Simstr & S) const
+{ return !strcmp(sz,S.sz) ? true : false; }
+
+bool
+Simstr::operator!=(const Simstr & S) const
+{ return strcmp(sz,S.sz) ? true : false; }
+
+bool
+Simstr::operator<(const Simstr & S) const
+{ return (strcmp(sz,S.sz) < 0) ? true : false; }
+
+bool
+Simstr::operator>(const Simstr & S) const
+{ return (strcmp(sz,S.sz) > 0) ? true : false; }
+
+bool
+Simstr::operator<=(const Simstr & S) const
+{ return (strcmp(sz,S.sz) <= 0) ? true : false; }
+
+bool
+Simstr::operator>=(const Simstr & S) const
+{ return (strcmp(sz,S.sz) >= 0) ? true : false; }
+
+
+
+
+// ************** LIST - Funktionen *****************
+
+
+// Einzelzugriff
+
+char
+Simstr::get(int n) const { return (n >= len || n < 0) ? 0 : sz[n]; }
+
+char
+Simstr::get_front() const { return sz[0]; }
+
+char
+Simstr::get_back() const { return len ? sz[len-1] : 0; }
+
+Simstr
+Simstr::get(int startPos, int anzahl) const
+{
+ if (startPos >= len || startPos < 0 || anzahl < 1)
+ return "";
+
+ int anz = len - startPos < anzahl ? len - startPos : anzahl;
+
+ Simstr ret(' ',anz);
+ memcpy(ret.sz, sz+startPos, anz);
+ return ret;
+}
+
+Simstr
+Simstr::get_front(int anzahl) const
+{
+ int anz = len < anzahl ? len : anzahl;
+ if (anz < 1)
+ return "";
+
+ Simstr ret(' ',anz);
+ memcpy(ret.sz, sz, anz);
+ return ret;
+}
+
+Simstr
+Simstr::get_back(int anzahl) const
+{
+ int anz = len < anzahl ? len : anzahl;
+ if (anz < 1)
+ return "";
+ int start = len-anz;
+
+ Simstr ret(' ',anz);
+ memcpy(ret.sz, sz+start, anz);
+ return ret;
+}
+
+Simstr
+Simstr::get_first_token(char c) const
+{
+ int posc = pos_first(c);
+ if (posc != NO_POS)
+ return get_front(posc);
+ else
+ return sz;
+}
+
+Simstr
+Simstr::get_last_token(char c) const
+{
+ int posc = pos_last(c);
+ if (posc != NO_POS)
+ return get_back(len-posc-1);
+ else
+ return sz;
+}
+
+
+
+// Insert
+
+void
+Simstr::insert(int pos, char c)
+{
+ if (pos < 0 || pos > len)
+ return;
+
+ char * result = new char[len+2];
+
+ memcpy(result,sz,pos);
+ result[pos] = c;
+ memcpy(result+pos+1,sz+pos,len-pos+1);
+
+ delete [] sz;
+ sz = result;
+ len++;
+}
+
+void
+Simstr::push_front(char c)
+{
+ char * result = new char[len+2];
+
+ result[0] = c;
+ memcpy(result+1,sz,len+1);
+
+ delete [] sz;
+ sz = result;
+ len++;
+}
+
+void
+Simstr::push_back(char c)
+{
+ char * result = new char[len+2];
+
+ memcpy(result,sz,len);
+ result[len] = c;
+ result[len+1] = 0;
+
+ delete [] sz;
+ sz = result;
+ len++;
+}
+
+void
+Simstr::insert(int pos, const Simstr & S)
+{
+ if (pos < 0 || pos > len)
+ return;
+
+ char * result = new char[len+1+S.len];
+
+ memcpy(result,sz,pos);
+ memcpy(result+pos,S.sz,S.len);
+ memcpy(result+pos+S.len,sz+pos,len-pos+1);
+
+ delete [] sz;
+ sz = result;
+ len += S.len;
+}
+
+void
+Simstr::push_front(const Simstr & S)
+{
+ char * result = new char[len+1+S.len];
+
+ memcpy(result,S.sz,S.len);
+ memcpy(result+S.len,sz,len+1);
+
+ delete [] sz;
+ sz = result;
+ len += S.len;
+}
+
+void
+Simstr::push_back(const Simstr & S)
+{
+ char * result = new char[len+1+S.len];
+
+ memcpy(result,sz,len);
+ memcpy(result+len,S.sz,S.len+1);
+
+ delete [] sz;
+ sz = result;
+ len += S.len;
+}
+
+
+// Remove
+
+void
+Simstr::remove(int pos, int anzahl)
+{
+ if (pos >= len || pos < 0 || anzahl < 1)
+ return;
+
+ int anz = len - pos < anzahl ? len - pos : anzahl;
+
+ char * result = new char[len-anz+1];
+
+ memcpy(result,sz,pos);
+ memcpy(result+pos,sz+pos+anz,len-pos-anz+1);
+
+ delete [] sz;
+ sz = result;
+ len -= anz;
+}
+
+void
+Simstr::remove_trailing_blanks()
+{
+ int newlen = len-1;
+ for ( ; newlen > 1 && sz[newlen] <= 32; --newlen ) {}
+
+ if (newlen < len-1)
+ remove ( newlen+1, len-newlen);
+}
+
+void
+Simstr::pop_front(int anzahl)
+{
+ if (anzahl < 1)
+ return;
+ int anz = len < anzahl ? len : anzahl;
+
+ char * result = new char[len-anz+1];
+
+ memcpy(result,sz+anz,len-anz+1);
+
+ delete [] sz;
+ sz = result;
+ len -= anz;
+}
+
+void
+Simstr::pop_back(int anzahl)
+{
+ if (anzahl < 1)
+ return;
+
+ int anz = len < anzahl ? len : anzahl;
+
+ char * result = new char[len-anz+1];
+
+ memcpy(result,sz,len-anz);
+ result[len-anz] = 0;
+
+ delete [] sz;
+ sz = result;
+ len -= anz;
+}
+
+void
+Simstr::rem_back_from(int removeStartPos)
+{
+ if (removeStartPos != NO_POS)
+ pop_back(len-removeStartPos);
+}
+
+void
+Simstr::remove_all(char c)
+{
+ if (!len)
+ return;
+ char * result = new char[len];
+ int i,j=0;
+ for (i = 0; i < len; i++)
+ if (sz[i] != c)
+ result[j++] = sz[i];
+
+ delete [] sz;
+ sz = new char[j+1];
+ memcpy(sz,result,j);
+ sz[j] = 0;
+ len = j;
+ delete [] result;
+}
+
+void
+Simstr::remove_all(const Simstr & S)
+{
+ int pos;
+ while ( (pos=pos_first(S)) != NO_POS )
+ remove(pos,S.len);
+}
+
+void
+Simstr::strip(char c)
+{
+ int start = 0;
+ if (c == ' ')
+ { // Sonderbehandlung: SPC entfernt auch TABs:
+ while ( start < len
+ ? sz[start] == ' '
+ || sz[start] == '\t'
+ : false )
+ start++;
+ }
+ else
+ {
+ while (start < len && sz[start] == c)
+ start++;
+ }
+
+ int ende = len-1;
+ if (c == ' ')
+ { // Sonderbehandlung: SPC entfernt auch TABs:
+ while ( ende >= start
+ ? sz[ende] == ' '
+ || sz[ende] == '\t'
+ : false )
+ ende--;
+ }
+ else
+ {
+ while (ende >= start && sz[ende] == c)
+ ende--;
+ }
+ *this = get(start,ende-start+1);
+}
+
+void
+Simstr::empty()
+{
+ if (len > 0)
+ {
+ delete [] sz;
+ sz = new char[1];
+ *sz = 0;
+ len = 0;
+ }
+}
+
+Simstr
+Simstr::take_first_token(char c)
+{
+ Simstr ret;
+ int pos = pos_first(c);
+ if (pos != NO_POS)
+ {
+ ret = get_front(pos);
+ pop_front(pos+1);
+ }
+ else
+ {
+ ret = sz;
+ delete [] sz;
+ sz = new char[1];
+ *sz = NULCH;
+ len = 0;
+ }
+
+ return ret;
+}
+
+Simstr
+Simstr::take_last_token(char c)
+{
+ Simstr ret;
+ int pos = pos_last(c);
+ if (pos != NO_POS)
+ {
+ ret = get_back(len-pos-1);
+ pop_back(len-pos);
+ }
+ else
+ {
+ ret = sz;
+ delete [] sz;
+ sz = new char[1];
+ *sz = NULCH;
+ len = 0;
+ }
+
+ return ret;
+}
+
+
+
+// Find
+
+int
+Simstr::pos_first(char c) const
+{
+ int i = 0;
+ for (i = 0; i < len ? sz[i] != c : false; i++);
+ if (i >= len)
+ return NO_POS;
+ else
+ return i;
+}
+
+int
+Simstr::pos_first_after( char c,
+ int startSearchPos) const
+{
+ int i = 0;
+ if (startSearchPos >= i)
+ i = startSearchPos+1;
+ for (; i < len ? sz[i] != c : false; i++);
+ if (i >= len)
+ return NO_POS;
+ else
+ return i;
+}
+
+
+int
+Simstr::pos_last(char c) const
+{
+ int i = 0;
+ for (i = len-1; i >= 0 ? sz[i] != c : false; i--);
+ if (i < 0)
+ return NO_POS;
+ else
+ return i;
+}
+
+int
+Simstr::pos_first(const Simstr & S) const
+{
+ char * ptr = strstr(sz,S.sz);
+ if (ptr)
+ return int(ptr-sz);
+ else
+ return NO_POS;
+}
+
+int
+Simstr::pos_last(const Simstr & S) const
+{
+ Simstr vgl;
+ int i;
+ for (i = len-S.len; i >= 0 ; i--)
+ {
+ vgl = get(i,S.len);
+ if (vgl == S)
+ break;
+ }
+ if (i >= 0)
+ return i;
+ else
+ return NO_POS;
+}
+
+int
+Simstr::count(char c) const
+{
+ int ret = 0;
+ for (int i =0; i < len; i++)
+ if (sz[i] == c)
+ ret++;
+ return ret;
+}
+
+bool
+Simstr::is_no_text() const
+{
+ if (!len)
+ return true;
+
+ int i;
+ for (i = 0; sz[i] <= 32 && i < len; i++);
+ if (i < len)
+ return false;
+ return true;
+}
+
+// Change
+
+void
+Simstr::replace(int pos, char c)
+{
+ if (pos < 0 || pos >= len)
+ return;
+ else
+ sz[unsigned(pos)] = c;
+}
+
+void
+Simstr::replace(int startPos, int anzahl, const Simstr & S)
+{
+ if (startPos >= len || startPos < 0 || anzahl < 1)
+ return;
+
+ int anz = len - startPos < anzahl ? len - startPos : anzahl;
+
+ char * result = new char[len-anz+S.len+1];
+
+ memcpy(result,sz,startPos);
+ memcpy(result+startPos, S.sz, S.len);
+ memcpy(result+startPos+S.len, sz+startPos+anz, len-startPos-anz+1);
+
+ delete [] sz;
+ sz = result;
+ len = len-anz+S.len;
+}
+
+void
+Simstr::replace_all(char oldCh, char newCh)
+{
+ for (int i=0; i < len; i++)
+ if (sz[i] == oldCh)
+ sz[i] = newCh;
+}
+
+void
+Simstr::replace_all(const Simstr & oldS, const Simstr & newS)
+{
+ Simstr vgl;
+ int i = 0;
+ while (i <= len-oldS.len)
+ {
+ vgl = get(i,oldS.len);
+ if (strcmp(vgl.sz,oldS.sz) == 0)
+ {
+ replace(i,oldS.len,newS);
+ i += newS.len;
+ }
+ else
+ i++;
+ }
+}
+
+void
+Simstr::to_lower()
+{
+ for (int i = 0; i < len; i++)
+ sz[i] = (char) tolower(sz[i]);
+}
+
+
+
+// Simstr addition
+Simstr
+operator+(const char * str, const Simstr & S)
+{
+ Simstr ret = S;
+ ret.push_front(str);
+ return ret;
+}
+
+Simstr
+operator+(const Simstr & S, const char * str)
+{
+ Simstr ret = S;
+ ret.push_back(str);
+ return ret;
+}
+
+Simstr
+operator+(char c, const Simstr & S)
+{
+ Simstr ret = S;
+ ret.push_front(c);
+ return ret;
+}
+
+Simstr
+operator+(const Simstr & S, char c)
+{
+ Simstr ret = S;
+ ret.push_back(c);
+ return ret;
+}
+
+
+// Simstr-Vergleiche mit char *
+bool
+operator==(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) == 0;
+}
+
+bool
+operator!=(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) != 0;
+}
+
+bool
+operator<(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) < 0;
+}
+
+bool
+operator>(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) > 0;
+}
+
+bool
+operator<=(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) <= 0;
+}
+
+bool
+operator>=(const Simstr & S, const char * str)
+{
+ return strcmp(S,str) >= 0;
+}
+
+bool
+operator==(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) == 0;
+}
+
+bool
+operator!=(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) != 0;
+}
+
+bool
+operator<(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) < 0;
+}
+
+bool
+operator>(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) > 0;
+}
+
+bool
+operator<=(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) <= 0;
+}
+
+bool
+operator>=(const char * str, const Simstr & S)
+{
+ return strcmp(str,S) >= 0;
+}
+
+