Update ooo320-m1
[ooovba.git] / autodoc / source / inc / luxenum.hxx
blobdd6c89df2c26b6a786ed7a0494b5aa94e8630a7c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: luxenum.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef UDM_LUXENUM_HXX
32 #define UDM_LUXENUM_HXX
36 // USED SERVICES
37 // BASE CLASSES
38 // COMPONENTS
39 // PARAMETERS
40 #include <map>
41 #include <algorithm>
44 namespace lux
47 typedef std::map< intt, String > EnumValueMap;
50 template <class DIFF>
51 class Enum // : public Template_Base
53 public:
54 // TYPES
55 typedef Enum< DIFF > self;
57 // LIFECYCLE
58 Enum(
59 DIFF i_nValue,
60 const char * i_sText )
61 : nValue(i_nValue) { Values_()[nValue] = i_sText;
62 // Sequence_().insert(
63 // std::lower_bound( Sequence_().begin(), Sequence_().end(), i_nValue ),
64 // i_nValue );
66 Enum(
67 DIFF i_nValue )
68 : nValue(i_nValue) { ; }
69 Enum(
70 intt i_nValue = 0 )
71 : nValue(i_nValue) { if ( NOT CheckIntt(i_nValue) ) { csv_assert(false); } }
72 Enum(
73 const self & i_rEnum )
74 : nValue(i_rEnum.nValue) {;}
76 self & operator=(
77 DIFF i_nValue )
78 { nValue = i_nValue; return *this; }
79 self & operator=(
80 intt i_nValue )
81 { if ( CheckIntt(i_nValue) ) {nValue = DIFF(i_nValue);}
82 else {csv_assert(false);} return *this; }
83 self & operator=(
84 const self & i_rEnum )
85 { nValue = i_rEnum.nValue; return *this; }
86 operator DIFF() const { return DIFF(nValue); }
88 DIFF operator()() const { return nValue; }
89 const String & Text() const { return Values_()[nValue]; }
91 private:
92 static EnumValueMap &
93 Values_();
94 bool CheckIntt(
95 intt i_nNumber )
96 { return Values_().find(i_nNumber) != Values_().end(); }
97 // DATA
98 intt nValue;
104 } // namespace lux
105 #endif