Thrill  0.1
version.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/version.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2007, 2011 Andreas Beckmann <[email protected]>
7  * Copyright (C) 2013 Timo Bingmann <[email protected]>
8  *
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  **************************************************************************/
13 
14 #ifndef FOXXLL_VERSION_HEADER
15 #define FOXXLL_VERSION_HEADER
16 
17 #include <string>
18 
19 #include <tlx/die/core.hpp>
20 
21 #include <foxxll/config.hpp>
22 
23 namespace foxxll {
24 
25 // FOXXLL_VERSION_{MAJOR,MINOR,PATCH} are defined in cmake generated config.h
26 
27 // construct an integer version number, like "10400" for "1.4.0".
28 #define FOXXLL_VERSION_INTEGER (FOXXLL_VERSION_MAJOR * 10000 + FOXXLL_VERSION_MINOR * 100 + FOXXLL_VERSION_PATCH)
29 
30 #define stringify_(x) #x
31 #define stringify(x) stringify_(x)
32 
33 //! Return "X.Y.Z" version string (of headers)
35 {
36  return FOXXLL_VERSION_STRING;
37 }
38 
39 //! Return longer "X.Y.Z (feature) (version)" version string (of headers)
41 {
42  return "FOXXLL"
43  " v" FOXXLL_VERSION_STRING
44 #ifdef FOXXLL_VERSION_PHASE
45  " (" FOXXLL_VERSION_PHASE ")"
46 #endif
47 #ifdef FOXXLL_VERSION_GIT_SHA1
48  " (git " FOXXLL_VERSION_GIT_SHA1 ")"
49 #endif // FOXXLL_VERSION_GIT_SHA1
50  ; // NOLINT
51 }
52 
53 #undef stringify
54 #undef stringify_
55 
56 //! return X if the FOXXLL library version is X.Y.Z
57 int version_major();
58 //! return Y if the FOXXLL library version is X.Y.Z
59 int version_minor();
60 //! return Z if the FOXXLL library version is X.Y.Z
61 int version_patch();
62 //! return integer version number of the FOXXLL library
63 int version_integer();
64 
65 //! returns "X.Y.Z" version string of library
67 
68 //! returns longer "X.Y.Z (feature) (version)" string of library
70 
71 //! Check for a mismatch between library and headers
73 {
74  if (version_major() != FOXXLL_VERSION_MAJOR)
75  return 1;
76  if (version_minor() != FOXXLL_VERSION_MINOR)
77  return 2;
78  if (version_patch() != FOXXLL_VERSION_PATCH)
79  return 3;
80  return 0;
81 }
82 
83 //! Check and print mismatch between header and library versions
85 {
87  {
88  tlx_die(
89  "version mismatch between headers"
90  " (" << FOXXLL_VERSION_STRING ") and library"
91  " (" << get_library_version_string() << ")"
92  );
93  }
94 }
95 
96 } // namespace foxxll
97 
98 #endif // !FOXXLL_VERSION_HEADER
99 
100 /**************************************************************************/
int version_minor()
return Y if the FOXXLL library version is X.Y.Z
Definition: version.cpp:25
int check_library_version()
Check for a mismatch between library and headers.
Definition: version.hpp:72
int version_patch()
return Z if the FOXXLL library version is X.Y.Z
Definition: version.cpp:30
std::string get_version_string()
Return "X.Y.Z" version string (of headers)
Definition: version.hpp:34
FOXXLL library namespace
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220
int version_integer()
return integer version number of the FOXXLL library
Definition: version.cpp:35
#define tlx_die(msg)
Instead of std::terminate(), throw the output the message via an exception.
Definition: core.hpp:44
void print_library_version_mismatch()
Check and print mismatch between header and library versions.
Definition: version.hpp:84
std::string get_library_version_string()
returns "X.Y.Z" version string of library
Definition: version.cpp:40
std::string get_library_version_string_long()
returns longer "X.Y.Z (feature) (version)" string of library
Definition: version.cpp:45
int version_major()
return X if the FOXXLL library version is X.Y.Z
Definition: version.cpp:20
std::string get_version_string_long()
Return longer "X.Y.Z (feature) (version)" version string (of headers)
Definition: version.hpp:40