| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | |
| 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 | #endif |
| 29 | |
| 30 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
| 31 | # pragma message("GLM: GLM_GTX_io extension included") |
| 32 | #endif |
| 33 | |
| 34 | #include <iosfwd> |
| 35 | #include <locale> |
| 36 | #include <utility> |
| 37 | |
| 38 | namespace glm |
| 39 | { |
| 40 | |
| 41 | |
| 42 | |
| 43 | namespace io |
| 44 | { |
| 45 | enum order_type { column_major, row_major}; |
| 46 | |
| 47 | template<typename CTy> |
| 48 | class format_punct : public std::locale::facet |
| 49 | { |
| 50 | typedef CTy char_type; |
| 51 | |
| 52 | public: |
| 53 | |
| 54 | static std::locale::id id; |
| 55 | |
| 56 | bool formatted; |
| 57 | unsigned precision; |
| 58 | unsigned width; |
| 59 | char_type separator; |
| 60 | char_type delim_left; |
| 61 | char_type delim_right; |
| 62 | char_type space; |
| 63 | char_type newline; |
| 64 | order_type order; |
| 65 | |
| 66 | GLM_FUNC_DECL explicit format_punct(size_t a = 0); |
| 67 | GLM_FUNC_DECL explicit format_punct(format_punct const&); |
| 68 | }; |
| 69 | |
| 70 | template<typename CTy, typename CTr = std::char_traits<CTy> > |
| 71 | class basic_state_saver { |
| 72 | |
| 73 | public: |
| 74 | |
| 75 | GLM_FUNC_DECL explicit basic_state_saver(std::basic_ios<CTy,CTr>&); |
| 76 | GLM_FUNC_DECL ~basic_state_saver(); |
| 77 | |
| 78 | private: |
| 79 | |
| 80 | typedef ::std::basic_ios<CTy,CTr> state_type; |
| 81 | typedef typename state_type::char_type char_type; |
| 82 | typedef ::std::ios_base::fmtflags flags_type; |
| 83 | typedef ::std::streamsize streamsize_type; |
| 84 | typedef ::std::locale const locale_type; |
| 85 | |
| 86 | state_type& state_; |
| 87 | flags_type flags_; |
| 88 | streamsize_type precision_; |
| 89 | streamsize_type width_; |
| 90 | char_type fill_; |
| 91 | locale_type locale_; |
| 92 | |
| 93 | GLM_FUNC_DECL basic_state_saver& operator=(basic_state_saver const&); |
| 94 | }; |
| 95 | |
| 96 | typedef basic_state_saver<char> state_saver; |
| 97 | typedef basic_state_saver<wchar_t> wstate_saver; |
| 98 | |
| 99 | template<typename CTy, typename CTr = std::char_traits<CTy> > |
| 100 | class basic_format_saver |
| 101 | { |
| 102 | public: |
| 103 | |
| 104 | GLM_FUNC_DECL explicit basic_format_saver(std::basic_ios<CTy,CTr>&); |
| 105 | GLM_FUNC_DECL ~basic_format_saver(); |
| 106 | |
| 107 | private: |
| 108 | |
| 109 | basic_state_saver<CTy> const bss_; |
| 110 | |
| 111 | GLM_FUNC_DECL basic_format_saver& operator=(basic_format_saver const&); |
| 112 | }; |
| 113 | |
| 114 | typedef basic_format_saver<char> format_saver; |
| 115 | typedef basic_format_saver<wchar_t> wformat_saver; |
| 116 | |
| 117 | struct precision |
| 118 | { |
| 119 | unsigned value; |
| 120 | |
| 121 | GLM_FUNC_DECL explicit precision(unsigned); |
| 122 | }; |
| 123 | |
| 124 | struct width |
| 125 | { |
| 126 | unsigned value; |
| 127 | |
| 128 | GLM_FUNC_DECL explicit width(unsigned); |
| 129 | }; |
| 130 | |
| 131 | template<typename CTy> |
| 132 | struct delimeter |
| 133 | { |
| 134 | CTy value[3]; |
| 135 | |
| 136 | GLM_FUNC_DECL explicit delimeter(CTy , CTy , CTy = ','); |
| 137 | }; |
| 138 | |
| 139 | struct order |
| 140 | { |
| 141 | order_type value; |
| 142 | |
| 143 | GLM_FUNC_DECL explicit order(order_type); |
| 144 | }; |
| 145 | |
| 146 | |
| 147 | |
| 148 | template<typename FTy, typename CTy, typename CTr> |
| 149 | FTy const& get_facet(std::basic_ios<CTy,CTr>&); |
| 150 | template<typename FTy, typename CTy, typename CTr> |
| 151 | std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&); |
| 152 | template<typename FTy, typename CTy, typename CTr> |
| 153 | std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&); |
| 154 | |
| 155 | template<typename CTy, typename CTr> |
| 156 | std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&); |
| 157 | template<typename CTy, typename CTr> |
| 158 | std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, width const&); |
| 159 | template<typename CTy, typename CTr> |
| 160 | std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&); |
| 161 | template<typename CTy, typename CTr> |
| 162 | std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&); |
| 163 | } |
| 164 | |
| 165 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 166 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, qua<T, Q> const&); |
| 167 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 168 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<1, T, Q> const&); |
| 169 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 170 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<2, T, Q> const&); |
| 171 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 172 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<3, T, Q> const&); |
| 173 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 174 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<4, T, Q> const&); |
| 175 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 176 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 2, T, Q> const&); |
| 177 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 178 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 3, T, Q> const&); |
| 179 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 180 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 4, T, Q> const&); |
| 181 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 182 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 2, T, Q> const&); |
| 183 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 184 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 3, T, Q> const&); |
| 185 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 186 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 4, T, Q> const&); |
| 187 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 188 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 2, T, Q> const&); |
| 189 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 190 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 3, T, Q> const&); |
| 191 | template<typename CTy, typename CTr, typename T, qualifier Q> |
| 192 | GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 4, T, Q> const&); |
| 193 | |
| 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> &, |
| 196 | std::pair<mat<4, 4, T, Q> const, mat<4, 4, T, Q> const> const&); |
| 197 | |
| 198 | |
| 199 | } |
| 200 | |
| 201 | #include "io.inl" |