15#include <vsg/core/Exception.h>
16#include <vsg/core/ref_ptr.h>
17#include <vsg/core/type_name.h>
18#include <vsg/io/Path.h>
19#include <vsg/maths/box.h>
20#include <vsg/maths/mat3.h>
21#include <vsg/maths/mat4.h>
22#include <vsg/maths/plane.h>
23#include <vsg/maths/quat.h>
24#include <vsg/maths/sphere.h>
25#include <vsg/maths/vec2.h>
26#include <vsg/maths/vec3.h>
27#include <vsg/maths/vec4.h>
28#include <vsg/utils/CoordinateSpace.h>
57 inline std::ostream& operator<<(std::ostream& output,
const indentation& in)
59 for (
int i = 0; i < in.indent; ++i) output.put(
' ');
64 template<
typename... Args>
65 std::string make_string(
const Args&... args)
67 std::ostringstream stream;
68 (stream << ... << args);
74 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec2<T>& vec)
76 output << vec.x <<
" " << vec.y;
82 std::istream& operator>>(std::istream& input, vsg::t_vec2<T>& vec)
84 input >> vec.x >> vec.y;
90 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec3<T>& vec)
92 output << vec.x <<
" " << vec.y <<
" " << vec.z;
98 std::istream& operator>>(std::istream& input, vsg::t_vec3<T>& vec)
100 input >> vec.x >> vec.y >> vec.z;
106 std::ostream& operator<<(std::ostream& output,
const vsg::t_vec4<T>& vec)
108 output << vec.x <<
" " << vec.y <<
" " << vec.z <<
" " << vec.w;
114 std::istream& operator>>(std::istream& input, vsg::t_vec4<T>& vec)
116 input >> vec.x >> vec.y >> vec.z >> vec.w;
122 std::ostream& operator<<(std::ostream& output,
const vsg::t_quat<T>& q)
124 output << q.x <<
" " << q.y <<
" " << q.z <<
" " << q.w;
130 std::istream& operator>>(std::istream& input, vsg::t_quat<T>& q)
132 input >> q.x >> q.y >> q.z >> q.w;
138 std::ostream& operator<<(std::ostream& output,
const vsg::t_plane<T>& vec)
140 output << vec.value[0] <<
" " << vec.value[1] <<
" " << vec.value[2] <<
" " << vec.value[3];
146 std::istream& operator>>(std::istream& input, vsg::t_plane<T>& vec)
148 input >> vec.value[0] >> vec.value[1] >> vec.value[2] >> vec.value[3];
154 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat3<T>& mat)
157 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) << std::endl;
158 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) << std::endl;
159 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) << std::endl;
165 std::istream& operator>>(std::istream& input, vsg::t_mat3<T>& mat)
167 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0);
168 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1);
169 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2);
175 std::ostream& operator<<(std::ostream& output,
const vsg::t_mat4<T>& mat)
178 output <<
" " << mat(0, 0) <<
" " << mat(1, 0) <<
" " << mat(2, 0) <<
" " << mat(3, 0) << std::endl;
179 output <<
" " << mat(0, 1) <<
" " << mat(1, 1) <<
" " << mat(2, 1) <<
" " << mat(3, 1) << std::endl;
180 output <<
" " << mat(0, 2) <<
" " << mat(1, 2) <<
" " << mat(2, 2) <<
" " << mat(3, 2) << std::endl;
181 output <<
" " << mat(0, 3) <<
" " << mat(1, 3) <<
" " << mat(2, 3) <<
" " << mat(3, 3) << std::endl;
187 std::istream& operator>>(std::istream& input, vsg::t_mat4<T>& mat)
189 input >> mat(0, 0) >> mat(1, 0) >> mat(2, 0) >> mat(3, 0);
190 input >> mat(0, 1) >> mat(1, 1) >> mat(2, 1) >> mat(3, 1);
191 input >> mat(0, 2) >> mat(1, 2) >> mat(2, 2) >> mat(3, 2);
192 input >> mat(0, 3) >> mat(1, 3) >> mat(2, 3) >> mat(3, 3);
198 std::ostream& operator<<(std::ostream& output,
const vsg::t_sphere<T>& sp)
206 std::istream& operator>>(std::istream& input, vsg::t_sphere<T>& sp)
214 std::ostream& operator<<(std::ostream& output,
const vsg::t_box<T>& bx)
217 output <<
" " << bx.min << std::endl;
218 output <<
" " << bx.max << std::endl;
224 std::istream& operator>>(std::istream& input, vsg::t_box<T>& bx)
233 std::ostream& operator<<(std::ostream& output,
const vsg::ref_ptr<T>& ptr)
236 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(" << ptr->className() <<
" " << ptr.get() <<
")";
238 output <<
"ref_ptr<" << vsg::type_name<T>() <<
">(nullptr)";
243 template<
typename T,
typename R>
244 std::ostream& operator<<(std::ostream& output,
const std::pair<T, R>& wd)
246 output << wd.first <<
" " << wd.second;
251 template<
typename T,
typename R>
252 std::istream& operator>>(std::istream& input, std::pair<T, R>& wd)
254 input >> wd.first >> wd.second;
260 std::ostream& operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
262 return stream << static_cast<typename std::underlying_type<T>::type>(e);
266 inline std::ostream& operator<<(std::ostream& output,
const vsg::Path& path)
268 output << path.string();
273 inline std::istream& operator>>(std::istream& input, vsg::Path& path)
282 inline std::ostream& operator<<(std::ostream& output,
const vsg::Exception& e)
284 output <<
"Error code: " << e.result <<
" | " << e.message;
288 inline std::istream& operator>>(std::istream& input, CoordinateSpace& coordinateSpace)
293 if (value ==
"LINEAR")
294 coordinateSpace = CoordinateSpace::LINEAR;
295 else if (value ==
"sRGB")
296 coordinateSpace = CoordinateSpace::sRGB;
298 coordinateSpace = CoordinateSpace::NO_PREFERENCE;
303 inline std::ostream& operator<<(std::ostream& output,
const CoordinateSpace& coordinateSpace)
305 if (coordinateSpace == CoordinateSpace::LINEAR)
307 else if (coordinateSpace == CoordinateSpace::sRGB)
310 output <<
"NO_PREFERENCE";
helper class for inserting indentation into streams useful for formatting output.
Definition stream.h:39