tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / inc / TSortIndex.hxx
blob3ac339f7e9f079e4119e737e7e951922cbb42664
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 #pragma once
21 #include <connectivity/dbtoolsdllapi.hxx>
22 #include "TKeyValue.hxx"
24 namespace connectivity
26 enum class OKeyType
28 NONE, // do not sort
29 Double, // numeric key
30 String // String Key
33 enum class TAscendingOrder
35 ASC = 1, // ascending
36 DESC = -1 // otherwise
39 class OKeySet;
40 class OKeyValue; // simple class which holds a sal_Int32 and a std::vector<ORowSetValueDecoratorRef>
42 /**
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
48 public:
49 typedef std::vector<std::pair<sal_Int32, std::unique_ptr<OKeyValue>>> TIntValuePairVector;
50 typedef std::vector<OKeyType> TKeyTypeVector;
52 private:
53 TIntValuePairVector m_aKeyValues;
54 TKeyTypeVector m_aKeyType;
55 std::vector<TAscendingOrder> m_aAscending;
56 bool m_bFrozen;
58 public:
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
65 ~OSortIndex();
67 /**
68 AddKeyValue appends a new value.
69 @param
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);
75 /**
76 Freeze freezes the sortindex so that new values could only be appended by their value
78 void Freeze();
80 /**
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> {};
94 /**
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
100 bool m_bFrozen;
101 public:
102 OKeySet()
103 : m_bFrozen(false){}
105 bool isFrozen() const { return m_bFrozen; }
106 void setFrozen() { m_bFrozen = true; }
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */