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 INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_DB_HXX
20 #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_DB_HXX
22 #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
24 #include <osl/diagnose.h>
25 #include <rtl/string.hxx>
26 #include <unordered_map>
28 namespace helpdatafileproxy
{
30 namespace hdf_internal
34 Noncopyable(const Noncopyable
&) SAL_DELETED_FUNCTION
;
35 void operator=(const Noncopyable
&) SAL_DELETED_FUNCTION
;
49 void copyToBuffer( const char* pSrcData
, int nSize
);
57 { delete [] m_pBuffer
; }
61 const char* getData() const
65 typedef std::unordered_map
< OString
,std::pair
<int,int>,OStringHash
> StringToValPosMap
;
66 typedef std::unordered_map
< OString
,OString
,OStringHash
> StringToDataMap
;
68 class Hdf
: hdf_internal::Noncopyable
71 StringToDataMap
* m_pStringToDataMap
;
72 StringToValPosMap
* m_pStringToValPosMap
;
73 com::sun::star::uno::Reference
< com::sun::star::ucb::XSimpleFileAccess3
>
76 com::sun::star::uno::Sequence
< sal_Int8
>
78 const char* m_pItData
;
82 static bool implReadLenAndData( const char* pData
, int& riPos
, HDFData
& rValue
);
85 //HDFHelp must get a fileURL which can then directly be used by simple file access.
86 //SimpleFileAccess requires file URLs as arguments. Passing file path may work but fails
87 //for example when using long file paths on Windows, which start with "\\?\"
88 Hdf( const OUString
& rFileURL
,
89 com::sun::star::uno::Reference
< com::sun::star::ucb::XSimpleFileAccess3
> xSFA
)
90 : m_aFileURL( rFileURL
)
91 , m_pStringToDataMap( NULL
)
92 , m_pStringToValPosMap( NULL
)
98 OSL_ASSERT(rFileURL
.startsWith("file:"));
101 { releaseHashMap(); }
103 void createHashMap( bool bOptimizeForPerformance
= false );
104 void releaseHashMap();
106 bool getValueForKey( const OString
& rKey
, HDFData
& rValue
);
108 bool startIteration();
109 bool getNextKeyAndValue( HDFData
& rKey
, HDFData
& rValue
);
110 void stopIteration();
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */