OpenMS
Types.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2023.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Oliver Kohlbacher $
32 // $Authors: Marc Sturm, Clemens Groepl $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/config.h>
38 
39 #include <ctime>
40 #include <cstddef> // for size_t & ptrdiff_t
41 #include <limits>
42 
43 // If possible use the ISO C99-compliant header stdint.h
44 // to define the portable integer types.
45 #ifdef OPENMS_HAS_STDINT_H
46 #include <cstdint>
47 #endif
48 
49 namespace OpenMS
50 {
56  typedef OPENMS_INT32_TYPE Int32;
57 
63  typedef OPENMS_UINT32_TYPE UInt32;
64 
70  typedef OPENMS_INT64_TYPE Int64;
71 
77  typedef OPENMS_UINT64_TYPE UInt64;
78 
86  typedef time_t Time;
87 
93  //typedef size_t UInt;
94  typedef unsigned int UInt;
95 
101  //typedef OPENMS_SIZE_T_SIGNED Int;
102  typedef int Int;
103 
111  typedef OPENMS_BYTE_TYPE Byte;
112 
120  typedef OPENMS_UINT64_TYPE UID;
121 
127  typedef size_t Size;
128 
134  typedef ptrdiff_t SignedSize;
135 
136  enum ASCII
137  {
139  ASCII__BELL = '\a',
147 
153  ASCII__SEMICOLON = ';'
154  };
155 
157 
200 
201 
207  template <typename FloatingPointType>
208  inline constexpr Int writtenDigits(const FloatingPointType& /* unused */ = FloatingPointType());
209 
211  template <>
212  inline constexpr Int writtenDigits<float>(const float&)
213  {
214  return std::numeric_limits<float>::digits10;
215  }
216 
218  template <>
219  inline constexpr Int writtenDigits<double>(const double&)
220  {
221  return std::numeric_limits<double>::digits10;
222  }
223 
225  template <>
226  inline constexpr Int writtenDigits<int>(const int&)
227  {
228  return std::numeric_limits<int>::digits10;
229  }
230 
232  template <>
233  inline constexpr Int writtenDigits<unsigned int>(const unsigned int&)
234  {
235  return std::numeric_limits<unsigned int>::digits10;
236  }
237 
239  template <>
240  inline constexpr Int writtenDigits<long int>(const long int&)
241  {
242  return std::numeric_limits<int>::digits10;
243  }
244 
246  template <>
247  inline constexpr Int writtenDigits<unsigned long int>(const unsigned long int&)
248  {
249  return std::numeric_limits<unsigned int>::digits10;
250  }
251 
252  class DataValue;
254  template <>
255  inline constexpr Int writtenDigits<DataValue>(const DataValue&)
256  {
257  return std::numeric_limits<double>::digits10;
258  }
259 
260  /*
261  META-COMMENT: DO NOT INTRODUCE ANY LINEBREAKS BELOW IN
262  "<code>std::numeric_limits<long double>::digits10 == 18</code>".
263  The doxygen parser (version 1.5.5) will get confused! (Clemens)
264  */
265 
277  template <>
278  inline constexpr Int writtenDigits<long double>(const long double&)
279  {
280 #ifndef OPENMS_WINDOWSPLATFORM
281  return std::numeric_limits<long double>::digits10;
282 
283 #else
284  return std::numeric_limits<double>::digits10;
285 
286 #endif
287  }
288 
293  template <typename FloatingPointType>
294  inline constexpr Int writtenDigits(const FloatingPointType& /* unused */)
295  {
296  return 6;
297  }
298 
299  namespace Internal
300  {
307  extern OPENMS_DLLAPI const char* OpenMS_locale;
308  }
309 
310 } // namespace OpenMS
311 
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:59
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:111
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:63
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
int Int
Signed integer type.
Definition: Types.h:102
OPENMS_INT32_TYPE Int32
Signed integer type (32bit)
Definition: Types.h:56
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:70
OPENMS_UINT64_TYPE UID
A unique object ID (as unsigned 64bit type).
Definition: Types.h:120
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
time_t Time
Time type.
Definition: Types.h:86
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const char * OpenMS_locale
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
ASCII
Definition: Types.h:137
@ ASCII__EXCLAMATION_MARK
Definition: Types.h:150
@ ASCII__HORIZONTAL_TAB
Definition: Types.h:141
@ ASCII__BACKSPACE
Definition: Types.h:138
@ ASCII__RETURN
Definition: Types.h:143
@ ASCII__NEWLINE
Definition: Types.h:142
@ ASCII__SEMICOLON
Definition: Types.h:153
@ ASCII__TAB
Definition: Types.h:145
@ ASCII__COMMA
Definition: Types.h:149
@ ASCII__COLON
Definition: Types.h:148
@ ASCII__BELL
Definition: Types.h:139
@ ASCII__SPACE
Definition: Types.h:144
@ ASCII__POINT
Definition: Types.h:151
@ ASCII__QUESTION_MARK
Definition: Types.h:152
@ ASCII__CARRIAGE_RETURN
Definition: Types.h:140
@ ASCII__VERTICAL_TAB
Definition: Types.h:146
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:240
constexpr Int writtenDigits< float >(const float &)
Number of digits commonly used for writing a float (a.k.a. precision).
Definition: Types.h:212
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:278
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:247
constexpr Int writtenDigits< DataValue >(const DataValue &)
DataValue will be printed like double.
Definition: Types.h:255
constexpr Int writtenDigits< double >(const double &)
Number of digits commonly used for writing a double (a.k.a. precision).
Definition: Types.h:219
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:233
constexpr Int writtenDigits< int >(const int &)
We do not want to bother people who unintentionally provide an int argument to this.
Definition: Types.h:226
constexpr Int writtenDigits(const FloatingPointType &=FloatingPointType())
Number of digits commonly used for writing a floating point type (a.k.a. precision)....
Definition: Types.h:294