fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmlhelp / source / cxxhelp / provider / db.hxx
blob79455916627d3fc24803711c57a7831f06c9f1cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
24 #ifndef HAVE_CXX0X
25 #define BOOST_NO_0X_HDR_TYPEINDEX
26 #endif
27 #include <boost/unordered_map.hpp>
28 #include <rtl/string.hxx>
30 namespace helpdatafileproxy {
32 namespace hdf_internal
34 class Noncopyable
36 // not implemented
37 Noncopyable(const Noncopyable&);
38 void operator=(const Noncopyable&);
39 protected:
40 Noncopyable() {}
41 ~Noncopyable() {}
45 class HDFData
47 friend class Hdf;
49 int m_nSize;
50 char* m_pBuffer;
52 void copyToBuffer( const char* pSrcData, int nSize );
54 public:
55 HDFData( void )
56 : m_nSize( 0 )
57 , m_pBuffer( NULL )
59 ~HDFData()
60 { delete [] m_pBuffer; }
62 int getSize() const
63 { return m_nSize; }
64 const char* getData() const
65 { return m_pBuffer; }
68 struct eq
70 bool operator()( const OString& rKey1, const OString& rKey2 ) const
71 { return (rKey1 == rKey2); }
74 struct ha
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
85 OUString m_aFileURL;
86 StringToDataMap* m_pStringToDataMap;
87 StringToValPosMap* m_pStringToValPosMap;
88 com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 >
89 m_xSFA;
91 com::sun::star::uno::Sequence< sal_Int8 >
92 m_aItData;
93 const char* m_pItData;
94 int m_nItRead;
95 int m_iItPos;
97 bool implReadLenAndData( const char* pData, int& riPos, HDFData& rValue );
99 public:
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 )
108 , m_xSFA( xSFA )
109 , m_pItData( NULL )
110 , m_nItRead( -1 )
111 , m_iItPos( -1 )
113 OSL_ASSERT(rFileURL.startsWith("file:"));
115 ~Hdf()
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 );
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */