LibreOffice Module ucbhelper (master)  1
propertyvalueset.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 
20 #ifndef INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
21 #define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
22 
23 #include <com/sun/star/sdbc/XColumnLocate.hpp>
24 #include <com/sun/star/sdbc/XRow.hpp>
25 #include <com/sun/star/beans/Property.hpp>
26 #include <cppuhelper/implbase.hxx>
27 
28 #include <osl/mutex.hxx>
30 #include <memory>
31 
32 namespace com::sun::star::script {
33  class XTypeConverter;
34 }
35 
36 namespace com::sun::star::beans {
37  class XPropertySet;
38 }
39 
40 namespace com::sun::star::uno { class XComponentContext; }
41 
42 enum class PropsSet;
43 namespace ucbhelper_impl { struct PropertyValue; }
44 
45 namespace ucbhelper {
46 
47 class PropertyValues;
48 
49 
58  public cppu::WeakImplHelper<
59  css::sdbc::XRow,
60  css::sdbc::XColumnLocate>
61 {
62  css::uno::Reference< css::uno::XComponentContext > m_xContext;
63  css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
64  osl::Mutex m_aMutex;
65  std::unique_ptr<PropertyValues> m_pValues;
66  bool m_bWasNull;
68 
69 private:
70  UCBHELPER_DLLPRIVATE const css::uno::Reference< css::script::XTypeConverter >&
72 
73  template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
74  T getValue(PropsSet nTypeName, sal_Int32 columnIndex);
75 
76  template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
77  void appendValue(const OUString& rPropName, PropsSet nTypeName, const T& rValue);
78 
79 public:
81  const css::uno::Reference< css::uno::XComponentContext >& rxContext );
82  virtual ~PropertyValueSet() override;
83 
84  // XRow
85  virtual sal_Bool SAL_CALL
86  wasNull() override;
87  virtual OUString SAL_CALL
88  getString( sal_Int32 columnIndex ) override;
89  virtual sal_Bool SAL_CALL
90  getBoolean( sal_Int32 columnIndex ) override;
91  virtual sal_Int8 SAL_CALL
92  getByte( sal_Int32 columnIndex ) override;
93  virtual sal_Int16 SAL_CALL
94  getShort( sal_Int32 columnIndex ) override;
95  virtual sal_Int32 SAL_CALL
96  getInt( sal_Int32 columnIndex ) override;
97  virtual sal_Int64 SAL_CALL
98  getLong( sal_Int32 columnIndex ) override;
99  virtual float SAL_CALL
100  getFloat( sal_Int32 columnIndex ) override;
101  virtual double SAL_CALL
102  getDouble( sal_Int32 columnIndex ) override;
103  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
104  getBytes( sal_Int32 columnIndex ) override;
105  virtual css::util::Date SAL_CALL
106  getDate( sal_Int32 columnIndex ) override;
107  virtual css::util::Time SAL_CALL
108  getTime( sal_Int32 columnIndex ) override;
109  virtual css::util::DateTime SAL_CALL
110  getTimestamp( sal_Int32 columnIndex ) override;
111  virtual css::uno::Reference<
112  css::io::XInputStream > SAL_CALL
113  getBinaryStream( sal_Int32 columnIndex ) override;
114  virtual css::uno::Reference<
115  css::io::XInputStream > SAL_CALL
116  getCharacterStream( sal_Int32 columnIndex ) override;
117  virtual css::uno::Any SAL_CALL
118  getObject( sal_Int32 columnIndex,
119  const css::uno::Reference<
120  css::container::XNameAccess >& typeMap ) override;
121  virtual css::uno::Reference<
122  css::sdbc::XRef > SAL_CALL
123  getRef( sal_Int32 columnIndex ) override;
124  virtual css::uno::Reference<
125  css::sdbc::XBlob > SAL_CALL
126  getBlob( sal_Int32 columnIndex ) override;
127  virtual css::uno::Reference<
128  css::sdbc::XClob > SAL_CALL
129  getClob( sal_Int32 columnIndex ) override;
130  virtual css::uno::Reference<
131  css::sdbc::XArray > SAL_CALL
132  getArray( sal_Int32 columnIndex ) override;
133 
134  // XColumnLocate
135  virtual sal_Int32 SAL_CALL
136  findColumn( const OUString& columnName ) override;
137 
138 
139  // Non-interface methods
140 
141  void appendString( const OUString& rPropName, const OUString& rValue );
142  void appendString( const css::beans::Property& rProp, const OUString& rValue )
143  {
144  appendString( rProp.Name, rValue );
145  }
146 
147  void appendBoolean( const OUString& rPropName, bool bValue );
148  void appendBoolean( const css::beans::Property& rProp, bool bValue )
149  {
150  appendBoolean( rProp.Name, bValue );
151  }
152 
153  void appendLong( const OUString& rPropName, sal_Int64 nValue );
154  void appendLong( const css::beans::Property& rProp, sal_Int64 nValue )
155  {
156  appendLong( rProp.Name, nValue );
157  }
158 
159  void appendTimestamp( const OUString& rPropName, const css::util::DateTime& rValue );
160  void appendTimestamp( const css::beans::Property& rProp, const css::util::DateTime& rValue )
161  {
162  appendTimestamp( rProp.Name, rValue );
163  }
164 
165  void appendObject( const OUString& rPropName, const css::uno::Any& rValue );
166  void appendObject( const css::beans::Property& rProp, const css::uno::Any& rValue )
167  {
168  appendObject( rProp.Name, rValue );
169  }
170 
171  void appendVoid( const OUString& rPropName );
172  void appendVoid( const css::beans::Property& rProp )
173  {
174  appendVoid( rProp.Name );
175  }
176 
183  void appendPropertySet( const css::uno::Reference< css::beans::XPropertySet >& rSet );
184 
194  bool appendPropertySetValue(
195  const css::uno::Reference< css::beans::XPropertySet >& rSet,
196  const css::beans::Property& rProperty );
197 };
198 
199 }
200 
201 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define UCBHELPER_DLLPRIVATE
float getFloat(const Any &_rAny)
css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter
signed char sal_Int8
css::beans::Optional< css::uno::Any > getValue(OUString const &id)
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::map< sal_Int32, std::shared_ptr< SetItemPropertyStorage > > PropertyValues
void appendString(const css::beans::Property &rProp, const OUString &rValue)
void appendLong(const css::beans::Property &rProp, sal_Int64 nValue)
class SAL_NO_VTABLE XPropertySet
unsigned char sal_Bool
void appendVoid(const css::beans::Property &rProp)
std::unique_ptr< PropertyValues > m_pValues
void appendBoolean(const css::beans::Property &rProp, bool bValue)
double getDouble(const Any &_rAny)
#define UCBHELPER_DLLPUBLIC
uno::Reference< script::XTypeConverter > const & getTypeConverter(const uno::Reference< uno::XComponentContext > &xContext)
OUString getString(const Any &_rAny)
This class implements the interface XRow.
void appendObject(const css::beans::Property &rProp, const css::uno::Any &rValue)
void appendTimestamp(const css::beans::Property &rProp, const css::util::DateTime &rValue)