fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / stdtypes.h
blob6760033cf4510bae32e1720b50287773adfaa12a
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 .
20 #ifndef INCLUDED_FRAMEWORK_INC_STDTYPES_H
21 #define INCLUDED_FRAMEWORK_INC_STDTYPES_H
23 #include <algorithm>
24 #include <queue>
25 #include <unordered_map>
26 #include <vector>
28 #include "general.h"
30 #include <com/sun/star/awt/KeyEvent.hpp>
32 #include <cppuhelper/interfacecontainer.hxx>
33 #include <rtl/ustring.hxx>
35 namespace framework{
37 /**
38 Own hash functions used for stl-structures ... e.g. hash tables/maps ...
41 struct ShortHashCode
43 size_t operator()( const ::sal_Int16& nShort ) const
45 return (size_t)nShort;
49 struct Int32HashCode
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 +
62 //aEvent.KeyChar +
63 //aEvent.KeyFunc +
64 aEvent.Modifiers);
68 struct KeyEventEqualsFunc
70 bool operator()(const css::awt::KeyEvent& rKey1,
71 const css::awt::KeyEvent& rKey2) const
73 return (
74 (rKey1.KeyCode == rKey2.KeyCode ) &&
75 //(rKey1.KeyChar == rKey2.KeyChar ) &&
76 //(rKey1.KeyFunc == rKey2.KeyFunc ) &&
77 (rKey1.Modifiers == rKey2.Modifiers)
82 typedef ::std::vector< OUString > OUStringList;
84 // search for given element
85 template <class T>
86 typename std::vector<T>::iterator find( std::vector<T>& vec, const T& sElement )
88 return ::std::find(vec.begin(), vec.end(), sElement);
91 template <class T>
92 typename std::vector<T>::const_iterator find( const std::vector<T>& vec, const T& sElement )
94 return ::std::find(vec.begin(), vec.end(), sElement);
97 template <class T>
98 void free(std::vector<T>& vec)
100 OUStringList().swap(vec);
104 Basic hash based on a std::unordered_map() which provides key=[OUString] and value=[template type] pairs
105 It implements some additional funtionality which can be useful but
106 is missing at the normal hash implementation.
108 template< class TType >
109 class BaseHash : public std::unordered_map< OUString ,
110 TType ,
111 OUStringHash ,
112 std::equal_to< OUString > >
114 public:
116 // the only way to free used memory really!
117 void free()
119 BaseHash().swap( *this );// get rid of reserved capacity
124 Basic OUString hash.
125 Key and values are OUStrings.
127 typedef BaseHash< OUString > OUStringHashMap;
130 It can be used to map names (e.g. of properties) to her corresponding handles.
131 Our helper class OPropertySetHelper works optimized with handles but sometimes we have only a property name.
132 Mapping between these two parts of a property should be done in the fastest way :-)
135 typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString> ListenerHash;
137 } // namespace framework
139 #endif // INCLUDED_FRAMEWORK_INC_STDTYPES_H
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */