OpenMS  2.4.0
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-2018.
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 
154  };
155 
157 
200 
201 
207  template <typename FloatingPointType>
208  inline Int writtenDigits(const FloatingPointType& /* unused */ = FloatingPointType());
209 
211  template <>
212  inline Int writtenDigits<float>(const float&)
213  {
214  return std::numeric_limits<float>::digits10;
215  }
216 
218  template <>
219  inline Int writtenDigits<double>(const double&)
220  {
221  return std::numeric_limits<double>::digits10;
222  }
223 
225  template <>
226  inline Int writtenDigits<int>(const int&)
227  {
228  return std::numeric_limits<int>::digits10;
229  }
230 
232  template <>
233  inline Int writtenDigits<unsigned int>(const unsigned int&)
234  {
235  return std::numeric_limits<unsigned int>::digits10;
236  }
237 
239  template <>
240  inline Int writtenDigits<long int>(const long int&)
241  {
242  return std::numeric_limits<int>::digits10;
243  }
244 
246  template <>
247  inline 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 <>
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 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 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 
Definition: Types.h:138
Int writtenDigits< DataValue >(const DataValue &)
DataValue will be printed like double.
Definition: Types.h:255
Definition: Types.h:151
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Definition: Types.h:150
Definition: Types.h:144
Int writtenDigits(const FloatingPointType &=FloatingPointType())
Number of digits commonly used for writing a floating point type (a.k.a. precision). Specializations are defined for float, double, long double.
Definition: Types.h:294
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
const char * OpenMS_locale
Definition: Types.h:153
Definition: Types.h:142
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
Definition: Types.h:139
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
Int writtenDigits< float >(const float &)
Number of digits commonly used for writing a float (a.k.a. precision).
Definition: Types.h:212
Definition: Types.h:140
Definition: Types.h:146
Int writtenDigits< int >(const int &)
We do not want to bother people who unintentionally provide an int argument to this.
Definition: Types.h:226
Definition: Types.h:141
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
OPENMS_INT32_TYPE Int32
Signed integer type (32bit)
Definition: Types.h:56
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:63
ASCII
Definition: Types.h:136
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Definition: Types.h:148
Definition: Types.h:149
Definition: Types.h:143
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
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
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
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:70
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:111
Definition: Types.h:152
Int writtenDigits< double >(const double &)
Number of digits commonly used for writing a double (a.k.a. precision).
Definition: Types.h:219
int Int
Signed integer type.
Definition: Types.h:102
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
time_t Time
Time type.
Definition: Types.h:86
OPENMS_UINT64_TYPE UID
A unique object ID (as unsigned 64bit type).
Definition: Types.h:120
Definition: Types.h:145