update emoji autocorrect entries from po-files
[LibreOffice.git] / include / comphelper / InlineContainer.hxx
blob482c62668e42e9e13d6c6f8858cd27c2d02fb144
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_COMPHELPER_INLINECONTAINER_HXX
20 #define INCLUDED_COMPHELPER_INLINECONTAINER_HXX
22 #include <com/sun/star/uno/Sequence.hxx>
24 #include <vector>
25 #include <map>
26 #include <set>
28 namespace comphelper
31 /** Creates a UNO-Sequence which contains an arbitrary number of elements.
32 Notice, that every call of the operator() issues a realloc, so this is not
33 suitable to create very large sequences.
35 usage:
37 uno::Sequence< t >( MakeSequence< t >( t_1 )( t_2 )...( t_n ) );
39 template < typename T >
40 class MakeSequence : public ::com::sun::star::uno::Sequence< T >
42 public:
43 explicit MakeSequence(const T &a)
44 : ::com::sun::star::uno::Sequence< T >( 1 )
46 this->operator[](0) = a;
48 MakeSequence& operator()(const T &a)
50 this->realloc( this->getLength() + 1 );
51 this->operator[]( this->getLength() - 1 ) = a;
52 return *this;
58 /** Creates a vector which contains an arbitrary number of elements.
60 usage:
62 vector< t > aVec( MakeVector< t >( t_1 )( t_2 )...( t_n ) );
64 template < typename T >
65 class MakeVector : public ::std::vector< T >
67 public:
68 explicit MakeVector(const T &a)
69 : ::std::vector< T >(1, a)
72 MakeVector &operator()(const T &a)
74 this->push_back(a);
75 return *this;
81 /** Creates a set which contains an arbitrary number of elements.
83 usage:
85 set< t > aSet( MakeSet< t >( t_1 )( t_2 )...( t_n ) );
87 template < typename T >
88 class MakeSet : public ::std::set< T >
90 public:
91 explicit MakeSet(const T &a)
92 : ::std::set< T >()
94 this->insert(this->end(), a);
96 MakeSet &operator()(const T &a)
98 this->insert(this->end(), a);
99 return *this;
105 /** usage:
107 map< k, v > aMap( MakeMap< k, v >
108 ( key_1, value_1 )
109 ( key_2, value_2 )
110 ( key_3, value_3 )
112 ( key_n, value_n )
115 template < typename Key, typename Value >
116 class MakeMap : public ::std::map< Key, Value >
118 private:
119 typedef typename ::std::map< Key, Value >::value_type value_type;
120 public:
121 explicit MakeMap( const Key &k, const Value &v )
123 this->insert( value_type( k, v ) );
125 MakeMap &operator()( const Key &k, const Value &v )
127 this->insert( value_type( k, v ) );
128 return *this;
131 MakeMap &operator()( const MakeMap& rSource )
133 this->insert(rSource.begin(),rSource.end());
134 return *this;
138 } // namespace comphelper
140 #endif
141 // INCLUDED_COMPHELPER_INLINECONTAINER_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */