The Battle for Wesnoth  1.15.1+dev
apple_version.mm
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 by Martin HrubĂ˝ <hrubymar10@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  */
14 
15 #ifdef __APPLE__
16 
17 #include "apple_version.hpp"
18 
19 #import "game_version.hpp"
20 
21 #if defined(__APPLE__) && defined(__MACH__) && defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
22 #define __IPHONEOS__ (__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__*1000)
23 #endif
24 
25 #import <Foundation/Foundation.h>
26 
27 #if defined(__IPHONEOS__)
28 #import <UIKit/UIKit.h>
29 #endif
30 
31 namespace desktop {
32 namespace apple {
33  std::string os_version() {
34 
35  //
36  // Standard Apple version
37  //
38 
39  std::string version_string = "";
40 
41  NSArray *version_array = [[[NSProcessInfo processInfo] operatingSystemVersionString] componentsSeparatedByString:@" "];
42 
43 #if defined(__IPHONEOS__)
44  std::string version_string = "iOS ";
45 #else
46  const version_info version_info([[version_array objectAtIndex:1] UTF8String]);
47 
48  if (version_info.major_version() == 10 && version_info.minor_version() < 12) {
49  version_string = "Apple OS X ";
50  } else {
51  version_string = "Apple macOS ";
52  }
53 #endif
54 
55  version_string += [[version_array objectAtIndex:1] UTF8String];
56  version_string += " (";
57  version_string += [[version_array objectAtIndex:3] UTF8String];
58 
59  return version_string;
60  }
61 
62 } // end namespace apple
63 } // end namespace desktop
64 
65 #endif //end __APPLE__
Interfaces for manipulating version numbers of engine, add-ons, etc.
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
std::string os_version()
Returns a string with the running OS name and version information.
Definition: version.cpp:121
Represents version numbers.