bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / inc / TSortIndex.hxx
blob6f2acdc01f9018fb3d22ffdb19d57217a6b67a02
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 typedef enum
29 SQL_ORDERBYKEY_NONE, // do not sort
30 SQL_ORDERBYKEY_DOUBLE, // numeric key
31 SQL_ORDERBYKEY_STRING // String Key
32 } OKeyType;
34 typedef enum
36 SQL_ASC = 1, // ascending
37 SQL_DESC = -1 // otherwise
38 } TAscendingOrder;
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,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);
64 ~OSortIndex();
66 inline static void * SAL_CALL operator new( size_t nSize )
67 { return ::rtl_allocateMemory( nSize ); }
68 inline static void * SAL_CALL operator new( size_t,void* _pHint )
69 { return _pHint; }
70 inline static void SAL_CALL operator delete( void * pMem )
71 { ::rtl_freeMemory( pMem ); }
72 inline static void SAL_CALL operator delete( void *,void* )
73 { }
76 /**
77 AddKeyValue appends a new value.
78 @param
79 pKeyValue the keyvalue to be appended
80 ATTENTION: when the sortindex is already frozen the parameter will be deleted
82 void AddKeyValue(OKeyValue * pKeyValue);
84 /**
85 Freeze freezes the sortindex so that new values could only be appended by their value
87 void Freeze();
89 /**
90 CreateKeySet creates the keyset which vaalues could be used to travel in your table/result
91 The returned keyset is frozen.
93 ::rtl::Reference<OKeySet> CreateKeySet();
97 // look at the name
98 bool IsFrozen() const { return m_bFrozen; }
99 // returns the current size of the keyvalues
100 size_t Count() const { return m_aKeyValues.size(); }
102 inline const ::std::vector<OKeyType>& getKeyType() const { return m_aKeyType; }
103 inline TAscendingOrder getAscending(::std::vector<TAscendingOrder>::size_type _nPos) const { return m_aAscending[_nPos]; }
108 The class OKeySet is a refcountable vector which also has a state.
109 This state gives information about if the keyset is fixed.
111 class OOO_DLLPUBLIC_DBTOOLS OKeySet : public ORefVector<sal_Int32>
113 bool m_bFrozen;
114 public:
115 OKeySet()
116 : ORefVector<sal_Int32>()
117 , m_bFrozen(false){}
118 OKeySet(Vector::size_type _nSize)
119 : ORefVector<sal_Int32>(_nSize)
120 , m_bFrozen(false){}
122 bool isFrozen() const { return m_bFrozen; }
123 void setFrozen(bool _bFrozen=true) { m_bFrozen = _bFrozen; }
126 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */