nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / inc / TSortIndex.hxx
blobc0354316efd955db1b75a894d7d3e423f48a92d8
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
22 #include <connectivity/dbtoolsdllapi.hxx>
23 #include "TKeyValue.hxx"
25 namespace connectivity
27 enum class OKeyType
29 NONE, // do not sort
30 Double, // numeric key
31 String // String Key
34 enum class TAscendingOrder
36 ASC = 1, // ascending
37 DESC = -1 // otherwise
40 class OKeySet;
41 class OKeyValue; // simple class which holds a sal_Int32 and a std::vector<ORowSetValueDecoratorRef>
43 /**
44 The class OSortIndex can be used to implement a sorted index.
45 This can depend on the fields which should be sorted.
47 class OOO_DLLPUBLIC_DBTOOLS OSortIndex
49 public:
50 typedef std::vector<std::pair<sal_Int32, std::unique_ptr<OKeyValue>>> TIntValuePairVector;
51 typedef std::vector<OKeyType> TKeyTypeVector;
53 private:
54 TIntValuePairVector m_aKeyValues;
55 TKeyTypeVector m_aKeyType;
56 std::vector<TAscendingOrder> m_aAscending;
57 bool m_bFrozen;
59 public:
61 OSortIndex( const std::vector<OKeyType>& _aKeyType,
62 const std::vector<TAscendingOrder>& _aAscending);
63 OSortIndex(OSortIndex const &) = delete; // MSVC2015 workaround
64 OSortIndex& operator=(OSortIndex const &) = delete; // MSVC2015 workaround
66 ~OSortIndex();
68 /**
69 AddKeyValue appends a new value.
70 @param
71 pKeyValue the keyvalue to be appended
72 ATTENTION: when the sortindex is already frozen the parameter will be deleted
74 void AddKeyValue(std::unique_ptr<OKeyValue> pKeyValue);
76 /**
77 Freeze freezes the sortindex so that new values could only be appended by their value
79 void Freeze();
81 /**
82 CreateKeySet creates the keyset which values could be used to travel in your table/result
83 The returned keyset is frozen.
85 ::rtl::Reference<OKeySet> CreateKeySet();
87 const std::vector<OKeyType>& getKeyType() const { return m_aKeyType; }
88 TAscendingOrder getAscending(std::vector<TAscendingOrder>::size_type _nPos) const { return m_aAscending[_nPos]; }
92 // MSVC hack to avoid multiply defined std::vector-related symbols:
93 class OKeySet_Base: public ORefVector<sal_Int32> {};
95 /**
96 The class OKeySet is a refcountable vector which also has a state.
97 This state gives information about if the keyset is fixed.
99 class OOO_DLLPUBLIC_DBTOOLS OKeySet : public OKeySet_Base
101 bool m_bFrozen;
102 public:
103 OKeySet()
104 : m_bFrozen(false){}
106 bool isFrozen() const { return m_bFrozen; }
107 void setFrozen() { m_bFrozen = true; }
110 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */