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 .
21 #include <connectivity/dbtoolsdllapi.hxx>
22 #include "TKeyValue.hxx"
24 namespace connectivity
29 Double
, // numeric key
33 enum class TAscendingOrder
36 DESC
= -1 // otherwise
40 class OKeyValue
; // simple class which holds a sal_Int32 and a std::vector<ORowSetValueDecoratorRef>
43 The class OSortIndex can be used to implement a sorted index.
44 This can depend on the fields which should be sorted.
46 class OOO_DLLPUBLIC_DBTOOLS OSortIndex
49 typedef std::vector
<std::pair
<sal_Int32
, std::unique_ptr
<OKeyValue
>>> TIntValuePairVector
;
50 typedef std::vector
<OKeyType
> TKeyTypeVector
;
53 TIntValuePairVector m_aKeyValues
;
54 TKeyTypeVector m_aKeyType
;
55 std::vector
<TAscendingOrder
> m_aAscending
;
60 OSortIndex( std::vector
<OKeyType
>&& _aKeyType
,
61 std::vector
<TAscendingOrder
>&& _aAscending
);
62 OSortIndex(OSortIndex
const &) = delete; // MSVC2015 workaround
63 OSortIndex
& operator=(OSortIndex
const &) = delete; // MSVC2015 workaround
68 AddKeyValue appends a new value.
70 pKeyValue the keyvalue to be appended
71 ATTENTION: when the sortindex is already frozen the parameter will be deleted
73 void AddKeyValue(std::unique_ptr
<OKeyValue
> pKeyValue
);
76 Freeze freezes the sortindex so that new values could only be appended by their value
81 CreateKeySet creates the keyset which values could be used to travel in your table/result
82 The returned keyset is frozen.
84 ::rtl::Reference
<OKeySet
> CreateKeySet();
86 const std::vector
<OKeyType
>& getKeyType() const { return m_aKeyType
; }
87 TAscendingOrder
getAscending(std::vector
<TAscendingOrder
>::size_type _nPos
) const { return m_aAscending
[_nPos
]; }
91 // MSVC hack to avoid multiply defined std::vector-related symbols:
92 class OKeySet_Base
: public ORefVector
<sal_Int32
> {};
95 The class OKeySet is a refcountable vector which also has a state.
96 This state gives information about if the keyset is fixed.
98 class OOO_DLLPUBLIC_DBTOOLS OKeySet
: public OKeySet_Base
105 bool isFrozen() const { return m_bFrozen
; }
106 void setFrozen() { m_bFrozen
= true; }
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */