OpenMS
Types.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Oliver Kohlbacher $
6 // $Authors: Marc Sturm, Clemens Groepl $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/config.h>
12 
13 #include <ctime>
14 #include <cstddef> // for size_t & ptrdiff_t
15 #include <limits>
16 
17 // If possible use the ISO C99-compliant header stdint.h
18 // to define the portable integer types.
19 #ifdef OPENMS_HAS_STDINT_H
20 #include <cstdint>
21 #endif
22 
23 namespace OpenMS
24 {
30  typedef OPENMS_INT32_TYPE Int32;
31 
37  typedef OPENMS_UINT32_TYPE UInt32;
38 
44  typedef OPENMS_INT64_TYPE Int64;
45 
51  typedef OPENMS_UINT64_TYPE UInt64;
52 
60  typedef time_t Time;
61 
67  //typedef size_t UInt;
68  typedef unsigned int UInt;
69 
75  //typedef OPENMS_SIZE_T_SIGNED Int;
76  typedef int Int;
77 
85  typedef OPENMS_BYTE_TYPE Byte;
86 
94  typedef OPENMS_UINT64_TYPE UID;
95 
101  typedef size_t Size;
102 
108  typedef ptrdiff_t SignedSize;
109 
110  enum ASCII
111  {
113  ASCII__BELL = '\a',
121 
127  ASCII__SEMICOLON = ';'
128  };
129 
131 
174 
175 
181  template <typename FloatingPointType>
182  inline constexpr Int writtenDigits(const FloatingPointType& /* unused */ = FloatingPointType());
183 
185  template <>
186  inline constexpr Int writtenDigits<float>(const float&)
187  {
188  return std::numeric_limits<float>::digits10;
189  }
190 
192  template <>
193  inline constexpr Int writtenDigits<double>(const double&)
194  {
195  return std::numeric_limits<double>::digits10;
196  }
197 
199  template <>
200  inline constexpr Int writtenDigits<int>(const int&)
201  {
202  return std::numeric_limits<int>::digits10;
203  }
204 
206  template <>
207  inline constexpr Int writtenDigits<unsigned int>(const unsigned int&)
208  {
209  return std::numeric_limits<unsigned int>::digits10;
210  }
211 
213  template <>
214  inline constexpr Int writtenDigits<long int>(const long int&)
215  {
216  return std::numeric_limits<int>::digits10;
217  }
218 
220  template <>
221  inline constexpr Int writtenDigits<unsigned long int>(const unsigned long int&)
222  {
223  return std::numeric_limits<unsigned int>::digits10;
224  }
225 
226  class DataValue;
228  template <>
229  inline constexpr Int writtenDigits<DataValue>(const DataValue&)
230  {
231  return std::numeric_limits<double>::digits10;
232  }
233 
234  /*
235  META-COMMENT: DO NOT INTRODUCE ANY LINEBREAKS BELOW IN
236  "<code>std::numeric_limits<long double>::digits10 == 18</code>".
237  The doxygen parser (version 1.5.5) will get confused! (Clemens)
238  */
239 
251  template <>
252  inline constexpr Int writtenDigits<long double>(const long double&)
253  {
254 #ifndef OPENMS_WINDOWSPLATFORM
255  return std::numeric_limits<long double>::digits10;
256 
257 #else
258  return std::numeric_limits<double>::digits10;
259 
260 #endif
261  }
262 
267  template <typename FloatingPointType>
268  inline constexpr Int writtenDigits(const FloatingPointType& /* unused */)
269  {
270  return 6;
271  }
272 
273  namespace Internal
274  {
281  extern OPENMS_DLLAPI const char* OpenMS_locale;
282  }
283 
284 } // namespace OpenMS
285 
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:33
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:85
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:37
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
int Int
Signed integer type.
Definition: Types.h:76
OPENMS_INT32_TYPE Int32
Signed integer type (32bit)
Definition: Types.h:30
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:44
OPENMS_UINT64_TYPE UID
A unique object ID (as unsigned 64bit type).
Definition: Types.h:94
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:108
time_t Time
Time type.
Definition: Types.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
const char * OpenMS_locale
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
ASCII
Definition: Types.h:111
@ ASCII__EXCLAMATION_MARK
Definition: Types.h:124
@ ASCII__HORIZONTAL_TAB
Definition: Types.h:115
@ ASCII__BACKSPACE
Definition: Types.h:112
@ ASCII__RETURN
Definition: Types.h:117
@ ASCII__NEWLINE
Definition: Types.h:116
@ ASCII__SEMICOLON
Definition: Types.h:127
@ ASCII__TAB
Definition: Types.h:119
@ ASCII__COMMA
Definition: Types.h:123
@ ASCII__COLON
Definition: Types.h:122
@ ASCII__BELL
Definition: Types.h:113
@ ASCII__SPACE
Definition: Types.h:118
@ ASCII__POINT
Definition: Types.h:125
@ ASCII__QUESTION_MARK
Definition: Types.h:126
@ ASCII__CARRIAGE_RETURN
Definition: Types.h:114
@ ASCII__VERTICAL_TAB
Definition: Types.h:120
constexpr Int writtenDigits< long int >(const long int &)
We do not want to bother people who unintentionally provide a long int argument to this.
Definition: Types.h:214
constexpr Int writtenDigits< float >(const float &)
Number of digits commonly used for writing a float (a.k.a. precision).
Definition: Types.h:186
constexpr Int writtenDigits< long double >(const long double &)
Number of digits commonly used for writing a long double (a.k.a. precision). ...
Definition: Types.h:252
constexpr Int writtenDigits< unsigned long int >(const unsigned long int &)
We do not want to bother people who unintentionally provide an unsigned long int argument to this.
Definition: Types.h:221
constexpr Int writtenDigits< DataValue >(const DataValue &)
DataValue will be printed like double.
Definition: Types.h:229
constexpr Int writtenDigits< double >(const double &)
Number of digits commonly used for writing a double (a.k.a. precision).
Definition: Types.h:193
constexpr Int writtenDigits< unsigned int >(const unsigned int &)
We do not want to bother people who unintentionally provide an unsigned int argument to this.
Definition: Types.h:207
constexpr Int writtenDigits< int >(const int &)
We do not want to bother people who unintentionally provide an int argument to this.
Definition: Types.h:200
constexpr Int writtenDigits(const FloatingPointType &=FloatingPointType())
Number of digits commonly used for writing a floating point type (a.k.a. precision)....
Definition: Types.h:268