ToString.hpp
Go to the documentation of this file.
1 //
3 // Thor C++ Library
4 // Copyright (c) 2011-2016 Jan Haller
5 //
6 // This software is provided 'as-is', without any express or implied
7 // warranty. In no event will the authors be held liable for any damages
8 // arising from the use of this software.
9 //
10 // Permission is granted to anyone to use this software for any purpose,
11 // including commercial applications, and to alter it and redistribute it
12 // freely, subject to the following restrictions:
13 //
14 // 1. The origin of this software must not be misrepresented; you must not
15 // claim that you wrote the original software. If you use this software
16 // in a product, an acknowledgment in the product documentation would be
17 // appreciated but is not required.
18 //
19 // 2. Altered source versions must be plainly marked as such, and must not be
20 // misrepresented as being the original software.
21 //
22 // 3. This notice may not be removed or altered from any source distribution.
23 //
25 
28 
29 #ifndef THOR_TOSTRING_HPP
30 #define THOR_TOSTRING_HPP
31 
32 // Note: Don't include specific headers to avoid unneeded dependencies. If one wants to
33 // output a certain object, he/she has already included the corresponding header anyway.
34 
35 #include <Thor/Config.hpp>
36 
37 #include <Aurora/Tools/Exceptions.hpp>
38 
39 #include <sstream>
40 
41 
42 namespace sf
43 {
44 
45  class Color;
46 
47  template <typename T>
48  class Vector2;
49 
50  template <typename T>
51  class Vector3;
52 
53  template <typename T>
54  class Rect;
55 
56 } // namespace sf
57 
58 
59 namespace thor
60 {
61 
62 template <typename T>
63 struct PolarVector2;
64 
67 
70 std::string THOR_API toString(const sf::Color& color);
71 
74 template <typename T>
75 std::string toString(const sf::Vector2<T>& vector);
76 
79 template <typename T>
80 std::string toString(const sf::Vector3<T>& vector);
81 
84 template <typename T>
85 std::string toString(const sf::Rect<T>& rect);
86 
89 template <typename T>
90 std::string toString(const PolarVector2<T>& vector);
91 
92 
95 class StringConversionException : public aurora::Exception
96 {
97  // ---------------------------------------------------------------------------------------------------------------------------
98  // Public member functions
99  public:
102  explicit StringConversionException(const std::string& message)
103  : aurora::Exception(message)
104  {
105  }
106 };
107 
109 
110 } // namespace thor
111 
112 #include <Thor/Graphics/Detail/ToString.inl>
113 #endif // THOR_TOSTRING_HPP
Distribution< sf::Vector2f > rect(sf::Vector2f center, sf::Vector2f halfSize)
Uniform random distribution in a rectangle
StringConversionException(const std::string &message)
Constructor.
Definition: ToString.hpp:102
Definition: AnimationMap.hpp:42
Configuration header of the library.
Definition: BigSprite.hpp:41
Exception class for failed string conversions.
Definition: ToString.hpp:95
Vector in polar coordinate system.
Definition: ToString.hpp:63
std::string toString(const PolarVector2< T > &vector)
Returns the string representation of thor::PolarVector.