LibreOffice Module connectivity (master) 1
CommonTools.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_CONNECTIVITY_COMMONTOOLS_HXX
20#define INCLUDED_CONNECTIVITY_COMMONTOOLS_HXX
21
22#include <sal/config.h>
23#include <config_java.h>
24
25#include <map>
26#include <string_view>
27
28#include <rtl/ref.hxx>
29#include <rtl/ustring.hxx>
30#include <vector>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
38
39namespace com::sun::star::uno { class XComponentContext; }
40
41#if HAVE_FEATURE_JAVA
42namespace jvmaccess { class VirtualMachine; }
43#endif
44
45namespace connectivity
46{
47 OOO_DLLPUBLIC_DBTOOLS bool match(const sal_Unicode* pWild, const sal_Unicode* pStr, const sal_Unicode cEscape);
48 inline bool match(const OUString &rWild, const OUString &rStr, const sal_Unicode cEscape)
49 {
50 return match(rWild.getStr(), rStr.getStr(), cEscape);
51 }
52 // typedefs
53 typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
54 typedef css::uno::Reference< css::sdbcx::XColumnsSupplier> OSQLTable;
55
56 typedef std::map<OUString,OSQLTable,comphelper::UStringMixLess> OSQLTables;
57
58 // class ORefVector allows reference counting on a std::vector
59 template< class VectorVal > class ORefVector : public salhelper::SimpleReferenceObject,
60 public std::vector< VectorVal >
61 {
62 protected:
63 virtual ~ORefVector() override {}
64 public:
65 typedef std::vector< VectorVal > Vector;
66
68 ORefVector(size_t _st) : std::vector< VectorVal >(_st) {}
69 ORefVector(const ORefVector& rOther)
71 , std::vector< VectorVal >(rOther)
72 {}
73
75 {
76 if ( &_rRH != this )
77 {
78 std::vector< VectorVal >::operator=(_rRH);
79 }
80 return *this;
81 }
82 };
83
84 // class ORowVector includes refcounting and initialize himself
85 // with at least one element. This first element is reserved for
86 // the bookmark
87 template< class VectorVal > class ORowVector : public ORefVector< VectorVal >
88 {
89 public:
90 ORowVector() : ORefVector< VectorVal >(1){}
91 ORowVector(size_t _st) : ORefVector< VectorVal >(_st+1)
92 {}
93 };
94
96
97 // search from first to last the column with the name _rVal
98 // when no such column exist last is returned
100 OSQLColumns::const_iterator find( const OSQLColumns::const_iterator& first,
101 const OSQLColumns::const_iterator& last,
102 std::u16string_view _rVal,
103 const ::comphelper::UStringMixEqual& _rCase);
104
105 // search from first to last the column with the realname _rVal
106 // when no such column exist last is returned
108 OSQLColumns::const_iterator findRealName( const OSQLColumns::const_iterator& first,
109 const OSQLColumns::const_iterator& last,
110 std::u16string_view _rVal,
111 const ::comphelper::UStringMixEqual& _rCase);
112
113 // the first two find methods are much faster than the one below
114 // search from first to last the column with the property _rProp equals the value _rVal
115 // when no such column exist last is returned
117 OSQLColumns::const_iterator find( OSQLColumns::const_iterator first,
118 const OSQLColumns::const_iterator& last,
119 const OUString& _rProp,
120 std::u16string_view _rVal,
121 const ::comphelper::UStringMixEqual& _rCase);
122
124 OOO_DLLPUBLIC_DBTOOLS void checkDisposed(bool _bThrow);
125
126#if HAVE_FEATURE_JAVA
133 OOO_DLLPUBLIC_DBTOOLS ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
134
141 OOO_DLLPUBLIC_DBTOOLS bool existsJavaClassByName( const ::rtl::Reference< jvmaccess::VirtualMachine >& _pJVM,std::u16string_view _sClassName );
142#endif
143}
144
145#define DECLARE_SERVICE_INFO() \
146 virtual OUString SAL_CALL getImplementationName( ) override; \
147 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; \
148 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override \
149
150#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \
151 OUString SAL_CALL classname::getImplementationName( ) \
152 { \
153 return implasciiname; \
154 } \
155 css::uno::Sequence< OUString > SAL_CALL classname::getSupportedServiceNames( ) \
156 { \
157 css::uno::Sequence< OUString > aSupported { serviceasciiname }; \
158 return aSupported; \
159 } \
160 sal_Bool SAL_CALL classname::supportsService( const OUString& rServiceName ) \
161 { \
162 return cppu::supportsService(this, rServiceName); \
163 } \
164
165#endif // INCLUDED_CONNECTIVITY_COMMONTOOLS_HXX
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~ORefVector() override
Definition: CommonTools.hxx:63
ORefVector & operator=(const ORefVector &_rRH)
Definition: CommonTools.hxx:74
std::vector< VectorVal > Vector
Definition: CommonTools.hxx:65
ORefVector(const ORefVector &rOther)
Definition: CommonTools.hxx:69
#define OOO_DLLPUBLIC_DBTOOLS
std::map< OUString, OSQLTable, comphelper::UStringMixLess > OSQLTables
Definition: CommonTools.hxx:56
ORefVector< css::uno::Reference< css::beans::XPropertySet > > OSQLColumns
Definition: CommonTools.hxx:95
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
Definition: dbtools.cxx:1958
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
Definition: CommonTools.cxx:51
std::vector< css::uno::WeakReferenceHelper > OWeakRefArray
Definition: CommonTools.hxx:53
css::uno::Reference< css::sdbcx::XColumnsSupplier > OSQLTable
Definition: CommonTools.hxx:54
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
OSQLColumns::const_iterator findRealName(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
Definition: dbtools.cxx:1967
sal_uInt16 sal_Unicode