xref: /aoo41x/main/store/source/stordata.hxx (revision 1a5fa39b)
1*1a5fa39bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1a5fa39bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1a5fa39bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1a5fa39bSAndrew Rist  * distributed with this work for additional information
6*1a5fa39bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1a5fa39bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1a5fa39bSAndrew Rist  * "License"); you may not use this file except in compliance
9*1a5fa39bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1a5fa39bSAndrew Rist  *
11*1a5fa39bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1a5fa39bSAndrew Rist  *
13*1a5fa39bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1a5fa39bSAndrew Rist  * software distributed under the License is distributed on an
15*1a5fa39bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1a5fa39bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*1a5fa39bSAndrew Rist  * specific language governing permissions and limitations
18*1a5fa39bSAndrew Rist  * under the License.
19*1a5fa39bSAndrew Rist  *
20*1a5fa39bSAndrew Rist  *************************************************************/
21*1a5fa39bSAndrew Rist 
22*1a5fa39bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _STORE_STORDATA_HXX_
25cdf0e10cSrcweir #define _STORE_STORDATA_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/types.h"
28cdf0e10cSrcweir #include "sal/macros.h"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "store/types.h"
31cdf0e10cSrcweir #include "storbase.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace store
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir /*========================================================================
37cdf0e10cSrcweir  *
38cdf0e10cSrcweir  * OStoreDataPageData.
39cdf0e10cSrcweir  *
40cdf0e10cSrcweir  *======================================================================*/
41cdf0e10cSrcweir #define STORE_MAGIC_DATAPAGE sal_uInt32(0x94190310)
42cdf0e10cSrcweir 
43cdf0e10cSrcweir struct OStoreDataPageData : public store::OStorePageData
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	typedef OStorePageData       base;
46cdf0e10cSrcweir 	typedef OStoreDataPageData   self;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	typedef OStorePageDescriptor D;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	/** Representation.
51cdf0e10cSrcweir 	*/
52cdf0e10cSrcweir 	sal_uInt8 m_pData[1];
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     /** type.
55cdf0e10cSrcweir      */
56cdf0e10cSrcweir     static const sal_uInt32 theTypeId = STORE_MAGIC_DATAPAGE;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	/** size.
59cdf0e10cSrcweir 	*/
60cdf0e10cSrcweir     static const size_t     theSize     = 0;
61cdf0e10cSrcweir     static const sal_uInt16 thePageSize = base::theSize + self::theSize;
62cdf0e10cSrcweir     STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	/** capacity.
65cdf0e10cSrcweir 	*/
capacitystore::OStoreDataPageData66cdf0e10cSrcweir 	static sal_uInt16 capacity (const D& rDescr) // @see inode::ChunkDescriptor
67cdf0e10cSrcweir 	{
68cdf0e10cSrcweir 		return (store::ntohs(rDescr.m_nSize) - self::thePageSize);
69cdf0e10cSrcweir 	}
capacitystore::OStoreDataPageData70cdf0e10cSrcweir 	sal_uInt16 capacity() const
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		return self::capacity (base::m_aDescr);
73cdf0e10cSrcweir 	}
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	/** usage.
76cdf0e10cSrcweir 	*/
usagestore::OStoreDataPageData77cdf0e10cSrcweir 	sal_uInt16 usage() const
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		return (store::ntohs(base::m_aDescr.m_nUsed) - self::thePageSize);
80cdf0e10cSrcweir 	}
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	/** Construction.
83cdf0e10cSrcweir 	*/
OStoreDataPageDatastore::OStoreDataPageData84cdf0e10cSrcweir 	explicit OStoreDataPageData (sal_uInt16 nPageSize = self::thePageSize)
85cdf0e10cSrcweir 		: base (nPageSize)
86cdf0e10cSrcweir 	{
87cdf0e10cSrcweir 		base::m_aGuard.m_nMagic = store::htonl(self::theTypeId);
88cdf0e10cSrcweir 		base::m_aDescr.m_nUsed  = store::htons(self::thePageSize);
89cdf0e10cSrcweir 		if (capacity()) memset (m_pData, 0, capacity());
90cdf0e10cSrcweir 	}
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	/** guard (external representation).
93cdf0e10cSrcweir 	*/
guardstore::OStoreDataPageData94cdf0e10cSrcweir 	void guard() {}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	/** verify (external representation).
97cdf0e10cSrcweir 	*/
verifystore::OStoreDataPageData98cdf0e10cSrcweir 	storeError verify() const { return store_E_None; }
99cdf0e10cSrcweir };
100cdf0e10cSrcweir 
101cdf0e10cSrcweir /*========================================================================
102cdf0e10cSrcweir  *
103cdf0e10cSrcweir  * OStoreDataPageObject.
104cdf0e10cSrcweir  *
105cdf0e10cSrcweir  *======================================================================*/
106cdf0e10cSrcweir class OStoreDataPageObject : public store::OStorePageObject
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	typedef OStorePageObject     base;
109cdf0e10cSrcweir 	typedef OStoreDataPageData   page;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir public:
112cdf0e10cSrcweir 	/** Construction.
113cdf0e10cSrcweir 	*/
OStoreDataPageObject(PageHolder const & rxPage=PageHolder ())114cdf0e10cSrcweir 	explicit OStoreDataPageObject (PageHolder const & rxPage = PageHolder())
115cdf0e10cSrcweir         : OStorePageObject (rxPage)
116cdf0e10cSrcweir     {}
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	/** External representation.
119cdf0e10cSrcweir 	 */
120cdf0e10cSrcweir     virtual storeError guard  (sal_uInt32 nAddr);
121cdf0e10cSrcweir     virtual storeError verify (sal_uInt32 nAddr) const;
122cdf0e10cSrcweir };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir /*========================================================================
125cdf0e10cSrcweir  *
126cdf0e10cSrcweir  * OStoreIndirectionPageData.
127cdf0e10cSrcweir  *
128cdf0e10cSrcweir  *======================================================================*/
129cdf0e10cSrcweir #define STORE_MAGIC_INDIRECTPAGE sal_uInt32(0x89191107)
130cdf0e10cSrcweir 
131cdf0e10cSrcweir struct OStoreIndirectionPageData : public store::OStorePageData
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	typedef OStorePageData            base;
134cdf0e10cSrcweir 	typedef OStoreIndirectionPageData self;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	typedef OStorePageGuard           G;
137cdf0e10cSrcweir 	typedef OStorePageDescriptor      D;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	/** Representation.
140cdf0e10cSrcweir 	*/
141cdf0e10cSrcweir 	G          m_aGuard;
142cdf0e10cSrcweir 	sal_uInt32 m_pData[1];
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     /** type.
145cdf0e10cSrcweir      */
146cdf0e10cSrcweir     static const sal_uInt32 theTypeId = STORE_MAGIC_INDIRECTPAGE;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	/** size.
149cdf0e10cSrcweir      */
150cdf0e10cSrcweir     static const size_t     theSize     = sizeof(G);
151cdf0e10cSrcweir     static const sal_uInt16 thePageSize = base::theSize + self::theSize;
152cdf0e10cSrcweir     STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	/** capacity.
155cdf0e10cSrcweir 	*/
capacitystore::OStoreIndirectionPageData156cdf0e10cSrcweir 	static sal_uInt16 capacity (const D& rDescr)
157cdf0e10cSrcweir 	{
158cdf0e10cSrcweir 		return (store::ntohs(rDescr.m_nSize) - self::thePageSize);
159cdf0e10cSrcweir 	}
capacitystore::OStoreIndirectionPageData160cdf0e10cSrcweir 	sal_uInt16 capacity() const
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		return self::capacity (base::m_aDescr);
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	/** capacityCount.
166cdf0e10cSrcweir 	*/
capacityCountstore::OStoreIndirectionPageData167cdf0e10cSrcweir 	static sal_uInt16 capacityCount (const D& rDescr) // @see DirectoryPageObject::scope()
168cdf0e10cSrcweir 	{
169cdf0e10cSrcweir 		return sal_uInt16(capacity(rDescr) / sizeof(sal_uInt32));
170cdf0e10cSrcweir 	}
capacityCountstore::OStoreIndirectionPageData171cdf0e10cSrcweir 	sal_uInt16 capacityCount() const
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		return sal_uInt16(capacity() / sizeof(sal_uInt32));
174cdf0e10cSrcweir 	}
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	/** Construction.
177cdf0e10cSrcweir 	*/
OStoreIndirectionPageDatastore::OStoreIndirectionPageData178cdf0e10cSrcweir 	explicit OStoreIndirectionPageData (sal_uInt16 nPageSize)
179cdf0e10cSrcweir 		: base (nPageSize)
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		base::m_aGuard.m_nMagic = store::htonl(self::theTypeId);
182cdf0e10cSrcweir 		base::m_aDescr.m_nUsed  = store::htons(self::thePageSize);
183cdf0e10cSrcweir 		self::m_aGuard.m_nMagic = store::htonl(0);
184cdf0e10cSrcweir 		memset (m_pData, STORE_PAGE_NULL, capacity());
185cdf0e10cSrcweir 	}
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	/** guard (external representation).
188cdf0e10cSrcweir 	*/
guardstore::OStoreIndirectionPageData189cdf0e10cSrcweir 	void guard()
190cdf0e10cSrcweir 	{
191cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
192cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
193cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, m_pData, capacity());
194cdf0e10cSrcweir 		m_aGuard.m_nCRC32 = store::htonl(nCRC32);
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	/** verify (external representation).
198cdf0e10cSrcweir 	*/
verifystore::OStoreIndirectionPageData199cdf0e10cSrcweir 	storeError verify() const
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
202cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
203cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, m_pData, capacity());
204cdf0e10cSrcweir 		if (m_aGuard.m_nCRC32 != store::htonl(nCRC32))
205cdf0e10cSrcweir 			return store_E_InvalidChecksum;
206cdf0e10cSrcweir 		else
207cdf0e10cSrcweir 			return store_E_None;
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir };
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*========================================================================
212cdf0e10cSrcweir  *
213cdf0e10cSrcweir  * OStoreIndirectionPageObject.
214cdf0e10cSrcweir  *
215cdf0e10cSrcweir  *======================================================================*/
216cdf0e10cSrcweir class OStoreIndirectionPageObject : public store::OStorePageObject
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	typedef OStorePageObject          base;
219cdf0e10cSrcweir 	typedef OStoreIndirectionPageData page;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir public:
222cdf0e10cSrcweir 	/** Construction.
223cdf0e10cSrcweir 	*/
OStoreIndirectionPageObject(PageHolder const & rxPage=PageHolder ())224cdf0e10cSrcweir     explicit OStoreIndirectionPageObject (PageHolder const & rxPage = PageHolder())
225cdf0e10cSrcweir         : OStorePageObject (rxPage)
226cdf0e10cSrcweir     {}
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	/** External representation.
229cdf0e10cSrcweir 	*/
230cdf0e10cSrcweir     storeError loadOrCreate (
231cdf0e10cSrcweir         sal_uInt32       nAddr,
232cdf0e10cSrcweir         OStorePageBIOS & rBIOS);
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     virtual storeError guard  (sal_uInt32 nAddr);
235cdf0e10cSrcweir     virtual storeError verify (sal_uInt32 nAddr) const;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	/** read (indirect data page).
238cdf0e10cSrcweir 	*/
239cdf0e10cSrcweir 	storeError read (
240cdf0e10cSrcweir 		sal_uInt16             nSingle,
241cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
242cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	storeError read (
245cdf0e10cSrcweir 		sal_uInt16             nDouble,
246cdf0e10cSrcweir 		sal_uInt16             nSingle,
247cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
248cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	storeError read (
251cdf0e10cSrcweir 		sal_uInt16             nTriple,
252cdf0e10cSrcweir 		sal_uInt16             nDouble,
253cdf0e10cSrcweir 		sal_uInt16             nSingle,
254cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
255cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 	/** write (indirect data page).
258cdf0e10cSrcweir 	*/
259cdf0e10cSrcweir 	storeError write (
260cdf0e10cSrcweir 		sal_uInt16             nSingle,
261cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
262cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	storeError write (
265cdf0e10cSrcweir 		sal_uInt16             nDouble,
266cdf0e10cSrcweir 		sal_uInt16             nSingle,
267cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
268cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	storeError write (
271cdf0e10cSrcweir 		sal_uInt16             nTriple,
272cdf0e10cSrcweir 		sal_uInt16             nDouble,
273cdf0e10cSrcweir 		sal_uInt16             nSingle,
274cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
275cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	/** truncate (indirect data page).
278cdf0e10cSrcweir 	*/
279cdf0e10cSrcweir 	storeError truncate (
280cdf0e10cSrcweir 		sal_uInt16             nSingle,
281cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	storeError truncate (
284cdf0e10cSrcweir 		sal_uInt16             nDouble,
285cdf0e10cSrcweir 		sal_uInt16             nSingle,
286cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	storeError truncate (
289cdf0e10cSrcweir 		sal_uInt16             nTriple,
290cdf0e10cSrcweir 		sal_uInt16             nDouble,
291cdf0e10cSrcweir 		sal_uInt16             nSingle,
292cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
293cdf0e10cSrcweir };
294cdf0e10cSrcweir 
295cdf0e10cSrcweir /*========================================================================
296cdf0e10cSrcweir  *
297cdf0e10cSrcweir  * OStorePageNameBlock.
298cdf0e10cSrcweir  *
299cdf0e10cSrcweir  *======================================================================*/
300cdf0e10cSrcweir struct OStorePageNameBlock
301cdf0e10cSrcweir {
302cdf0e10cSrcweir 	typedef OStorePageGuard G;
303cdf0e10cSrcweir 	typedef OStorePageKey   K;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 	/** Representation.
306cdf0e10cSrcweir 	*/
307cdf0e10cSrcweir 	G          m_aGuard;
308cdf0e10cSrcweir 	K          m_aKey;
309cdf0e10cSrcweir 	sal_uInt32 m_nAttrib;
310cdf0e10cSrcweir 	sal_Char   m_pData[STORE_MAXIMUM_NAMESIZE];
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 	/** size.
313cdf0e10cSrcweir 	*/
314cdf0e10cSrcweir     static const size_t theSize = sizeof(G) + sizeof(K) + sizeof(sal_uInt32) + sizeof(sal_Char[STORE_MAXIMUM_NAMESIZE]);
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	/** initialize.
317cdf0e10cSrcweir 	*/
initializestore::OStorePageNameBlock318cdf0e10cSrcweir 	void initialize (void)
319cdf0e10cSrcweir 	{
320cdf0e10cSrcweir 		m_aGuard  = G();
321cdf0e10cSrcweir 		m_aKey    = K();
322cdf0e10cSrcweir 		m_nAttrib = 0;
323cdf0e10cSrcweir 		memset (m_pData, 0, sizeof(m_pData));
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	/** Construction.
327cdf0e10cSrcweir 	*/
OStorePageNameBlockstore::OStorePageNameBlock328cdf0e10cSrcweir 	OStorePageNameBlock (void)
329cdf0e10cSrcweir 		: m_aGuard(), m_aKey(), m_nAttrib (0)
330cdf0e10cSrcweir 	{
331cdf0e10cSrcweir 		memset (m_pData, 0, sizeof(m_pData));
332cdf0e10cSrcweir 	}
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	/** guard (external representation).
335cdf0e10cSrcweir 	*/
guardstore::OStorePageNameBlock336cdf0e10cSrcweir 	void guard()
337cdf0e10cSrcweir 	{
338cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
339cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
340cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aKey, theSize - sizeof(G));
341cdf0e10cSrcweir 		m_aGuard.m_nCRC32 = store::htonl(nCRC32);
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	/** verify (external representation).
345cdf0e10cSrcweir 	*/
verifystore::OStorePageNameBlock346cdf0e10cSrcweir 	storeError verify() const
347cdf0e10cSrcweir 	{
348cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
349cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
350cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aKey, theSize - sizeof(G));
351cdf0e10cSrcweir 		if (m_aGuard.m_nCRC32 != store::htonl(nCRC32))
352cdf0e10cSrcweir 			return store_E_InvalidChecksum;
353cdf0e10cSrcweir 		else
354cdf0e10cSrcweir 			return store_E_None;
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir };
357cdf0e10cSrcweir 
358cdf0e10cSrcweir /*========================================================================
359cdf0e10cSrcweir  *
360cdf0e10cSrcweir  * OStoreDirectoryDataBlock.
361cdf0e10cSrcweir  *
362cdf0e10cSrcweir  *======================================================================*/
363cdf0e10cSrcweir #define STORE_LIMIT_DATAPAGE_DIRECT 16
364cdf0e10cSrcweir #define STORE_LIMIT_DATAPAGE_SINGLE  8
365cdf0e10cSrcweir #define STORE_LIMIT_DATAPAGE_DOUBLE  1
366cdf0e10cSrcweir #define STORE_LIMIT_DATAPAGE_TRIPLE  1
367cdf0e10cSrcweir 
368cdf0e10cSrcweir struct OStoreDirectoryDataBlock
369cdf0e10cSrcweir {
370cdf0e10cSrcweir 	typedef OStorePageGuard G;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	/** LinkDescriptor.
373cdf0e10cSrcweir 	*/
374cdf0e10cSrcweir 	struct LinkDescriptor
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir 		/** Representation.
377cdf0e10cSrcweir 		*/
378cdf0e10cSrcweir 		sal_uInt16 m_nIndex0;
379cdf0e10cSrcweir 		sal_uInt16 m_nIndex1;
380cdf0e10cSrcweir 		sal_uInt16 m_nIndex2;
381cdf0e10cSrcweir 		sal_uInt16 m_nIndex3;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 		/** Construction.
384cdf0e10cSrcweir 		*/
LinkDescriptorstore::OStoreDirectoryDataBlock::LinkDescriptor385cdf0e10cSrcweir 		LinkDescriptor (void)
386cdf0e10cSrcweir 			: m_nIndex0 ((sal_uInt16)(~0)),
387cdf0e10cSrcweir 			  m_nIndex1 ((sal_uInt16)(~0)),
388cdf0e10cSrcweir 			  m_nIndex2 ((sal_uInt16)(~0)),
389cdf0e10cSrcweir 			  m_nIndex3 ((sal_uInt16)(~0))
390cdf0e10cSrcweir 		{}
391cdf0e10cSrcweir 	};
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	/** LinkTable.
394cdf0e10cSrcweir 	*/
395cdf0e10cSrcweir 	struct LinkTable
396cdf0e10cSrcweir 	{
397cdf0e10cSrcweir 		/** Representation.
398cdf0e10cSrcweir 		*/
399cdf0e10cSrcweir 		sal_uInt32 m_pDirect[STORE_LIMIT_DATAPAGE_DIRECT];
400cdf0e10cSrcweir 		sal_uInt32 m_pSingle[STORE_LIMIT_DATAPAGE_SINGLE];
401cdf0e10cSrcweir 		sal_uInt32 m_pDouble[STORE_LIMIT_DATAPAGE_DOUBLE];
402cdf0e10cSrcweir 		sal_uInt32 m_pTriple[STORE_LIMIT_DATAPAGE_TRIPLE];
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 		/** initialize.
405cdf0e10cSrcweir 		*/
initializestore::OStoreDirectoryDataBlock::LinkTable406cdf0e10cSrcweir 		void initialize (void)
407cdf0e10cSrcweir 		{
408cdf0e10cSrcweir 		  memset(m_pDirect, STORE_PAGE_NULL, sizeof(m_pDirect));
409cdf0e10cSrcweir 		  memset(m_pSingle, STORE_PAGE_NULL, sizeof(m_pSingle));
410cdf0e10cSrcweir 		  memset(m_pDouble, STORE_PAGE_NULL, sizeof(m_pDouble));
411cdf0e10cSrcweir 		  memset(m_pTriple, STORE_PAGE_NULL, sizeof(m_pTriple));
412cdf0e10cSrcweir 		}
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 		/** Construction.
415cdf0e10cSrcweir 		*/
LinkTablestore::OStoreDirectoryDataBlock::LinkTable416cdf0e10cSrcweir 		LinkTable (void)
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 		  initialize();
419cdf0e10cSrcweir 		}
420cdf0e10cSrcweir 	};
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	/** Representation.
423cdf0e10cSrcweir 	*/
424cdf0e10cSrcweir 	G          m_aGuard;
425cdf0e10cSrcweir 	LinkTable  m_aTable;
426cdf0e10cSrcweir 	sal_uInt32 m_nDataLen;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	/** size.
429cdf0e10cSrcweir      */
430cdf0e10cSrcweir     static const size_t theSize = sizeof(G) + sizeof(LinkTable) + sizeof(sal_uInt32);
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 	/** initialize.
433cdf0e10cSrcweir 	*/
initializestore::OStoreDirectoryDataBlock434cdf0e10cSrcweir 	void initialize (void)
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		m_aGuard = G();
437cdf0e10cSrcweir 		m_aTable.initialize();
438cdf0e10cSrcweir 		m_nDataLen = 0;
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	/** Construction.
442cdf0e10cSrcweir 	*/
OStoreDirectoryDataBlockstore::OStoreDirectoryDataBlock443cdf0e10cSrcweir 	OStoreDirectoryDataBlock (void)
444cdf0e10cSrcweir 		: m_aGuard(), m_aTable(), m_nDataLen (0)
445cdf0e10cSrcweir 	{}
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	/** guard (external representation).
448cdf0e10cSrcweir 	*/
guardstore::OStoreDirectoryDataBlock449cdf0e10cSrcweir 	void guard()
450cdf0e10cSrcweir 	{
451cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
452cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
453cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aTable, theSize - sizeof(G));
454cdf0e10cSrcweir 		m_aGuard.m_nCRC32 = store::htonl(nCRC32);
455cdf0e10cSrcweir 	}
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	/** verify (external representation).
458cdf0e10cSrcweir 	*/
verifystore::OStoreDirectoryDataBlock459cdf0e10cSrcweir 	storeError verify() const
460cdf0e10cSrcweir 	{
461cdf0e10cSrcweir 		sal_uInt32 nCRC32 = 0;
462cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aGuard.m_nMagic, sizeof(sal_uInt32));
463cdf0e10cSrcweir 		nCRC32 = rtl_crc32 (nCRC32, &m_aTable, theSize - sizeof(G));
464cdf0e10cSrcweir 		if (m_aGuard.m_nCRC32 != store::htonl(nCRC32))
465cdf0e10cSrcweir 			return store_E_InvalidChecksum;
466cdf0e10cSrcweir 		else
467cdf0e10cSrcweir 			return store_E_None;
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 	/** direct.
471cdf0e10cSrcweir 	*/
directCountstore::OStoreDirectoryDataBlock472cdf0e10cSrcweir 	static sal_uInt16 directCount (void)
473cdf0e10cSrcweir 	{
474cdf0e10cSrcweir 		return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DIRECT));
475cdf0e10cSrcweir 	}
directLinkstore::OStoreDirectoryDataBlock476cdf0e10cSrcweir 	sal_uInt32 directLink (sal_uInt16 nIndex) const
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		if (nIndex < directCount())
479cdf0e10cSrcweir 			return store::ntohl(m_aTable.m_pDirect[nIndex]);
480cdf0e10cSrcweir 		else
481cdf0e10cSrcweir 			return STORE_PAGE_NULL;
482cdf0e10cSrcweir 	}
directLinkstore::OStoreDirectoryDataBlock483cdf0e10cSrcweir 	void directLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
484cdf0e10cSrcweir 	{
485cdf0e10cSrcweir 		if (nIndex < directCount())
486cdf0e10cSrcweir 			m_aTable.m_pDirect[nIndex] = store::htonl(nAddr);
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	/** single.
490cdf0e10cSrcweir 	*/
singleCountstore::OStoreDirectoryDataBlock491cdf0e10cSrcweir 	static sal_uInt16 singleCount (void)
492cdf0e10cSrcweir 	{
493cdf0e10cSrcweir 		return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_SINGLE));
494cdf0e10cSrcweir 	}
singleLinkstore::OStoreDirectoryDataBlock495cdf0e10cSrcweir 	sal_uInt32 singleLink (sal_uInt16 nIndex) const
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir 		if (nIndex < singleCount())
498cdf0e10cSrcweir 			return store::ntohl(m_aTable.m_pSingle[nIndex]);
499cdf0e10cSrcweir 		else
500cdf0e10cSrcweir 			return STORE_PAGE_NULL;
501cdf0e10cSrcweir 	}
singleLinkstore::OStoreDirectoryDataBlock502cdf0e10cSrcweir 	void singleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
503cdf0e10cSrcweir 	{
504cdf0e10cSrcweir 		if (nIndex < singleCount())
505cdf0e10cSrcweir 			m_aTable.m_pSingle[nIndex] = store::htonl(nAddr);
506cdf0e10cSrcweir 	}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 	/** double.
509cdf0e10cSrcweir 	*/
doubleCountstore::OStoreDirectoryDataBlock510cdf0e10cSrcweir 	static sal_uInt16 doubleCount (void)
511cdf0e10cSrcweir 	{
512cdf0e10cSrcweir 		return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DOUBLE));
513cdf0e10cSrcweir 	}
doubleLinkstore::OStoreDirectoryDataBlock514cdf0e10cSrcweir 	sal_uInt32 doubleLink (sal_uInt16 nIndex) const
515cdf0e10cSrcweir 	{
516cdf0e10cSrcweir 		if (nIndex < doubleCount())
517cdf0e10cSrcweir 			return store::ntohl(m_aTable.m_pDouble[nIndex]);
518cdf0e10cSrcweir 		else
519cdf0e10cSrcweir 			return STORE_PAGE_NULL;
520cdf0e10cSrcweir 	}
doubleLinkstore::OStoreDirectoryDataBlock521cdf0e10cSrcweir 	void doubleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
522cdf0e10cSrcweir 	{
523cdf0e10cSrcweir 		if (nIndex < doubleCount())
524cdf0e10cSrcweir 			m_aTable.m_pDouble[nIndex] = store::htonl(nAddr);
525cdf0e10cSrcweir 	}
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	/** triple.
528cdf0e10cSrcweir 	*/
tripleCountstore::OStoreDirectoryDataBlock529cdf0e10cSrcweir 	static sal_uInt16 tripleCount (void)
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 		return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_TRIPLE));
532cdf0e10cSrcweir 	}
tripleLinkstore::OStoreDirectoryDataBlock533cdf0e10cSrcweir 	sal_uInt32 tripleLink (sal_uInt16 nIndex) const
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		if (nIndex < tripleCount())
536cdf0e10cSrcweir 			return store::ntohl(m_aTable.m_pTriple[nIndex]);
537cdf0e10cSrcweir 		else
538cdf0e10cSrcweir 			return STORE_PAGE_NULL;
539cdf0e10cSrcweir 	}
tripleLinkstore::OStoreDirectoryDataBlock540cdf0e10cSrcweir 	void tripleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
541cdf0e10cSrcweir 	{
542cdf0e10cSrcweir 		if (nIndex < tripleCount())
543cdf0e10cSrcweir 			m_aTable.m_pTriple[nIndex] = store::htonl(nAddr);
544cdf0e10cSrcweir 	}
545cdf0e10cSrcweir };
546cdf0e10cSrcweir 
547cdf0e10cSrcweir /*========================================================================
548cdf0e10cSrcweir  *
549cdf0e10cSrcweir  * OStoreDirectoryPageData.
550cdf0e10cSrcweir  *
551cdf0e10cSrcweir  *======================================================================*/
552cdf0e10cSrcweir #define STORE_MAGIC_DIRECTORYPAGE sal_uInt32(0x62190120)
553cdf0e10cSrcweir 
554cdf0e10cSrcweir struct OStoreDirectoryPageData : public store::OStorePageData
555cdf0e10cSrcweir {
556cdf0e10cSrcweir 	typedef OStorePageData           base;
557cdf0e10cSrcweir 	typedef OStoreDirectoryPageData  self;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 	typedef OStorePageDescriptor     D;
560cdf0e10cSrcweir 	typedef OStorePageNameBlock      NameBlock;
561cdf0e10cSrcweir 	typedef OStoreDirectoryDataBlock DataBlock;
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 	/** Representation.
564cdf0e10cSrcweir      */
565cdf0e10cSrcweir 	NameBlock m_aNameBlock;
566cdf0e10cSrcweir 	DataBlock m_aDataBlock;
567cdf0e10cSrcweir 	sal_uInt8 m_pData[1];
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     /** type.
570cdf0e10cSrcweir      */
571cdf0e10cSrcweir     static const sal_uInt32 theTypeId = STORE_MAGIC_DIRECTORYPAGE;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	/** size.
574cdf0e10cSrcweir      */
575cdf0e10cSrcweir     static const size_t     theSize     = NameBlock::theSize + DataBlock::theSize;
576cdf0e10cSrcweir     static const sal_uInt16 thePageSize = base::theSize + self::theSize;
577cdf0e10cSrcweir     STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 	/** capacity.
580cdf0e10cSrcweir 	*/
capacitystore::OStoreDirectoryPageData581cdf0e10cSrcweir 	sal_uInt16 capacity() const
582cdf0e10cSrcweir 	{
583cdf0e10cSrcweir 		return (store::ntohs(base::m_aDescr.m_nSize) - self::thePageSize);
584cdf0e10cSrcweir 	}
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 	/** usage.
587cdf0e10cSrcweir 	*/
usagestore::OStoreDirectoryPageData588cdf0e10cSrcweir 	sal_uInt16 usage() const
589cdf0e10cSrcweir 	{
590cdf0e10cSrcweir 		return (store::ntohs(base::m_aDescr.m_nUsed) - self::thePageSize);
591cdf0e10cSrcweir 	}
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	/** initialize.
594cdf0e10cSrcweir 	*/
initializestore::OStoreDirectoryPageData595cdf0e10cSrcweir 	void initialize (void)
596cdf0e10cSrcweir 	{
597cdf0e10cSrcweir 		base::m_aGuard.m_nMagic = store::htonl(self::theTypeId);
598cdf0e10cSrcweir 		base::m_aDescr.m_nUsed  = store::htons(self::thePageSize);
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 		m_aNameBlock.initialize();
601cdf0e10cSrcweir 		m_aDataBlock.initialize();
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 		memset (m_pData, 0, capacity());
604cdf0e10cSrcweir 	}
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	/** Construction.
607cdf0e10cSrcweir 	*/
OStoreDirectoryPageDatastore::OStoreDirectoryPageData608cdf0e10cSrcweir 	explicit OStoreDirectoryPageData (sal_uInt16 nPageSize)
609cdf0e10cSrcweir 		: base (nPageSize), m_aNameBlock(), m_aDataBlock()
610cdf0e10cSrcweir 	{
611cdf0e10cSrcweir 		base::m_aGuard.m_nMagic = store::htonl(self::theTypeId);
612cdf0e10cSrcweir 		base::m_aDescr.m_nUsed  = store::htons(self::thePageSize);
613cdf0e10cSrcweir 		memset (m_pData, 0, capacity());
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 	/** guard (external representation).
617cdf0e10cSrcweir 	*/
guardstore::OStoreDirectoryPageData618cdf0e10cSrcweir 	void guard()
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 		m_aNameBlock.guard();
621cdf0e10cSrcweir 		m_aDataBlock.guard();
622cdf0e10cSrcweir 	}
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 	/** verify (external representation).
625cdf0e10cSrcweir 	*/
verifystore::OStoreDirectoryPageData626cdf0e10cSrcweir 	storeError verify() const
627cdf0e10cSrcweir 	{
628cdf0e10cSrcweir 		storeError eErrCode = m_aNameBlock.verify();
629cdf0e10cSrcweir 		if (eErrCode == store_E_None)
630cdf0e10cSrcweir 			eErrCode = m_aDataBlock.verify();
631cdf0e10cSrcweir 		return eErrCode;
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	/** ChunkDescriptor.
635cdf0e10cSrcweir 	*/
636cdf0e10cSrcweir 	struct ChunkDescriptor
637cdf0e10cSrcweir 	{
638cdf0e10cSrcweir 		/** Representation.
639cdf0e10cSrcweir 		*/
640cdf0e10cSrcweir 		sal_uInt32 m_nPage;
641cdf0e10cSrcweir 		sal_uInt16 m_nOffset;
642cdf0e10cSrcweir 		sal_uInt16 m_nLength;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 		/** Construction.
645cdf0e10cSrcweir 		*/
ChunkDescriptorstore::OStoreDirectoryPageData::ChunkDescriptor646cdf0e10cSrcweir 		ChunkDescriptor (sal_uInt32 nPosition, sal_uInt16 nCapacity)
647cdf0e10cSrcweir 		{
648cdf0e10cSrcweir 			m_nPage   = nPosition / nCapacity;
649cdf0e10cSrcweir 			m_nOffset = (sal_uInt16)((nPosition % nCapacity) & 0xffff);
650cdf0e10cSrcweir 			m_nLength = nCapacity - m_nOffset;
651cdf0e10cSrcweir 		}
652cdf0e10cSrcweir 	};
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	/** ChunkScope.
655cdf0e10cSrcweir 	*/
656cdf0e10cSrcweir 	enum ChunkScope
657cdf0e10cSrcweir 	{
658cdf0e10cSrcweir 		SCOPE_INTERNAL,
659cdf0e10cSrcweir 		SCOPE_EXTERNAL,
660cdf0e10cSrcweir 		SCOPE_DIRECT,
661cdf0e10cSrcweir 		SCOPE_SINGLE,
662cdf0e10cSrcweir 		SCOPE_DOUBLE,
663cdf0e10cSrcweir 		SCOPE_TRIPLE,
664cdf0e10cSrcweir 		SCOPE_UNREACHABLE,
665cdf0e10cSrcweir 		SCOPE_UNKNOWN
666cdf0e10cSrcweir 	};
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	/** scope (internal).
669cdf0e10cSrcweir 	*/
scopestore::OStoreDirectoryPageData670cdf0e10cSrcweir 	ChunkScope scope (sal_uInt32 nPosition) const
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		sal_uInt32 nCapacity = capacity();
673cdf0e10cSrcweir 		if (nPosition < nCapacity)
674cdf0e10cSrcweir 			return SCOPE_INTERNAL;
675cdf0e10cSrcweir 		else
676cdf0e10cSrcweir 			return SCOPE_EXTERNAL;
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir };
679cdf0e10cSrcweir 
680cdf0e10cSrcweir /*========================================================================
681cdf0e10cSrcweir  *
682cdf0e10cSrcweir  * OStoreDirectoryPageObject.
683cdf0e10cSrcweir  *
684cdf0e10cSrcweir  *======================================================================*/
685cdf0e10cSrcweir class OStoreDirectoryPageObject : public store::OStorePageObject
686cdf0e10cSrcweir {
687cdf0e10cSrcweir 	typedef OStorePageObject          base;
688cdf0e10cSrcweir 	typedef OStoreDirectoryPageData   page;
689cdf0e10cSrcweir 	typedef OStoreIndirectionPageData indirect;
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	typedef OStorePageDescriptor      D;
692cdf0e10cSrcweir 
693cdf0e10cSrcweir public:
694cdf0e10cSrcweir 	/** Construction.
695cdf0e10cSrcweir 	*/
OStoreDirectoryPageObject(PageHolder const & rxPage=PageHolder ())696cdf0e10cSrcweir     explicit OStoreDirectoryPageObject (PageHolder const & rxPage = PageHolder())
697cdf0e10cSrcweir         : OStorePageObject (rxPage)
698cdf0e10cSrcweir     {}
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	/** External representation.
701cdf0e10cSrcweir 	*/
702cdf0e10cSrcweir 	virtual storeError guard  (sal_uInt32 nAddr);
703cdf0e10cSrcweir 	virtual storeError verify (sal_uInt32 nAddr) const;
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 	/** attrib.
706cdf0e10cSrcweir 	*/
attrib(void) const707cdf0e10cSrcweir 	sal_uInt32 attrib (void) const
708cdf0e10cSrcweir 	{
709cdf0e10cSrcweir 		return store::ntohl(PAGE().m_aNameBlock.m_nAttrib);
710cdf0e10cSrcweir 	}
attrib(sal_uInt32 nAttrib)711cdf0e10cSrcweir 	void attrib (sal_uInt32 nAttrib)
712cdf0e10cSrcweir 	{
713cdf0e10cSrcweir 		PAGE().m_aNameBlock.m_nAttrib = store::htonl(nAttrib);
714cdf0e10cSrcweir 		touch();
715cdf0e10cSrcweir 	}
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 	/** key.
718cdf0e10cSrcweir 	*/
key(void) const719cdf0e10cSrcweir 	OStorePageKey key (void) const
720cdf0e10cSrcweir 	{
721cdf0e10cSrcweir 		return PAGE().m_aNameBlock.m_aKey;
722cdf0e10cSrcweir 	}
key(OStorePageKey const & rKey)723cdf0e10cSrcweir 	void key (OStorePageKey const & rKey)
724cdf0e10cSrcweir 	{
725cdf0e10cSrcweir 		PAGE().m_aNameBlock.m_aKey = rKey;
726cdf0e10cSrcweir 		touch();
727cdf0e10cSrcweir 	}
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 	/** path.
730cdf0e10cSrcweir 	*/
path(void) const731cdf0e10cSrcweir 	sal_uInt32 path (void) const
732cdf0e10cSrcweir 	{
733cdf0e10cSrcweir         page const & rPage = PAGE();
734cdf0e10cSrcweir 		const sal_Char * pszName = rPage.m_aNameBlock.m_pData;
735cdf0e10cSrcweir 		sal_uInt32       nPath   = store::ntohl(rPage.m_aNameBlock.m_aKey.m_nHigh);
736cdf0e10cSrcweir 		return rtl_crc32 (nPath, pszName, rtl_str_getLength(pszName));
737cdf0e10cSrcweir 	}
738cdf0e10cSrcweir 
getName(sal_Char * pBuffer,sal_Size nBufsiz) const739cdf0e10cSrcweir     sal_Size getName (sal_Char * pBuffer, sal_Size nBufsiz) const
740cdf0e10cSrcweir     {
741cdf0e10cSrcweir         sal_Char const * pszName = PAGE().m_aNameBlock.m_pData;
742cdf0e10cSrcweir         sal_Size nLength = rtl_str_getLength(pszName);
743cdf0e10cSrcweir         memcpy (pBuffer, pszName, SAL_MIN(nLength, nBufsiz));
744cdf0e10cSrcweir         return nLength;
745cdf0e10cSrcweir     }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 	/** dataLength.
748cdf0e10cSrcweir 	*/
dataLength(void) const749cdf0e10cSrcweir 	sal_uInt32 dataLength (void) const
750cdf0e10cSrcweir 	{
751cdf0e10cSrcweir 		return store::ntohl(PAGE().m_aDataBlock.m_nDataLen);
752cdf0e10cSrcweir 	}
dataLength(sal_uInt32 nLength)753cdf0e10cSrcweir 	void dataLength (sal_uInt32 nLength)
754cdf0e10cSrcweir 	{
755cdf0e10cSrcweir 		PAGE().m_aDataBlock.m_nDataLen = store::htonl(nLength);
756cdf0e10cSrcweir 		touch();
757cdf0e10cSrcweir 	}
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 	/** direct.
760cdf0e10cSrcweir 	*/
directLink(sal_uInt16 nIndex) const761cdf0e10cSrcweir 	sal_uInt32 directLink (sal_uInt16 nIndex) const
762cdf0e10cSrcweir 	{
763cdf0e10cSrcweir 		return PAGE().m_aDataBlock.directLink (nIndex);
764cdf0e10cSrcweir 	}
directLink(sal_uInt16 nIndex,sal_uInt32 nAddr)765cdf0e10cSrcweir 	void directLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
766cdf0e10cSrcweir 	{
767cdf0e10cSrcweir 		PAGE().m_aDataBlock.directLink (nIndex, nAddr);
768cdf0e10cSrcweir 		touch();
769cdf0e10cSrcweir 	}
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 	/** single indirect.
772cdf0e10cSrcweir 	*/
singleLink(sal_uInt16 nIndex) const773cdf0e10cSrcweir 	sal_uInt32 singleLink (sal_uInt16 nIndex) const
774cdf0e10cSrcweir 	{
775cdf0e10cSrcweir 		return PAGE().m_aDataBlock.singleLink (nIndex);
776cdf0e10cSrcweir 	}
singleLink(sal_uInt16 nIndex,sal_uInt32 nAddr)777cdf0e10cSrcweir 	void singleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
778cdf0e10cSrcweir 	{
779cdf0e10cSrcweir 		PAGE().m_aDataBlock.singleLink (nIndex, nAddr);
780cdf0e10cSrcweir 		touch();
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 	/** double indirect.
784cdf0e10cSrcweir 	*/
doubleLink(sal_uInt16 nIndex) const785cdf0e10cSrcweir 	sal_uInt32 doubleLink (sal_uInt16 nIndex) const
786cdf0e10cSrcweir 	{
787cdf0e10cSrcweir 		return PAGE().m_aDataBlock.doubleLink (nIndex);
788cdf0e10cSrcweir 	}
doubleLink(sal_uInt16 nIndex,sal_uInt32 nAddr)789cdf0e10cSrcweir 	void doubleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
790cdf0e10cSrcweir 	{
791cdf0e10cSrcweir 		PAGE().m_aDataBlock.doubleLink (nIndex, nAddr);
792cdf0e10cSrcweir 		touch();
793cdf0e10cSrcweir 	}
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 	/** triple indirect.
796cdf0e10cSrcweir 	*/
tripleLink(sal_uInt16 nIndex) const797cdf0e10cSrcweir 	sal_uInt32 tripleLink (sal_uInt16 nIndex) const
798cdf0e10cSrcweir 	{
799cdf0e10cSrcweir 		return PAGE().m_aDataBlock.tripleLink (nIndex);
800cdf0e10cSrcweir 	}
tripleLink(sal_uInt16 nIndex,sal_uInt32 nAddr)801cdf0e10cSrcweir 	void tripleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
802cdf0e10cSrcweir 	{
803cdf0e10cSrcweir 		PAGE().m_aDataBlock.tripleLink (nIndex, nAddr);
804cdf0e10cSrcweir 		touch();
805cdf0e10cSrcweir 	}
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 	/** read (external data page).
808cdf0e10cSrcweir 	*/
809cdf0e10cSrcweir 	storeError read (
810cdf0e10cSrcweir 		sal_uInt32             nPage,
811cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
812cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 	/** write (external data page).
815cdf0e10cSrcweir 	*/
816cdf0e10cSrcweir 	storeError write (
817cdf0e10cSrcweir 		sal_uInt32             nPage,
818cdf0e10cSrcweir 		OStoreDataPageObject  &rData,
819cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 	/** truncate (external data page).
822cdf0e10cSrcweir 	*/
823cdf0e10cSrcweir 	storeError truncate (
824cdf0e10cSrcweir 		sal_uInt32             nPage,
825cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
826cdf0e10cSrcweir 
827cdf0e10cSrcweir private:
828cdf0e10cSrcweir 	/** Representation.
829cdf0e10cSrcweir 	*/
PAGE()830cdf0e10cSrcweir     page & PAGE()
831cdf0e10cSrcweir     {
832cdf0e10cSrcweir         page * pImpl = static_cast<page*>(m_xPage.get());
833cdf0e10cSrcweir         OSL_PRECOND(pImpl != 0, "OStoreDirectoryPageObject::PAGE(): Null pointer");
834cdf0e10cSrcweir         return (*pImpl);
835cdf0e10cSrcweir     }
PAGE() const836cdf0e10cSrcweir     page const & PAGE() const
837cdf0e10cSrcweir     {
838cdf0e10cSrcweir         page const * pImpl = static_cast<page const *>(m_xPage.get());
839cdf0e10cSrcweir         OSL_PRECOND(pImpl != 0, "OStoreDirectoryPageObject::PAGE(): Null pointer");
840cdf0e10cSrcweir         return (*pImpl);
841cdf0e10cSrcweir     }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	/** scope (external data page; private).
844cdf0e10cSrcweir 	*/
845cdf0e10cSrcweir 	page::ChunkScope scope (
846cdf0e10cSrcweir 		sal_uInt32                       nPage,
847cdf0e10cSrcweir 		page::DataBlock::LinkDescriptor &rDescr) const;
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 	/** truncate (external data page scope; private).
850cdf0e10cSrcweir 	*/
851cdf0e10cSrcweir 	storeError truncate (
852cdf0e10cSrcweir 		page::ChunkScope       eScope,
853cdf0e10cSrcweir 		sal_uInt16             nRemain,
854cdf0e10cSrcweir 		OStorePageBIOS        &rBIOS);
855cdf0e10cSrcweir };
856cdf0e10cSrcweir 
857cdf0e10cSrcweir /*========================================================================
858cdf0e10cSrcweir  *
859cdf0e10cSrcweir  * The End.
860cdf0e10cSrcweir  *
861cdf0e10cSrcweir  *======================================================================*/
862cdf0e10cSrcweir 
863cdf0e10cSrcweir } // namespace store
864cdf0e10cSrcweir 
865cdf0e10cSrcweir #endif /* !_STORE_STORDATA_HXX_ */
866cdf0e10cSrcweir 
867