/src/libreoffice/include/connectivity/CommonTools.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #pragma once |
20 | | |
21 | | #include <sal/config.h> |
22 | | #include <config_java.h> |
23 | | |
24 | | #include <map> |
25 | | #include <string_view> |
26 | | |
27 | | #include <rtl/ref.hxx> |
28 | | #include <rtl/ustring.hxx> |
29 | | #include <vector> |
30 | | #include <cppuhelper/weakref.hxx> |
31 | | #include <comphelper/stl_types.hxx> |
32 | | #include <com/sun/star/beans/XPropertySet.hpp> |
33 | | #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> |
34 | | #include <connectivity/dbtoolsdllapi.hxx> |
35 | | #include <cppuhelper/supportsservice.hxx> |
36 | | #include <salhelper/simplereferenceobject.hxx> |
37 | | |
38 | | namespace com::sun::star::uno { class XComponentContext; } |
39 | | |
40 | | #if HAVE_FEATURE_JAVA |
41 | | namespace jvmaccess { class VirtualMachine; } |
42 | | #endif |
43 | | |
44 | | namespace connectivity |
45 | | { |
46 | | OOO_DLLPUBLIC_DBTOOLS bool match(const sal_Unicode* pWild, const sal_Unicode* pStr, const sal_Unicode cEscape); |
47 | | inline bool match(const OUString &rWild, const OUString &rStr, const sal_Unicode cEscape) |
48 | 348k | { |
49 | 348k | return match(rWild.getStr(), rStr.getStr(), cEscape); |
50 | 348k | } |
51 | | // typedefs |
52 | | typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray; |
53 | | typedef css::uno::Reference< css::sdbcx::XColumnsSupplier> OSQLTable; |
54 | | |
55 | | typedef std::map<OUString,OSQLTable,comphelper::UStringMixLess> OSQLTables; |
56 | | |
57 | | // class ORefVector allows reference counting on a std::vector |
58 | | template< class VectorVal > class ORefVector : public salhelper::SimpleReferenceObject, |
59 | | public std::vector< VectorVal > |
60 | | { |
61 | | protected: |
62 | 4.21M | virtual ~ORefVector() override {}connectivity::ORefVector<connectivity::ORowSetValue>::~ORefVector() Line | Count | Source | 62 | 3.44M | virtual ~ORefVector() override {} |
connectivity::ORefVector<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::~ORefVector() Line | Count | Source | 62 | 626k | virtual ~ORefVector() override {} |
connectivity::ORefVector<rtl::Reference<connectivity::ORowSetValueDecorator> >::~ORefVector() Line | Count | Source | 62 | 124k | virtual ~ORefVector() override {} |
connectivity::ORefVector<int>::~ORefVector() Line | Count | Source | 62 | 19.1k | virtual ~ORefVector() override {} |
|
63 | | public: |
64 | | typedef std::vector< VectorVal > Vector; |
65 | | |
66 | 645k | ORefVector() {}connectivity::ORefVector<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::ORefVector() Line | Count | Source | 66 | 626k | ORefVector() {} |
connectivity::ORefVector<int>::ORefVector() Line | Count | Source | 66 | 19.1k | ORefVector() {} |
|
67 | 327k | ORefVector(size_t _st) : std::vector< VectorVal >(_st) {}connectivity::ORefVector<connectivity::ORowSetValue>::ORefVector(unsigned long) Line | Count | Source | 67 | 203k | ORefVector(size_t _st) : std::vector< VectorVal >(_st) {} |
connectivity::ORefVector<rtl::Reference<connectivity::ORowSetValueDecorator> >::ORefVector(unsigned long) Line | Count | Source | 67 | 124k | ORefVector(size_t _st) : std::vector< VectorVal >(_st) {} |
|
68 | | ORefVector(const ORefVector& rOther) |
69 | 3.24M | : salhelper::SimpleReferenceObject() |
70 | 3.24M | , std::vector< VectorVal >(rOther) |
71 | 3.24M | {} |
72 | | |
73 | | ORefVector& operator=(const ORefVector& _rRH) |
74 | 0 | { |
75 | 0 | if ( &_rRH != this ) |
76 | 0 | { |
77 | 0 | std::vector< VectorVal >::operator=(_rRH); |
78 | 0 | } |
79 | 0 | return *this; |
80 | 0 | } |
81 | | }; |
82 | | |
83 | | // class ORowVector includes refcounting and initialize himself |
84 | | // with at least one element. This first element is reserved for |
85 | | // the bookmark |
86 | | template< class VectorVal > class ORowVector : public ORefVector< VectorVal > |
87 | | { |
88 | | public: |
89 | 38.5k | ORowVector() : ORefVector< VectorVal >(1){}connectivity::ORowVector<connectivity::ORowSetValue>::ORowVector() Line | Count | Source | 89 | 19.4k | ORowVector() : ORefVector< VectorVal >(1){} |
connectivity::ORowVector<rtl::Reference<connectivity::ORowSetValueDecorator> >::ORowVector() Line | Count | Source | 89 | 19.1k | ORowVector() : ORefVector< VectorVal >(1){} |
|
90 | 289k | ORowVector(size_t _st) : ORefVector< VectorVal >(_st+1) |
91 | 289k | {}connectivity::ORowVector<connectivity::ORowSetValue>::ORowVector(unsigned long) Line | Count | Source | 90 | 184k | ORowVector(size_t _st) : ORefVector< VectorVal >(_st+1) | 91 | 184k | {} |
connectivity::ORowVector<rtl::Reference<connectivity::ORowSetValueDecorator> >::ORowVector(unsigned long) Line | Count | Source | 90 | 105k | ORowVector(size_t _st) : ORefVector< VectorVal >(_st+1) | 91 | 105k | {} |
|
92 | | }; |
93 | | |
94 | | typedef ORefVector< css::uno::Reference< css::beans::XPropertySet> > OSQLColumns; |
95 | | |
96 | | // search from first to last the column with the name _rVal |
97 | | // when no such column exist last is returned |
98 | | OOO_DLLPUBLIC_DBTOOLS |
99 | | OSQLColumns::const_iterator find( const OSQLColumns::const_iterator& first, |
100 | | const OSQLColumns::const_iterator& last, |
101 | | std::u16string_view _rVal, |
102 | | const ::comphelper::UStringMixEqual& _rCase); |
103 | | |
104 | | // search from first to last the column with the realname _rVal |
105 | | // when no such column exist last is returned |
106 | | OOO_DLLPUBLIC_DBTOOLS |
107 | | OSQLColumns::const_iterator findRealName( const OSQLColumns::const_iterator& first, |
108 | | const OSQLColumns::const_iterator& last, |
109 | | std::u16string_view _rVal, |
110 | | const ::comphelper::UStringMixEqual& _rCase); |
111 | | |
112 | | // the first two find methods are much faster than the one below |
113 | | // search from first to last the column with the property _rProp equals the value _rVal |
114 | | // when no such column exist last is returned |
115 | | OOO_DLLPUBLIC_DBTOOLS |
116 | | OSQLColumns::const_iterator find( OSQLColumns::const_iterator first, |
117 | | const OSQLColumns::const_iterator& last, |
118 | | const OUString& _rProp, |
119 | | std::u16string_view _rVal, |
120 | | const ::comphelper::UStringMixEqual& _rCase); |
121 | | |
122 | | /// @throws css::lang::DisposedException |
123 | | OOO_DLLPUBLIC_DBTOOLS void checkDisposed(bool _bThrow); |
124 | | |
125 | | #if HAVE_FEATURE_JAVA |
126 | | /** creates a java virtual machine |
127 | | @param _rxContext |
128 | | The ORB. |
129 | | @return |
130 | | The JavaVM. |
131 | | */ |
132 | | OOO_DLLPUBLIC_DBTOOLS ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); |
133 | | |
134 | | /** return <TRUE/> if the java class exists, otherwise <FALSE/>. |
135 | | @param _pJVM |
136 | | The JavaVM. |
137 | | @param _sClassName |
138 | | The class name to look for. |
139 | | */ |
140 | | OOO_DLLPUBLIC_DBTOOLS bool existsJavaClassByName( const ::rtl::Reference< jvmaccess::VirtualMachine >& _pJVM,std::u16string_view _sClassName ); |
141 | | #endif |
142 | | } |
143 | | |
144 | | #define DECLARE_SERVICE_INFO() \ |
145 | | virtual OUString SAL_CALL getImplementationName( ) override; \ |
146 | | virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; \ |
147 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override \ |
148 | | |
149 | | #define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \ |
150 | | OUString SAL_CALL classname::getImplementationName( ) \ |
151 | 0 | { \ |
152 | 0 | return implasciiname; \ |
153 | 0 | } \ Unexecuted instantiation: connectivity::dbase::ODbaseConnection::getImplementationName() Unexecuted instantiation: connectivity::dbase::ODbaseStatement::getImplementationName() Unexecuted instantiation: connectivity::dbase::ODbasePreparedStatement::getImplementationName() Unexecuted instantiation: connectivity::dbase::ODbaseIndex::getImplementationName() Unexecuted instantiation: connectivity::sdbcx::OCatalog::getImplementationName() Unexecuted instantiation: connectivity::sdbcx::OCollection::getImplementationName() Unexecuted instantiation: connectivity::sdbcx::OView::getImplementationName() Unexecuted instantiation: connectivity::file::OConnection::getImplementationName() Unexecuted instantiation: connectivity::file::OPreparedStatement::getImplementationName() Unexecuted instantiation: connectivity::file::OResultSet::getImplementationName() Unexecuted instantiation: connectivity::file::OStatement::getImplementationName() |
154 | | css::uno::Sequence< OUString > SAL_CALL classname::getSupportedServiceNames( ) \ |
155 | 0 | { \ |
156 | 0 | css::uno::Sequence< OUString > aSupported { serviceasciiname }; \ |
157 | 0 | return aSupported; \ |
158 | 0 | } \ Unexecuted instantiation: connectivity::dbase::ODbaseConnection::getSupportedServiceNames() Unexecuted instantiation: connectivity::dbase::ODbaseStatement::getSupportedServiceNames() Unexecuted instantiation: connectivity::dbase::ODbasePreparedStatement::getSupportedServiceNames() Unexecuted instantiation: connectivity::dbase::ODbaseIndex::getSupportedServiceNames() Unexecuted instantiation: connectivity::sdbcx::OCatalog::getSupportedServiceNames() Unexecuted instantiation: connectivity::sdbcx::OCollection::getSupportedServiceNames() Unexecuted instantiation: connectivity::sdbcx::OView::getSupportedServiceNames() Unexecuted instantiation: connectivity::file::OConnection::getSupportedServiceNames() Unexecuted instantiation: connectivity::file::OPreparedStatement::getSupportedServiceNames() Unexecuted instantiation: connectivity::file::OResultSet::getSupportedServiceNames() Unexecuted instantiation: connectivity::file::OStatement::getSupportedServiceNames() |
159 | | sal_Bool SAL_CALL classname::supportsService( const OUString& rServiceName ) \ |
160 | 0 | { \ |
161 | 0 | return cppu::supportsService(this, rServiceName); \ |
162 | 0 | } \ Unexecuted instantiation: connectivity::dbase::ODbaseConnection::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::dbase::ODbaseStatement::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::dbase::ODbasePreparedStatement::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::dbase::ODbaseIndex::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::sdbcx::OCatalog::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::sdbcx::OCollection::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::sdbcx::OView::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::file::OConnection::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::file::OPreparedStatement::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::file::OResultSet::supportsService(rtl::OUString const&) Unexecuted instantiation: connectivity::file::OStatement::supportsService(rtl::OUString const&) |
163 | | |
164 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |