Athena IO Library
Global.hpp
1 // This file is part of libAthena.
2 //
3 // libAthena is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // libAthena is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with libAthena. If not, see <http://www.gnu.org/licenses/>
15 
16 #ifndef GLOBAL_HPP
17 #define GLOBAL_HPP
18 
19 #include "Athena/Types.hpp"
20 #include "Athena/Utility.hpp"
21 #include <iostream>
22 
23 #ifdef _MSC_VER
24 #pragma warning(disable : 4996)
25 #endif
26 
27 #ifndef AT_PRETTY_FUNCTION
28 # if defined(__PRETTY_FUNCTION__) || defined(__GNUC__)
29 # define AT_PRETTY_FUNCTION __PRETTY_FUNCTION__
30 # elif defined(__FUNCSIG__)
31 # define AT_PRETTY_FUNCTION __FUNCSIG__
32 # elif defined(__FUNCTION__)
33 # define AT_PRETTY_FUNCTION __FUNCTION__
34 # elif defined(__FUNC__)
35 # define AT_PRETTY_FUNCTION __FUNC__
36 # elif defined(__func__)
37 # define AT_PRETTY_FUNCTION __func__
38 # else
39 # define AT_PRETTY_FUNCTION "<unknown>"
40 # endif
41 #endif
42 
43 
44 #ifdef GEKKO
45 #include "gekko_support.h"
46 typedef struct stat stat64_t;
47 #define stat64 stat
48 #else
49 typedef struct stat64 stat64_t;
50 #endif
51 
52 #ifndef aDebug
53 #define aDebug() \
54  std::cout << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
55 #endif
56 #ifndef aError
57 #define aError() \
58  std::cerr << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
59 #endif
60 
61 #ifndef aPrint
62 #define aPrint() std::cout
63 #endif
64 
65 #define aEnd() '\n'
66 
67 #ifndef BLOCKSZ
68 #define BLOCKSZ 512
69 #endif
70 
71 #define ROUND_UP_32(val) (((val) + 31) & ~31)
72 #define ROUND_UP_16(val) (((val) + 15) & ~15)
73 
74 namespace Athena
75 {
76 enum class SeekOrigin
77 {
78  Begin,
79  Current,
80  End
81 };
82 
83 enum class Endian
84 {
85  LittleEndian,
86  BigEndian
87 };
88 
89 #ifndef ATHENA_NO_SAKURA
90 namespace Sakura
91 {
92 
93 template <typename T>
94 class Vector2D
95 {
96 public:
97  T x;
98  T y;
99 
100  Vector2D()
101  : x(0),
102  y(0)
103  {
104  }
105 
106  Vector2D(T x, T y)
107  : x(x),
108  y(y)
109  {
110  }
111 };
112 
113 typedef Vector2D<int> Vector2Di;
114 typedef Vector2D<float> Vector2Df;
115 } // Sakura
116 #endif // ATHENA_NO_SAKURA
117 } // Athena
118 
119 typedef void (*atEXCEPTION_HANDLER)(const std::string& file, const std::string& function, int line, const std::string&, ...);
120 
121 atEXCEPTION_HANDLER atGetExceptionHandler();
122 void atSetExceptionHandler(atEXCEPTION_HANDLER func);
123 
124 std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin);
125 std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian);
126 #endif // GLOBAL_HPP