1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef HELPDATAFILEPROXY_DB_HXX_
20 #define HELPDATAFILEPROXY_DB_HXX_
22 #include "com/sun/star/ucb/XSimpleFileAccess3.hpp"
25 #define BOOST_NO_0X_HDR_TYPEINDEX
27 #include <boost/unordered_map.hpp>
28 #include <rtl/string.hxx>
30 namespace helpdatafileproxy
{
32 namespace hdf_internal
37 Noncopyable(const Noncopyable
&);
38 void operator=(const Noncopyable
&);
52 void copyToBuffer( const char* pSrcData
, int nSize
);
60 { delete [] m_pBuffer
; }
64 const char* getData() const
70 bool operator()( const OString
& rKey1
, const OString
& rKey2
) const
71 { return (rKey1
== rKey2
); }
76 size_t operator()( const OString
& rName
) const
77 { return rName
.hashCode(); }
80 typedef boost::unordered_map
< OString
,std::pair
<int,int>,ha
,eq
> StringToValPosMap
;
81 typedef boost::unordered_map
< OString
,OString
,ha
,eq
> StringToDataMap
;
83 class Hdf
: hdf_internal::Noncopyable
86 StringToDataMap
* m_pStringToDataMap
;
87 StringToValPosMap
* m_pStringToValPosMap
;
88 com::sun::star::uno::Reference
< com::sun::star::ucb::XSimpleFileAccess3
>
91 com::sun::star::uno::Sequence
< sal_Int8
>
93 const char* m_pItData
;
97 bool implReadLenAndData( const char* pData
, int& riPos
, HDFData
& rValue
);
100 //HDFHelp must get a fileURL which can then directly be used by simple file access.
101 //SimpleFileAccess requires file URLs as arguments. Passing file path may work but fails
102 //for example when using long file paths on Windows, which start with "\\?\"
103 Hdf( const OUString
& rFileURL
,
104 com::sun::star::uno::Reference
< com::sun::star::ucb::XSimpleFileAccess3
> xSFA
)
105 : m_aFileURL( rFileURL
)
106 , m_pStringToDataMap( NULL
)
107 , m_pStringToValPosMap( NULL
)
113 OSL_ASSERT(rFileURL
.startsWith("file:"));
116 { releaseHashMap(); }
118 void createHashMap( bool bOptimizeForPerformance
= false );
119 void releaseHashMap( void );
121 bool getValueForKey( const OString
& rKey
, HDFData
& rValue
);
123 bool startIteration( void );
124 bool getNextKeyAndValue( HDFData
& rKey
, HDFData
& rValue
);
125 void stopIteration( void );
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */