LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/comphelper - InlineContainer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 26 42.3 %
Date: 2012-12-27 Functions: 18 31 58.1 %
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_COMPHELPER_INLINE_CONTAINER_HXX
      20             : #define INCLUDED_COMPHELPER_INLINE_CONTAINER_HXX
      21             : 
      22             : #include <com/sun/star/uno/Sequence.hxx>
      23             : 
      24             : #include <vector>
      25             : #include <map>
      26             : #include <set>
      27             : 
      28             : namespace comphelper
      29             : {
      30             : 
      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.
      34             : 
      35             :     usage:
      36             : 
      37             :     uno::Sequence< t >( MakeSequence< t >( t_1 )( t_2 )...( t_n ) );
      38             :  */
      39             : template < typename T >
      40             : class MakeSequence : public ::com::sun::star::uno::Sequence< T >
      41             : {
      42             : public:
      43             :     explicit MakeSequence(const T &a)
      44             :         : ::com::sun::star::uno::Sequence< T >( 1 )
      45             :     {
      46             :         this->operator[](0) = a;
      47             :     }
      48             :     MakeSequence& operator()(const T &a)
      49             :     {
      50             :         this->realloc( this->getLength() + 1 );
      51             :         this->operator[]( this->getLength() - 1 ) = a;
      52             :         return *this;
      53             :     }
      54             : };
      55             : 
      56             : // ----------------------------------------
      57             : 
      58             : /** Creates a vector which contains an arbitrary number of elements.
      59             : 
      60             :     usage:
      61             : 
      62             :     vector< t > aVec( MakeVector< t >( t_1 )( t_2 )...( t_n ) );
      63             :  */
      64             : template < typename T >
      65           0 : class MakeVector : public ::std::vector< T >
      66             : {
      67             : public:
      68           0 :     explicit MakeVector(const T &a)
      69           0 :         : ::std::vector< T >(1, a)
      70             :     {
      71           0 :     }
      72           0 :     MakeVector &operator()(const T &a)
      73             :     {
      74           0 :         this->push_back(a);
      75           0 :         return *this;
      76             :     }
      77             : };
      78             : 
      79             : // ----------------------------------------
      80             : 
      81             : /** Creates a set which contains an arbitrary number of elements.
      82             : 
      83             :     usage:
      84             : 
      85             :     set< t > aSet( MakeSet< t >( t_1 )( t_2 )...( t_n ) );
      86             :  */
      87             : template < typename T >
      88           0 : class MakeSet : public ::std::set< T >
      89             : {
      90             : public:
      91           0 :     explicit MakeSet(const T &a)
      92           0 :         : ::std::set< T >()
      93             :     {
      94           0 :         this->insert(this->end(), a);
      95           0 :     }
      96           0 :     MakeSet &operator()(const T &a)
      97             :     {
      98           0 :         this->insert(this->end(), a);
      99           0 :         return *this;
     100             :     }
     101             : };
     102             : 
     103             : // ----------------------------------------
     104             : 
     105             : /** usage:
     106             : 
     107             :     map< k, v > aMap( MakeMap< k, v >
     108             :     ( key_1, value_1 )
     109             :     ( key_2, value_2 )
     110             :     ( key_3, value_3 )
     111             :     ...
     112             :     ( key_n, value_n )
     113             :     );
     114             :  */
     115             : template < typename Key, typename Value >
     116          25 : class MakeMap : public ::std::map< Key, Value >
     117             : {
     118             : private:
     119             :     typedef typename ::std::map< Key, Value >::value_type value_type;
     120             : public:
     121           9 :     explicit MakeMap( const Key &k, const Value &v )
     122           9 :     {
     123           9 :         this->insert( value_type( k, v ) );
     124           9 :     }
     125         183 :     MakeMap &operator()( const Key &k, const Value &v )
     126             :     {
     127         183 :         this->insert( value_type( k, v ) );
     128         183 :         return *this;
     129             :     }
     130             : 
     131           1 :     MakeMap &operator()( const MakeMap& rSource )
     132             :     {
     133           1 :         this->insert(rSource.begin(),rSource.end());
     134           1 :         return *this;
     135             :     }
     136             : };
     137             : 
     138             : } // namespace comphelper
     139             : 
     140             : #endif
     141             : // INCLUDED_COMPHELPER_INLINE_CONTAINER_HXX
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10