| 1.0.0 API documentation

io.hpp
Go to the documentation of this file.
1
20 #pragma once
21
22 // Dependency:
23 #include "../glm.hpp"
24 #include "../gtx/quaternion.hpp"
25
26 #ifndef GLM_ENABLE_EXPERIMENTAL
27 # error "GLM: GLM_GTX_io is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
28 #elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
29 # pragma message("GLM: GLM_GTX_io extension included")
30 #endif
31
32 #if GLM_COMPILER & GLM_COMPILER_CLANG
33 # pragma clang diagnostic push
34 # pragma clang diagnostic ignored "-Wpadded"
35 # pragma clang diagnostic ignored "-Wshorten-64-to-32"
36 # pragma clang diagnostic ignored "-Wglobal-constructors"
37 #endif
38
39 #include <iosfwd> // std::basic_ostream<> (fwd)
40 #include <locale> // std::locale, std::locale::facet, std::locale::id
41 #include <utility> // std::pair<>
42
43 namespace glm
44 {
47
48 namespace io
49 {
50 enum order_type { column_major, row_major};
51
52 template<typename CTy>
53 class format_punct : public std::locale::facet
54 {
55 typedef CTy char_type;
56
57 public:
58
59 static std::locale::id id;
60
61 bool formatted;
62 unsigned precision;
63 unsigned width;
64 char_type separator;
65 char_type delim_left;
66 char_type delim_right;
67 char_type space;
68 char_type newline;
69 order_type order;
70
71 GLM_FUNC_DECL explicit format_punct(size_t a = 0);
72 GLM_FUNC_DECL explicit format_punct(format_punct const&);
73 };
74
75 template<typename CTy, typename CTr = std::char_traits<CTy> >
76 class basic_state_saver {
77
78 public:
79
80 GLM_FUNC_DECL explicit basic_state_saver(std::basic_ios<CTy,CTr>&);
81 GLM_FUNC_DECL ~basic_state_saver();
82
83 private:
84
85 typedef ::std::basic_ios<CTy,CTr> state_type;
86 typedef typename state_type::char_type char_type;
87 typedef ::std::ios_base::fmtflags flags_type;
88 typedef ::std::streamsize streamsize_type;
89 typedef ::std::locale const locale_type;
90
91 state_type& state_;
92 flags_type flags_;
93 streamsize_type precision_;
94 streamsize_type width_;
95 char_type fill_;
96 locale_type locale_;
97
98 GLM_FUNC_DECL basic_state_saver& operator=(basic_state_saver const&);
99 };
100
101 typedef basic_state_saver<char> state_saver;
102 typedef basic_state_saver<wchar_t> wstate_saver;
103
104 template<typename CTy, typename CTr = std::char_traits<CTy> >
105 class basic_format_saver
106 {
107 public:
108
109 GLM_FUNC_DECL explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
110 GLM_FUNC_DECL ~basic_format_saver();
111
112 private:
113
114 basic_state_saver<CTy> const bss_;
115
116 GLM_FUNC_DECL basic_format_saver& operator=(basic_format_saver const&);
117 };
118
119 typedef basic_format_saver<char> format_saver;
120 typedef basic_format_saver<wchar_t> wformat_saver;
121
122 struct precision
123 {
124 unsigned value;
125
126 GLM_FUNC_DECL explicit precision(unsigned);
127 };
128
129 struct width
130 {
131 unsigned value;
132
133 GLM_FUNC_DECL explicit width(unsigned);
134 };
135
136 template<typename CTy>
137 struct delimeter
138 {
139 CTy value[3];
140
141 GLM_FUNC_DECL explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
142 };
143
144 struct order
145 {
146 order_type value;
147
148 GLM_FUNC_DECL explicit order(order_type);
149 };
150
151 // functions, inlined (inline)
152
153 template<typename FTy, typename CTy, typename CTr>
154 FTy const& get_facet(std::basic_ios<CTy,CTr>&);
155 template<typename FTy, typename CTy, typename CTr>
156 std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
157 template<typename FTy, typename CTy, typename CTr>
158 std::basic_ios<CTy,CTr>& unformatted(std::basic_ios<CTy,CTr>&);
159
160 template<typename CTy, typename CTr>
161 std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
162 template<typename CTy, typename CTr>
163 std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, width const&);
164 template<typename CTy, typename CTr>
165 std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
166 template<typename CTy, typename CTr>
167 std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
168 }//namespace io
169
170 template<typename CTy, typename CTr, typename T, qualifier Q>
171 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, qua<T, Q> const&);
172 template<typename CTy, typename CTr, typename T, qualifier Q>
173 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<1, T, Q> const&);
174 template<typename CTy, typename CTr, typename T, qualifier Q>
175 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<2, T, Q> const&);
176 template<typename CTy, typename CTr, typename T, qualifier Q>
177 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<3, T, Q> const&);
178 template<typename CTy, typename CTr, typename T, qualifier Q>
179 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<4, T, Q> const&);
180 template<typename CTy, typename CTr, typename T, qualifier Q>
181 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 2, T, Q> const&);
182 template<typename CTy, typename CTr, typename T, qualifier Q>
183 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 3, T, Q> const&);
184 template<typename CTy, typename CTr, typename T, qualifier Q>
185 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 4, T, Q> const&);
186 template<typename CTy, typename CTr, typename T, qualifier Q>
187 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 2, T, Q> const&);
188 template<typename CTy, typename CTr, typename T, qualifier Q>
189 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 3, T, Q> const&);
190 template<typename CTy, typename CTr, typename T, qualifier Q>
191 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 4, T, Q> const&);
192 template<typename CTy, typename CTr, typename T, qualifier Q>
193 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 2, T, Q> const&);
194 template<typename CTy, typename CTr, typename T, qualifier Q>
195 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 3, T, Q> const&);
196 template<typename CTy, typename CTr, typename T, qualifier Q>
197 GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 4, T, Q> const&);
198
199 template<typename CTy, typename CTr, typename T, qualifier Q>
200 GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr> &,
201 std::pair<mat<4, 4, T, Q> const, mat<4, 4, T, Q> const> const&);
202
204 }//namespace glm
205
206 #if GLM_COMPILER & GLM_COMPILER_CLANG
207 # pragma clang diagnostic pop
208 #endif
209
210 #include "io.inl"