Blame view

build3/ion/src/shared/software_version.cpp 1.07 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  #include <ion.h>
  #include <assert.h>
  
  #define STR_EXPAND(arg) #arg
  #define STR(arg) STR_EXPAND(arg)
  
  #ifndef PATCH_LEVEL
  #error This file expects PATCH_LEVEL to be defined
  #endif
  
  #ifndef EPSILON_VERSION
  #error This file expects EPSILON_VERSION to be defined
  #endif
  
  #ifndef HEADER_SECTION
  #define HEADER_SECTION
  #endif
  
  class VersionInfo {
  public:
    constexpr VersionInfo() :
      m_header(Magic),
      m_version{EPSILON_VERSION},
      m_patchLevel{PATCH_LEVEL},
      m_footer(Magic) { }
    const char * version() const {
      assert(m_header == Magic);
      assert(m_footer == Magic);
      return m_version;
    }
    const char * patchLevel() const {
      assert(m_header == Magic);
      assert(m_footer == Magic);
      return m_patchLevel;
    }
  private:
    constexpr static uint32_t Magic = 0xDEC00DF0;
    uint32_t m_header;
    const char m_version[8];
    const char m_patchLevel[8];
    uint32_t m_footer;
  };
  
  constexpr VersionInfo HEADER_SECTION version_infos;
  
  const char * Ion::softwareVersion() {
    return version_infos.version();
  }
  
  const char * Ion::patchLevel() {
    return version_infos.patchLevel();
  }