xref: /trunk/main/connectivity/source/inc/TKeyValue.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef CONNECTIVITY_TKEYVALUE_HXX
28 #define CONNECTIVITY_TKEYVALUE_HXX
29 
30 #include "connectivity/FValue.hxx"
31 #include "connectivity/dbtoolsdllapi.hxx"
32 
33 namespace connectivity
34 {
35     class OOO_DLLPUBLIC_DBTOOLS OKeyValue
36     {
37     private:
38         ::std::vector<ORowSetValueDecoratorRef> m_aKeys;
39         sal_Int32 m_nValue;
40 
41     protected:
42         OKeyValue();
43         OKeyValue(sal_Int32 nVal);
44     public:
45 
46         ~OKeyValue();
47 
48         inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
49             { return ::rtl_allocateMemory( nSize ); }
50         inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
51             { return _pHint; }
52         inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
53             { ::rtl_freeMemory( pMem ); }
54         inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
55             {  }
56 
57         static OKeyValue* createKeyValue(sal_Int32 nVal);
58         //  static OKeyValue* createEmptyKeyValue();
59 
60         inline void pushKey(const ORowSetValueDecoratorRef& _aValueRef)
61         {
62             m_aKeys.push_back(_aValueRef);
63         }
64         inline void setValue(sal_Int32 nVal) { m_nValue = nVal; }
65 
66         ::rtl::OUString getKeyString(::std::vector<ORowSetValueDecoratorRef>::size_type i) const
67         {
68             OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue");
69             return m_aKeys[i]->getValue();
70         }
71         double          getKeyDouble(::std::vector<ORowSetValueDecoratorRef>::size_type i) const
72         {
73             OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue");
74             return m_aKeys[i]->getValue();
75         }
76 
77         inline sal_Int32 getValue() const { return m_nValue; }
78     };
79 }
80 
81 #endif // CONNECTIVITY_TKEYVALUE_HXX
82 
83