1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef __FRAMEWORK_STDTYPES_H_
21 #define __FRAMEWORK_STDTYPES_H_
25 #include <boost/unordered_map.hpp>
29 #include <com/sun/star/awt/KeyEvent.hpp>
31 #include <comphelper/sequenceasvector.hxx>
32 #include <cppuhelper/interfacecontainer.hxx>
33 #include <rtl/ustring.hxx>
38 Own hash functions used for stl-structures ... e.g. hash tables/maps ...
43 size_t operator()( const ::sal_Int16
& nShort
) const
45 return (size_t)nShort
;
51 size_t operator()( const ::sal_Int32
& nValue
) const
53 return (size_t)nValue
;
57 struct KeyEventHashCode
59 size_t operator()( const css::awt::KeyEvent
& aEvent
) const
61 return (size_t)(aEvent
.KeyCode
+
68 struct KeyEventEqualsFunc
70 bool operator()(const css::awt::KeyEvent aKey1
,
71 const css::awt::KeyEvent aKey2
) const
74 (aKey1
.KeyCode
== aKey2
.KeyCode
) &&
75 //(aKey1.KeyChar == aKey2.KeyChar ) &&
76 //(aKey1.KeyFunc == aKey2.KeyFunc ) &&
77 (aKey1
.Modifiers
== aKey2
.Modifiers
)
82 //_________________________________________________________________________________________________________________
85 Basic string list based on a std::vector()
86 It implements some additional funtionality which can be useful but
87 is missing at the normal vector implementation.
89 class OUStringList
: public ::comphelper::SequenceAsVector
< OUString
>
93 // insert given element as the first one into the vector
94 void push_front( const OUString
& sElement
)
96 insert( begin(), sElement
);
99 // search for given element
100 iterator
find( const OUString
& sElement
)
102 return ::std::find(begin(), end(), sElement
);
105 const_iterator
findConst( const OUString
& sElement
) const
107 return ::std::find(begin(), end(), sElement
);
110 // the only way to free used memory realy!
113 OUStringList().swap( *this );
117 //_________________________________________________________________________________________________________________
120 Basic string queue based on a std::queue()
121 It implements some additional funtionality which can be useful but
122 is missing at the normal std implementation.
124 typedef ::std::queue
< OUString
> OUStringQueue
;
126 //_________________________________________________________________________________________________________________
129 Basic hash based on a boost::unordered_map() which provides key=[OUString] and value=[template type] pairs
130 It implements some additional funtionality which can be useful but
131 is missing at the normal hash implementation.
133 template< class TType
>
134 class BaseHash
: public ::boost::unordered_map
< OUString
,
137 ::std::equal_to
< OUString
> >
141 // the only way to free used memory realy!
144 BaseHash().swap( *this );
148 //_________________________________________________________________________________________________________________
152 Key and values are OUStrings.
154 typedef BaseHash
< OUString
> OUStringHashMap
;
156 //_________________________________________________________________________________________________________________
159 It can be used to map names (e.g. of properties) to her corresponding handles.
160 Our helper class OPropertySetHelper works optimized with handles but sometimes we have only a property name.
161 Mapping between these two parts of a property should be done in the fastest way :-)
163 typedef BaseHash
< sal_Int32
> NameToHandleHash
;
165 //_________________________________________________________________________________________________________________
168 Sometimes we need this template to implement listener container ...
169 and we need it at different positions ...
170 So it's better to declare it one times only!
172 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar
< OUString
,
174 ::std::equal_to
< OUString
> > ListenerHash
;
176 } // namespace framework
178 #endif // #ifndef __FRAMEWORK_STDTYPES_H_
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */