LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/inc - luxenum.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 15 100.0 %
Date: 2012-12-27 Functions: 58 63 92.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             : 
      20             : #ifndef UDM_LUXENUM_HXX
      21             : #define UDM_LUXENUM_HXX
      22             : 
      23             : 
      24             : 
      25             : // USED SERVICES
      26             :     // BASE CLASSES
      27             :     // COMPONENTS
      28             :     // PARAMETERS
      29             : #include <map>
      30             : #include <algorithm>
      31             : 
      32             : 
      33             : namespace lux
      34             : {
      35             : 
      36             : typedef std::map< intt, String  > EnumValueMap;
      37             : 
      38             : 
      39             : template <class DIFF>
      40             : class Enum // : public Template_Base
      41             : {
      42             :   public:
      43             :     // TYPES
      44             :     typedef Enum< DIFF >    self;
      45             : 
      46             :     // LIFECYCLE
      47          90 :                         Enum(
      48             :                             DIFF                i_nValue,
      49             :                             const char *        i_sText )
      50          90 :                                                 :   nValue(i_nValue) { Values_()[nValue] = i_sText;
      51             :                                                                        // Sequence_().insert(
      52             :                                                                        //       std::lower_bound( Sequence_().begin(), Sequence_().end(), i_nValue ),
      53             :                                                                        //       i_nValue );
      54          90 :                                                                      }
      55        9561 :                         Enum(
      56             :                             DIFF                i_nValue )
      57        9561 :                                                 :   nValue(i_nValue) { ; }
      58      200799 :                         Enum(
      59             :                             intt                i_nValue = 0 )
      60      200799 :                                                 :   nValue(i_nValue) { if ( NOT CheckIntt(i_nValue) ) { csv_assert(false); } }
      61      321913 :                         Enum(
      62             :                             const self &        i_rEnum )
      63      321913 :                                                 :   nValue(i_rEnum.nValue) {;}
      64             : 
      65             :     self &              operator=(
      66             :                             DIFF                i_nValue )
      67             :                                                 { nValue = i_nValue; return *this; }
      68             :     self &              operator=(
      69             :                             intt                i_nValue )
      70             :                                                 { if ( CheckIntt(i_nValue) ) {nValue = DIFF(i_nValue);}
      71             :                                                   else {csv_assert(false);} return *this; }
      72       14712 :     self &              operator=(
      73             :                             const self &        i_rEnum )
      74       14712 :                                                 { nValue = i_rEnum.nValue; return *this; }
      75      219135 :                         operator DIFF() const   { return DIFF(nValue); }
      76             : 
      77             :     DIFF                operator()() const      { return nValue; }
      78       37100 :     const String  &     Text() const            { return Values_()[nValue]; }
      79             : 
      80             :   private:
      81             :     static EnumValueMap &
      82             :                         Values_();
      83      200799 :     bool                CheckIntt(
      84             :                             intt                i_nNumber )
      85      200799 :                                                 { return Values_().find(i_nNumber) != Values_().end(); }
      86             :     // DATA
      87             :     intt                nValue;
      88             : };
      89             : 
      90             : 
      91             : 
      92             : 
      93             : }   // namespace lux
      94             : #endif
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10