LCOV - code coverage report
Current view: top level - connectivity/source/inc - TSortIndex.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 11 11 100.0 %
Date: 2015-06-13 12:38:46 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
      20             : #define INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
      21             : 
      22             : #include <connectivity/dbtoolsdllapi.hxx>
      23             : #include "TKeyValue.hxx"
      24             : 
      25             : namespace connectivity
      26             : {
      27             :     typedef enum
      28             :     {
      29             :         SQL_ORDERBYKEY_NONE,        // do not sort
      30             :         SQL_ORDERBYKEY_DOUBLE,      // numeric key
      31             :         SQL_ORDERBYKEY_STRING       // String Key
      32             :     } OKeyType;
      33             : 
      34             :     typedef enum
      35             :     {
      36             :         SQL_ASC     = 1,            // ascending
      37             :         SQL_DESC    = -1            // otherwise
      38             :     } TAscendingOrder;
      39             : 
      40             :     class OKeySet;
      41             :     class OKeyValue;                // simple class which holds a sal_Int32 and a ::std::vector<ORowSetValueDecoratorRef>
      42             : 
      43             :     /**
      44             :         The class OSortIndex can be used to implement a sorted index.
      45             :         This can depend on the fields which should be sorted.
      46             :     */
      47             :     class OOO_DLLPUBLIC_DBTOOLS OSortIndex
      48             :     {
      49             :     public:
      50             :         typedef ::std::vector< ::std::pair<sal_Int32,OKeyValue*> >  TIntValuePairVector;
      51             :         typedef ::std::vector<OKeyType>                             TKeyTypeVector;
      52             : 
      53             :     private:
      54             :         TIntValuePairVector             m_aKeyValues;
      55             :         TKeyTypeVector                  m_aKeyType;
      56             :         ::std::vector<TAscendingOrder>  m_aAscending;
      57             :         bool                        m_bFrozen;
      58             : 
      59             :     public:
      60             : 
      61             :         OSortIndex( const ::std::vector<OKeyType>& _aKeyType,
      62             :                     const ::std::vector<TAscendingOrder>& _aAscending);
      63             : 
      64             :         ~OSortIndex();
      65             : 
      66           1 :         inline static void * SAL_CALL operator new( size_t nSize )
      67           1 :             { return ::rtl_allocateMemory( nSize ); }
      68             :         inline static void * SAL_CALL operator new( size_t,void* _pHint )
      69             :             { return _pHint; }
      70           1 :         inline static void SAL_CALL operator delete( void * pMem )
      71           1 :             { ::rtl_freeMemory( pMem ); }
      72             :         inline static void SAL_CALL operator delete( void *,void* )
      73             :             {  }
      74             : 
      75             : 
      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
      81             :         */
      82             :         void AddKeyValue(OKeyValue * pKeyValue);
      83             : 
      84             :         /**
      85             :             Freeze freezes the sortindex so that new values could only be appended by their value
      86             :         */
      87             :         void Freeze();
      88             : 
      89             :         /**
      90             :             CreateKeySet creates the keyset which vaalues could be used to travel in your table/result
      91             :             The returned keyset is frozen.
      92             :         */
      93             :         ::rtl::Reference<OKeySet> CreateKeySet();
      94             : 
      95             : 
      96             : 
      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(); }
     101             : 
     102          89 :         inline const ::std::vector<OKeyType>& getKeyType() const { return m_aKeyType; }
     103          89 :         inline TAscendingOrder getAscending(::std::vector<TAscendingOrder>::size_type _nPos) const { return m_aAscending[_nPos]; }
     104             : 
     105             :     };
     106             : 
     107             :     /**
     108             :         The class OKeySet is a refcountable vector which also has a state.
     109             :         This state gives information about if the keyset is fixed.
     110             :     */
     111          62 :     class OOO_DLLPUBLIC_DBTOOLS OKeySet : public ORefVector<sal_Int32>
     112             :     {
     113             :         bool m_bFrozen;
     114             :     public:
     115          31 :         OKeySet()
     116             :             : ORefVector<sal_Int32>()
     117          31 :             , m_bFrozen(false){}
     118             :         OKeySet(Vector::size_type _nSize)
     119             :             : ORefVector<sal_Int32>(_nSize)
     120             :             , m_bFrozen(false){}
     121             : 
     122        2196 :         bool    isFrozen() const                        { return m_bFrozen; }
     123          30 :         void        setFrozen(bool _bFrozen=true)   { m_bFrozen = _bFrozen; }
     124             :     };
     125             : }
     126             : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_TSORTINDEX_HXX
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11