TGUI  0.8-dev
Global.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef TGUI_GLOBAL_HPP
26 #define TGUI_GLOBAL_HPP
27 
29 
30 #include <TGUI/Config.hpp>
31 #include <TGUI/Exception.hpp>
32 #include <iostream>
33 #include <string>
34 #include <memory>
35 
37 
38 #ifdef TGUI_NO_CPP14
39  namespace tgui
40  {
41  template<typename T, typename... Args>
42  std::unique_ptr<T> make_unique(Args&&... args)
43  {
44  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
45  }
46  }
47 #else
48  using std::make_unique;
49 #endif
50 
52 
54 namespace tgui
55 {
60  TGUI_API void enableTabKeyUsage();
61 
62 
67  TGUI_API void disableTabKeyUsage();
68 
69 
78  TGUI_API void setResourcePath(const std::string& path);
79 
80 
89  TGUI_API const std::string& getResourcePath();
90 
91 
94  // Checks if two floats are equal, with regard to a small epsilon margin.
96  TGUI_API bool compareFloats(float x, float y);
97 
98 
101  // Checks if a character is a whitespace character.
103  TGUI_API bool isWhitespace(char character);
104 
105 
108  // Converts a string to an integer. Acts like std::stoi which isn't supported in MinGW TDM.
110  TGUI_API int stoi(const std::string& value);
111 
112 
115  // Converts a string to a float. Acts like std::stof which isn't supported in MinGW TDM.
117  TGUI_API float stof(const std::string& value);
118 
119 
122  // Extracts a bool from a string value.
124  TGUI_API bool extractBoolFromString(const std::string& property, const std::string& value);
125 
126 
129  // Moves the iterator forward until no more whitespace is found
131  TGUI_API bool removeWhitespace(const std::string& line, std::string::const_iterator& c);
132 
133 
136  // Converts a string to lowercase.
138  TGUI_API std::string toLower(std::string str);
139 
140 
143  // Trims the whitespace from a string.
145  TGUI_API std::string trim(std::string str);
146 
147 
149 }
150 
152 
153 #endif // TGUI_GLOBAL_HPP
154 
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
TGUI_API void enableTabKeyUsage()
While tab key usage is enabled (default), pressing tab will focus another widget. ...
TGUI_API void disableTabKeyUsage()
When disabling the tab key usage, pressing tab will no longer focus another widget.
TGUI_API const std::string & getResourcePath()
Returns the resource path.
TGUI_API void setResourcePath(const std::string &path)
Sets a new resource path.