Debian Codegraph @

avogadro/core/types.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_CORE_TYPES_H
7 #define AVOGADRO_CORE_TYPES_H
8
9 namespace Avogadro {
10
11 /** Symbolic constants representing various built-in C++ types. */
12 enum Type
13 {
14 UnknownType = -1,
15 CharType,
16 UCharType,
17 ShortType,
18 UShortType,
19 IntType,
20 UIntType,
21 FloatType,
22 DoubleType
23 };
24
25 template <typename T>
26 class TypeTraits
27 {
28 public:
29 enum
30 {
31 EnumValue = -1
32 };
33 static const char* name() { return "Unsupported type."; }
34 };
35
36 template <>
37 class TypeTraits<char>
38 {
39 public:
40 enum
41 {
42 EnumValue = CharType
43 };
44 static const char* name() { return "char"; }
45 };
46
47 template <>
48 class TypeTraits<unsigned char>
49 {
50 public:
51 enum
52 {
53 EnumValue = UCharType
54 };
55 static const char* name() { return "unsigned char"; }
56 };
57
58 template <>
59 class TypeTraits<short>
60 {
61 public:
62 enum
63 {
64 EnumValue = ShortType
65 };
66 static const char* name() { return "short"; }
67 };
68
69 template <>
70 class TypeTraits<unsigned short>
71 {
72 public:
73 enum
74 {
75 EnumValue = UShortType
76 };
77 static const char* name() { return "unsigned short"; }
78 };
79
80 template <>
81 class TypeTraits<int>
82 {
83 public:
84 enum
85 {
86 EnumValue = IntType
87 };
88 static const char* name() { return "int"; }
89 };
90
91 template <>
92 class TypeTraits<unsigned int>
93 {
94 public:
95 enum
96 {
97 EnumValue = UIntType
98 };
99 static const char* name() { return "unsigned int"; }
100 };
101
102 template <>
103 class TypeTraits<float>
104 {
105 public:
106 enum
107 {
108 EnumValue = FloatType
109 };
110 static const char* name() { return "float"; }
111 };
112
113 template <>
114 class TypeTraits<double>
115 {
116 public:
117 enum
118 {
119 EnumValue = DoubleType
120 };
121 static const char* name() { return "double"; }
122 };
123
124 } // namespace Avogadro
125
126 #endif // AVOGADRO_CORE_H