bump product version to 4.1.6.2
[LibreOffice.git] / autodoc / source / inc / luxenum.hxx
blob35a7522ec8d46e4b9e62017c2a6ef9ab525fe594
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 UDM_LUXENUM_HXX
21 #define UDM_LUXENUM_HXX
25 // USED SERVICES
26 // BASE CLASSES
27 // COMPONENTS
28 // PARAMETERS
29 #include <map>
30 #include <algorithm>
33 namespace lux
36 typedef std::map< intt, String > EnumValueMap;
39 template <class DIFF>
40 class Enum // : public Template_Base
42 public:
43 // TYPES
44 typedef Enum< DIFF > self;
46 // LIFECYCLE
47 Enum(
48 DIFF i_nValue,
49 const char * i_sText )
50 : nValue(i_nValue) { Values_()[nValue] = i_sText;
51 // Sequence_().insert(
52 // std::lower_bound( Sequence_().begin(), Sequence_().end(), i_nValue ),
53 // i_nValue );
55 Enum(
56 DIFF i_nValue )
57 : nValue(i_nValue) { ; }
58 Enum(
59 intt i_nValue = 0 )
60 : nValue(i_nValue) { if ( NOT CheckIntt(i_nValue) ) { csv_assert(false); } }
61 Enum(
62 const self & i_rEnum )
63 : nValue(i_rEnum.nValue) {;}
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 self & operator=(
73 const self & i_rEnum )
74 { nValue = i_rEnum.nValue; return *this; }
75 operator DIFF() const { return DIFF(nValue); }
77 DIFF operator()() const { return nValue; }
78 const String & Text() const { return Values_()[nValue]; }
80 private:
81 static EnumValueMap &
82 Values_();
83 bool CheckIntt(
84 intt i_nNumber )
85 { return Values_().find(i_nNumber) != Values_().end(); }
86 // DATA
87 intt nValue;
93 } // namespace lux
94 #endif
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */