Skyscraper 2.0
globals.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Global Functions
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_GLOBALS_H
25#define _SBS_GLOBALS_H
26
27#include <string>
28#include <vector>
29//#include <OgreVector2.h>
30//#include <OgreVector3.h>
31#include <Ogre.h>
32
33//DLL Exporting
34#ifdef _WIN32
35 #if defined(_MSC_VER)
36 #define __VISUALC__ _MSC_VER
37 #endif
38 #if defined(__VISUALC__) || defined(__GNUC__)
39 #if defined(SBS_DLL) || (SBS_EXPORTS)
40 #define SBSIMPEXP __declspec(dllexport)
41 #define SBSIMPEXP_DATA(type) __declspec(dllexport) type
42 #else
43 #define SBSIMPEXP __declspec(dllimport)
44 #define SBSIMPEXP_DATA(type) __declspec(dllimport) type
45 #endif
46 #else
47 #define SBSIMPEXP
48 #define SBSIMPEXP_DATA(type) type
49 #endif
50#endif
51
52#ifndef SBSIMPEXP
53 #define SBSIMPEXP
54 #define SBSIMPEXP_DATA(type)
55#endif
56
57typedef Ogre::Real Real;
58typedef Ogre::Vector3 Vector3;
59typedef Ogre::Vector2 Vector2;
60typedef Ogre::Quaternion Quaternion;
61typedef Ogre::Degree Degree;
62typedef Ogre::Radian Radian;
63typedef Ogre::Ray Ray;
64typedef Ogre::Matrix3 Matrix3;
65typedef Ogre::Plane Plane;
66
67typedef unsigned int uint;
68
69namespace SBS {
70
71const Real pi = 3.14159265;
72
73SBSIMPEXP bool IsEven(int Number);
74SBSIMPEXP bool IsNumeric(char character);
75SBSIMPEXP bool IsNumeric(const std::string &string);
76SBSIMPEXP bool IsNumeric(const std::string &string, int &number);
77SBSIMPEXP bool IsNumeric(const std::string &string, float &number);
78SBSIMPEXP bool IsNumeric(const std::string &string, double &number);
79SBSIMPEXP std::string BoolToString(bool item);
84SBSIMPEXP Real Min(Real a, Real b, Real c, Real d);
85SBSIMPEXP Real Max(Real a, Real b, Real c, Real d);
86SBSIMPEXP std::string SetCaseCopy(std::string string, bool uppercase);
87SBSIMPEXP void SetCase(std::string &string, bool uppercase);
88SBSIMPEXP int FindWithCase(const std::string &string, bool uppercase, const std::string &key, int offset);
89SBSIMPEXP void TrimString(std::string &string);
90SBSIMPEXP std::string TrimStringCopy(std::string string);
91SBSIMPEXP void ReplaceAll(std::string &string, const std::string &original, const std::string &replacement);
92SBSIMPEXP bool StartsWith(const std::string &string, const std::string &check_string, bool ignore_case = false);
93SBSIMPEXP bool StartsWithNoCase(const std::string &string, const std::string &check_string);
94SBSIMPEXP void SplitString(std::vector<std::string> &dest_array, const std::string &original_string, char separator);
95SBSIMPEXP std::string ToString(int number);
96SBSIMPEXP std::string ToString(float number);
97SBSIMPEXP std::string ToString(double number);
98#if defined(__VISUALC__)
99SBSIMPEXP std::string ToString(size_t number);
100#endif
101SBSIMPEXP std::string ToString(unsigned long number);
102SBSIMPEXP float Log2(float number);
103SBSIMPEXP double Log2(double number);
104SBSIMPEXP float Round(float number, int decimal_places = 0);
105SBSIMPEXP double Round(double number, int decimal_places = 0);
106SBSIMPEXP Vector3 Round(const Vector3 &value, int decimal_places = 0);
107SBSIMPEXP Vector2 Round(const Vector2 &value, int decimal_places = 0);
108SBSIMPEXP bool IsBoolean(std::string string);
109SBSIMPEXP Real ToFloat(const std::string &string);
110SBSIMPEXP int ToInt(const std::string &string);
111SBSIMPEXP bool ToBool(std::string string);
112SBSIMPEXP std::string TruncateNumber(float value, int decimals);
113SBSIMPEXP std::string TruncateNumber(double value, int decimals);
114SBSIMPEXP std::string TruncateNumber(const std::string &number, int decimals);
115
116}
117
118#endif
Ogre::Matrix3 Matrix3
Definition globals.h:64
Ogre::Ray Ray
Definition globals.h:63
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
Ogre::Plane Plane
Definition globals.h:65
Ogre::Vector2 Vector2
Definition globals.h:59
unsigned int uint
Definition globals.h:67
Ogre::Radian Radian
Definition globals.h:62
#define SBSIMPEXP
Definition globals.h:53
Ogre::Quaternion Quaternion
Definition globals.h:60
Ogre::Degree Degree
Definition globals.h:61
bool IsBoolean(std::string string)
Definition globals.cpp:391
Real DegreesToRadians(Real degrees)
Definition globals.cpp:115
const Real pi
Definition globals.h:71
bool StartsWithNoCase(const std::string &string, const std::string &check_string)
Definition globals.cpp:237
std::string TruncateNumber(float value, int decimals)
Definition globals.cpp:416
int FindWithCase(const std::string &string, bool uppercase, const std::string &key, int offset)
Definition globals.cpp:181
void SplitString(std::vector< std::string > &dest_array, const std::string &original_string, char separator)
Definition globals.cpp:242
Real Min(Real a, Real b, Real c)
Definition globals.cpp:121
void ReplaceAll(std::string &string, const std::string &original, const std::string &replacement)
Definition globals.cpp:201
int ToInt(const std::string &string)
Definition globals.cpp:402
Real Max(Real a, Real b, Real c)
Definition globals.cpp:131
void SetCase(std::string &string, bool uppercase)
Definition globals.cpp:172
std::string ToString(int number)
Definition globals.cpp:279
float Round(float number, int decimal_places)
Definition globals.cpp:346
std::string SetCaseCopy(std::string string, bool uppercase)
Definition globals.cpp:165
Real ToFloat(const std::string &string)
Definition globals.cpp:397
bool IsNumeric(char character)
Definition globals.cpp:48
bool StartsWith(const std::string &string, const std::string &check_string, bool ignore_case)
Definition globals.cpp:216
std::string BoolToString(bool item)
Definition globals.cpp:101
void TrimString(std::string &string)
Definition globals.cpp:188
std::string TrimStringCopy(std::string string)
Definition globals.cpp:194
bool ToBool(std::string string)
Definition globals.cpp:407
bool IsEven(int Number)
Definition globals.cpp:37
Real RadiansToDegrees(Real radians)
Definition globals.cpp:109
float Log2(float number)
Definition globals.cpp:336