diff options
Diffstat (limited to 'soltools/inc')
-rw-r--r-- | soltools/inc/gen_info.hxx | 92 | ||||
-rw-r--r-- | soltools/inc/gi_list.hxx | 218 | ||||
-rw-r--r-- | soltools/inc/gi_parse.hxx | 168 | ||||
-rw-r--r-- | soltools/inc/gilacces.hxx | 107 | ||||
-rw-r--r-- | soltools/inc/pch/precompiled_soltools.cxx | 32 | ||||
-rw-r--r-- | soltools/inc/pch/precompiled_soltools.hxx | 35 | ||||
-rw-r--r-- | soltools/inc/simstr.hxx | 226 | ||||
-rw-r--r-- | soltools/inc/st_gilrw.hxx | 128 | ||||
-rw-r--r-- | soltools/inc/st_list.hxx | 333 | ||||
-rw-r--r-- | soltools/inc/st_types.hxx | 43 |
10 files changed, 1382 insertions, 0 deletions
diff --git a/soltools/inc/gen_info.hxx b/soltools/inc/gen_info.hxx new file mode 100644 index 000000000000..31e6306fba5e --- /dev/null +++ b/soltools/inc/gen_info.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gen_info.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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; } + + const List_GenericInfo & + SubList() const { return HasSubList() ? *dpSubList : CreateMyList(); } + // ACCESS + 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..4d8baf77222f --- /dev/null +++ b/soltools/inc/gi_list.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gi_list.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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_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(); + 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() + : it(0) { } + +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() + : it(0) { } + +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..4d81e2d61666 --- /dev/null +++ b/soltools/inc/gi_parse.hxx @@ -0,0 +1,168 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gi_parse.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#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(); + 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; + + char * dpBuffer; + char * sFilePtr; +}; + + +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..9ccd651c0c03 --- /dev/null +++ b/soltools/inc/gilacces.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gilacces.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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/pch/precompiled_soltools.cxx b/soltools/inc/pch/precompiled_soltools.cxx new file mode 100644 index 000000000000..4ba03f51c6ba --- /dev/null +++ b/soltools/inc/pch/precompiled_soltools.cxx @@ -0,0 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: precompiled_soltools.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_soltools.hxx" + diff --git a/soltools/inc/pch/precompiled_soltools.hxx b/soltools/inc/pch/precompiled_soltools.hxx new file mode 100644 index 000000000000..662818e7db12 --- /dev/null +++ b/soltools/inc/pch/precompiled_soltools.hxx @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: precompiled_soltools.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:50:01.811113 + +#ifdef PRECOMPILED_HEADERS +#endif + diff --git a/soltools/inc/simstr.hxx b/soltools/inc/simstr.hxx new file mode 100644 index 000000000000..34984485ef93 --- /dev/null +++ b/soltools/inc/simstr.hxx @@ -0,0 +1,226 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: simstr.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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..725fa1d4811f --- /dev/null +++ b/soltools/inc/st_gilrw.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: st_gilrw.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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..d87a232b2310 --- /dev/null +++ b/soltools/inc/st_list.hxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: st_list.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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() + : inhalt(0), + len(0), + allocated(0) +{ + alloc(1); +} + +template <class XX> +ST_List<XX>::ST_List( const ST_List<XX> & i_rList ) + : inhalt(0), + len(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 ( typename DynamicList<XY>::iterator it = this->begin(); + it != DynamicList<XY>::end(); + ++it ) + { + // Copying the contents the pointers point at: + (*it) = new XY( *(*it) ); + } +} + +template <class XY> +DynamicList<XY>::~DynamicList() +{ + this->erase_all(); +} + +template <class XY> +DynamicList<XY> & +DynamicList<XY>::operator=( const DynamicList<XY> & i_rList ) +{ + for ( typename DynamicList<XY>::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 > this->len ) + return; + + checkSize(DynamicList<XY>::len+2); + memmove( DynamicList<XY>::inhalt+pos+1, DynamicList<XY>::inhalt+pos, (DynamicList<XY>::len-pos) * sizeof(XY*) ); + this->inhalt[pos] = elem_; + this->len++; +} + +template <class XY> +void +DynamicList<XY>::Remove( unsigned pos ) +{ + if (!this->is_valid_index(pos) ) + return; + this->len--; + delete DynamicList<XY>::inhalt[pos]; + memmove(DynamicList<XY>::inhalt+pos, DynamicList<XY>::inhalt+pos+1, (DynamicList<XY>::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..b64df4b54fb3 --- /dev/null +++ b/soltools/inc/st_types.hxx @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: st_types.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#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 + |