summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-03-25 14:16:27 +0000
committerOliver Bolte <obo@openoffice.org>2008-03-25 14:16:27 +0000
commit003d34e3c30c1e7dc1f08f7737cedef79be3b15f (patch)
tree67483ba61721b32862ac9a0eed366169ca5d972d /xmlhelp
parentd9b65dc3e392bf12eba106e3792e5e25051df837 (diff)
INTEGRATION: CWS ucbfixes06 (1.1.2); FILE ADDED
2008/01/21 15:30:19 kso 1.1.2.1: #i85425# - cleanup of CVS module.
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/Block.hxx130
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/BlockFactory.hxx59
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/BlockManager.hxx174
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/BtreeDict.hxx126
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/DBEnv.hxx73
-rw-r--r--xmlhelp/source/cxxhelp/inc/db/EntryProcessor.hxx60
6 files changed, 622 insertions, 0 deletions
diff --git a/xmlhelp/source/cxxhelp/inc/db/Block.hxx b/xmlhelp/source/cxxhelp/inc/db/Block.hxx
new file mode 100644
index 000000000000..0a9538968154
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/Block.hxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Block.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:15:19 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_BLOCK_HXX_
+#define _XMLSEARCH_DB_BLOCK_HXX_
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace util {
+
+ class RandomAccessStream;
+
+ }
+
+ namespace db {
+
+
+ class DBEnv;
+
+
+ class Block // refcounted class
+ {
+ public:
+
+ Block( const DBEnv* );
+ virtual ~Block();
+
+ void setInteger( sal_Int32 i,sal_Int32 value ) throw( xmlsearch::excep::IllegalIndexException );
+ sal_Int32 getInteger( sal_Int32 i ) const throw( xmlsearch::excep::IllegalIndexException );
+
+ void trueLeaf() { isLeaf_ = true; }
+ void falseLeaf() { isLeaf_ = false; }
+ bool isLeaf() const { return isLeaf_; }
+
+ void setFree( sal_Int32 free ) { free_ = free; }
+ sal_Int32 getFree() const { return free_; }
+
+ void setNum( sal_Int32 num ) { num_ = num; }
+ sal_Int32 getNum() const { return num_; }
+
+ void read( util::RandomAccessStream* in );
+ void write( util::RandomAccessStream* out ) const;
+
+ const sal_Int8* getData() const { return data_; }
+
+
+ protected:
+
+ const DBEnv* dbenv_; // not owner
+
+
+ private:
+
+ bool isLeaf_;
+ sal_Int32 free_;
+ sal_Int32 num_;
+ sal_Int32 dataL_;
+ sal_Int8* data_;
+
+ // methods
+
+ Block( const Block& );
+ Block& operator=( const Block& );
+
+ }; // end class Block
+
+
+ }
+}
+
+
+inline sal_Int32 getInteger_( const sal_Int8* v )
+{
+ return (((((( v[0]&0xFF ) << 8 )
+ | v[1]&0xFF ) << 8 )
+ | v[2]&0xFF ) << 8 )
+ | v[3]&0xFF;
+}
+
+
+
+inline void setInteger_( sal_Int8* v,sal_Int32 value )
+{
+ v[0] = sal_Int8((value >> 24) & 0xFF);
+ v[1] = sal_Int8((value >> 16) & 0xFF);
+ v[2] = sal_Int8((value >> 8) & 0xFF);
+ v[3] = sal_Int8( value & 0xFF );
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/db/BlockFactory.hxx b/xmlhelp/source/cxxhelp/inc/db/BlockFactory.hxx
new file mode 100644
index 000000000000..d88f0f05e34c
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/BlockFactory.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BlockFactory.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:15:32 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_BLOCKFACTORY_HXX_
+#define _XMLSEARCH_DB_BLOCKFACTORY_HXX_
+
+namespace xmlsearch {
+
+ namespace db {
+
+
+ class Block;
+
+
+ class BlockFactory
+ {
+ public:
+
+ virtual ~BlockFactory() { }
+ virtual Block* makeBlock() const = 0;
+ };
+
+
+ }
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/db/BlockManager.hxx b/xmlhelp/source/cxxhelp/inc/db/BlockManager.hxx
new file mode 100644
index 000000000000..00052a09941c
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/BlockManager.hxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BlockManager.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:15:50 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_BLOCKMANAGER_HXX_
+#define _XMLSEARCH_DB_BLOCKMANAGER_HXX_
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _XMLSEARCH_DB_BLOCK_HXX_
+#include <db/Block.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_BLOCKFACTORY_HXX_
+#include <db/BlockFactory.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_DBENV_HXX_
+#include <db/DBEnv.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+
+namespace xmlsearch {
+
+ namespace util {
+
+ class RandomAccessStream;
+
+ }
+
+ namespace db {
+
+
+ class BlockDecoratour // internal class for BlockManager
+ {
+ public:
+
+ BlockDecoratour()
+ : lock_( false ),
+ modf_( false ),
+ prev_( 0 ),
+ next_( 0 ),
+ block_( 0 )
+ {
+ }
+
+ ~BlockDecoratour() { delete block_; }
+
+ void lock() { lock_ = true; }
+ void unlock() { lock_ = false; }
+ bool isLocked() const { return lock_; }
+
+ bool isModf() const { return modf_; }
+ void modf() { modf_ = true; }
+
+ void next( sal_Int32 parnext ) { next_ = parnext; }
+ sal_Int32 next() const { return next_; }
+ void prev( sal_Int32 parprev ) { prev_ = parprev; }
+ sal_Int32 prev() const { return prev_; }
+
+ void read( DBEnv* dbenv,sal_Int32 blNum ) { dbenv->read( blNum,block_ ); }
+ void write(DBEnv* dbenv,sal_Int32 blNum ) { dbenv->write( blNum,block_ ); }
+
+ Block* reset() { lock_ = modf_ = false; prev_ = next_ = 0; Block* tmp = block_; block_ = 0; return tmp; }
+ void add( Block* block ) { delete block_; block_ = block; }
+ bool is() const { return block_ != 0; }
+
+ const Block* getBlock() const { return block_; }
+
+ private:
+
+ bool lock_;
+ bool modf_;
+ sal_Int32 prev_;
+ sal_Int32 next_;
+ Block* block_;
+
+ };
+
+
+
+ class BlockProcessor
+ {
+ public:
+
+ virtual void process( Block* block ) const = 0;
+ virtual ~BlockProcessor() {}
+ };
+
+
+ class BlockManager
+ {
+ public:
+
+ // Buffered mapping of stream into memory
+
+ BlockManager( DBEnv* ) throw( xmlsearch::excep::IOException );
+ virtual ~BlockManager();
+
+ // From BlockManagerBase
+ virtual void lock( sal_Int32 blNum ) throw( xmlsearch::excep::IllegalIndexException );
+ virtual void unlock( sal_Int32 blNum ) throw( xmlsearch::excep::IllegalIndexException );
+ virtual bool isLocked( sal_Int32 blNum ) throw( xmlsearch::excep::IllegalIndexException );
+
+ virtual void modf( sal_Int32 blNum ) throw( xmlsearch::excep::IllegalIndexException );
+ virtual void close() throw( xmlsearch::excep::IOException );
+
+ virtual const Block* accessBlock( sal_Int32 blNum ) throw( xmlsearch::excep::NoSuchBlock );
+ virtual void mapBlocks( const BlockProcessor& blProc );
+
+
+ private:
+
+ // types
+
+ xmlsearch::db::DBEnv* dbenv_;
+
+ sal_Int32 oldest_;
+ sal_Int32 newest_;
+ BlockDecoratour dummy_;
+ sal_Int32 blockused_;
+ std::vector< BlockDecoratour > blockTable_;
+
+
+ // private methods
+
+ void moveToFront( sal_Int32 index );
+ void mapStorage2Memory( sal_Int32 blNum ) throw( xmlsearch::excep::IOException );
+ void remap( sal_Int32 blNum ) throw( xmlsearch::excep::XmlSearchException );
+ void add( sal_Int32 blNum );
+ };
+
+
+ }
+}
+
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/db/BtreeDict.hxx b/xmlhelp/source/cxxhelp/inc/db/BtreeDict.hxx
new file mode 100644
index 000000000000..044f224cd10e
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/BtreeDict.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BtreeDict.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:16:02 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_BTREEDICT_HXX_
+#define _XMLSEARCH_DB_BTREEDICT_HXX_
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _RTL_USTRING_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_BLOCKMANAGER_HXX_
+#include <db/BlockManager.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_ENTRYPROCESSOR_HXX_
+#include <db/EntryProcessor.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_INDEXACCESSOR_HXX_
+#include <util/IndexAccessor.hxx>
+#endif
+
+namespace xmlsearch {
+
+ namespace db {
+
+
+ class DictBlock;
+ class DBEnv;
+
+
+ class BtreeDict
+ {
+ public:
+
+ static const sal_Int32 ENTHEADERLEN;
+ static const sal_Int32 BLOCKSIZE;
+ static const sal_Int32 HEADERLEN;
+ static const sal_Int32 DATALEN;
+
+ static const sal_Int32 nBlocksLimit;
+ static const sal_Int32 MaxKeyLength;
+ static const sal_Int32 lastPtrIndex; //!!! Careful with that number, Eugene
+
+ BtreeDict( const xmlsearch::util::IndexAccessor& indexAccessor )
+ throw( xmlsearch::excep::IOException );
+ ~BtreeDict();
+
+ void lock( sal_Int32 blNum ) const throw( xmlsearch::excep::IllegalIndexException );
+ void unlock( sal_Int32 blNum ) const throw( xmlsearch::excep::IllegalIndexException );
+ bool isLocked( sal_Int32 blNum ) const throw( xmlsearch::excep::IllegalIndexException );
+
+ const DictBlock* accessBlock( sal_Int32 id ) const;
+
+ sal_Int32 fetch( const rtl::OUString& key ) const throw( xmlsearch::excep::XmlSearchException );
+ rtl::OUString fetch( sal_Int32 conceptID ) const throw( xmlsearch::excep::XmlSearchException );
+
+ std::vector< sal_Int32 > withPrefix( const rtl::OUString& prefix ) const throw( xmlsearch::excep::XmlSearchException );
+ sal_Int32* get_blocks() const { return blocks_; }
+
+ void test();
+
+ private:
+
+ mutable BlockManager blockManager_;
+ sal_Int32 root_;
+ sal_Int32 blocksL_;
+ sal_Int32* blocks_;
+
+ sal_Int32 find( const DictBlock* bl,
+ const sal_Int8* key,
+ sal_Int32 inputKeyLen ) const throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 find( const DictBlock* bl,
+ const sal_Int8* key,
+ sal_Int32 inputKeyLen,
+ sal_Int32 index ) const throw( xmlsearch::excep::XmlSearchException );
+
+ const DictBlock* child( const DictBlock* bl,
+ sal_Int32 index) const throw( xmlsearch::excep::XmlSearchException );
+
+ rtl::OUString findID( sal_Int32 blNum,sal_Int32 id ) const throw( xmlsearch::excep::XmlSearchException );
+
+ };
+
+
+ }
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/db/DBEnv.hxx b/xmlhelp/source/cxxhelp/inc/db/DBEnv.hxx
new file mode 100644
index 000000000000..20faa8709d2d
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/DBEnv.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DBEnv.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:16:15 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_DBENV_HXX_
+#define _XMLSEARCH_DB_DBENV_HXX_
+
+namespace xmlsearch {
+
+ namespace db {
+
+
+ class Block;
+
+
+ // environment class for a DBEnv
+
+ class DBEnv
+ {
+ public:
+
+ virtual sal_Int32 getEntryHeaderLen() const = 0;
+
+ virtual sal_Int32 getBlockCount() const = 0;
+
+ virtual sal_Int32 getMaximumBlockCount() const = 0;
+
+ virtual sal_Int32 getDataLen() const = 0;
+
+ virtual sal_Int32 getBlockLen() const = 0;
+
+ virtual void read( sal_Int32 block,Block*& ) const = 0;
+
+ virtual void write( sal_Int32,Block* ) = 0;
+ };
+
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/db/EntryProcessor.hxx b/xmlhelp/source/cxxhelp/inc/db/EntryProcessor.hxx
new file mode 100644
index 000000000000..443a485a1de6
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/db/EntryProcessor.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: EntryProcessor.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:16:27 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 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
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_ENTRYPROCESSOR_HXX_
+#define _XMLSEARCH_DB_ENTRYPROCESSOR_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring>
+#endif
+
+namespace xmlsearch {
+
+ namespace db {
+
+
+ class EntryProcessor
+ {
+ public:
+
+ virtual ~EntryProcessor() = 0;
+ virtual void processEntry( rtl::OUString string,sal_Int32 id ) = 0;
+ };
+
+
+ }
+}
+
+
+#endif