blob: e97d27fb19739de54b33e8762025434bc486720f [file] [log] [blame]
Tony-LunarGb0b195d2015-05-13 15:01:06 -06001///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in
13/// all copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref gtx_io
24/// @file glm/gtx/io.hpp
25/// @date 2013-11-22
26/// @author Jan P Springer (regnirpsj@gmail.com)
27///
28/// @see core (dependence)
29/// @see gtx_quaternion (dependence)
30///
31/// @defgroup gtx_io GLM_GTX_io
32/// @ingroup gtx
33///
34/// @brief std::[w]ostream support for glm types
35///
36/// <glm/gtx/io.hpp> needs to be included to use these functionalities.
37///////////////////////////////////////////////////////////////////////////////////
38
39#ifndef GLM_GTX_io
40#define GLM_GTX_io
41
42// Dependency:
43#include "../detail/setup.hpp"
44#include "../gtc/quaternion.hpp"
45
46#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
47# pragma message("GLM: GLM_GTX_io extension included")
48#endif
49
50#include <iosfwd> // std::basic_ostream<> (fwd)
51#include <utility> // std::pair<>
52
53namespace glm
54{
55 /// @addtogroup gtx_io
56 /// @{
57
58 namespace io
59 {
60
61 class precision_guard {
62
63 public:
64
65 GLM_FUNC_DECL explicit precision_guard();
66 GLM_FUNC_DECL ~precision_guard();
67
68 private:
69
70 unsigned precision_;
71 unsigned value_width_;
72
73 };
74
75 class format_guard
76 {
77 public:
78 enum order_t { column_major, row_major, };
79
80 GLM_FUNC_DECL explicit format_guard();
81 GLM_FUNC_DECL ~format_guard();
82
83 private:
84
85 order_t order_;
86 char cr_;
87 };
88
89 // decimal places (dflt: 3)
90 GLM_FUNC_DECL unsigned& precision();
91
92 // sign + value + '.' + decimals (dflt: 1 + 4 + 1 + precision())
93 GLM_FUNC_DECL unsigned& value_width();
94
95 // matrix output order (dflt: row_major)
96 GLM_FUNC_DECL format_guard::order_t& order();
97
98 // carriage/return char (dflt: '\n')
99 GLM_FUNC_DECL char& cr();
100
101 // matrix output order -> column_major
102 GLM_FUNC_DECL std::ios_base& column_major(std::ios_base&);
103
104 // matrix output order -> row_major
105 GLM_FUNC_DECL std::ios_base& row_major (std::ios_base&);
106
107 // carriage/return char -> '\n'
108 GLM_FUNC_DECL std::ios_base& formatted (std::ios_base&);
109
110 // carriage/return char -> ' '
111 GLM_FUNC_DECL std::ios_base& unformatted (std::ios_base&);
112
113 }//namespace io
114
115 namespace detail
116 {
117 template <typename CTy, typename CTr, typename T, precision P>
118 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tquat<T,P> const&);
119 template <typename CTy, typename CTr, typename T, precision P>
120 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec2<T,P> const&);
121 template <typename CTy, typename CTr, typename T, precision P>
122 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec3<T,P> const&);
123 template <typename CTy, typename CTr, typename T, precision P>
124 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec4<T,P> const&);
125 template <typename CTy, typename CTr, typename T, precision P>
126 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x2<T,P> const&);
127 template <typename CTy, typename CTr, typename T, precision P>
128 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x3<T,P> const&);
129 template <typename CTy, typename CTr, typename T, precision P>
130 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x4<T,P> const&);
131 template <typename CTy, typename CTr, typename T, precision P>
132 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x2<T,P> const&);
133 template <typename CTy, typename CTr, typename T, precision P>
134 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x3<T,P> const&);
135 template <typename CTy, typename CTr, typename T, precision P>
136 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x4<T,P> const&);
137 template <typename CTy, typename CTr, typename T, precision P>
138 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x2<T,P> const&);
139 template <typename CTy, typename CTr, typename T, precision P>
140 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x3<T,P> const&);
141 template <typename CTy, typename CTr, typename T, precision P>
142 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x4<T,P> const&);
143
144 /// @}
145}//namespace detail
146}//namespace glm
147
148#include "io.inl"
149
150#endif//GLM_GTX_io