diff --git a/glm/gtx/io.hpp b/glm/gtx/io.hpp index 25e9d74b..7dd22182 100644 --- a/glm/gtx/io.hpp +++ b/glm/gtx/io.hpp @@ -57,178 +57,168 @@ namespace glm { - /// @addtogroup gtx_io - /// @{ - - namespace io - { - - enum order_type { column_major, row_major, }; - - template - class format_punct : public std::locale::facet { + /// @addtogroup gtx_io + /// @{ - typedef CTy char_type; - - public: + namespace io + { + enum order_type { column_major, row_major}; - static std::locale::id id; + template + class format_punct : public std::locale::facet + { + typedef CTy char_type; - bool formatted; - unsigned precision; - unsigned width; - char_type separator; - char_type delim_left; - char_type delim_right; - char_type space; - char_type newline; - order_type order; - - explicit format_punct(size_t a = 0); - explicit format_punct(format_punct const&); - - }; + public: - template > - class basic_state_saver { + static std::locale::id id; - public: + bool formatted; + unsigned precision; + unsigned width; + char_type separator; + char_type delim_left; + char_type delim_right; + char_type space; + char_type newline; + order_type order; - explicit basic_state_saver(std::basic_ios&); - ~basic_state_saver(); + explicit format_punct(size_t a = 0); + explicit format_punct(format_punct const&); + }; - private: + template > + class basic_state_saver { - typedef ::std::basic_ios state_type; - typedef typename state_type::char_type char_type; - typedef ::std::ios_base::fmtflags flags_type; - typedef ::std::streamsize streamsize_type; - typedef ::std::locale const locale_type; - - state_type& state_; - flags_type flags_; - streamsize_type precision_; - streamsize_type width_; - char_type fill_; - locale_type locale_; - - basic_state_saver& operator=(basic_state_saver const&); - - }; + public: - typedef basic_state_saver state_saver; - typedef basic_state_saver wstate_saver; - - template > - class basic_format_saver { + explicit basic_state_saver(std::basic_ios&); + ~basic_state_saver(); - public: + private: - explicit basic_format_saver(std::basic_ios&); - ~basic_format_saver(); + typedef ::std::basic_ios state_type; + typedef typename state_type::char_type char_type; + typedef ::std::ios_base::fmtflags flags_type; + typedef ::std::streamsize streamsize_type; + typedef ::std::locale const locale_type; - private: + state_type& state_; + flags_type flags_; + streamsize_type precision_; + streamsize_type width_; + char_type fill_; + locale_type locale_; - basic_state_saver const bss_; + basic_state_saver& operator=(basic_state_saver const&); + }; - basic_format_saver& operator=(basic_format_saver const&); - - }; + typedef basic_state_saver state_saver; + typedef basic_state_saver wstate_saver; - typedef basic_format_saver format_saver; - typedef basic_format_saver wformat_saver; - - struct precision { + template > + class basic_format_saver + { + public: - unsigned value; - - explicit precision(unsigned); - - }; + explicit basic_format_saver(std::basic_ios&); + ~basic_format_saver(); - struct width { + private: - unsigned value; - - explicit width(unsigned); - - }; + basic_state_saver const bss_; - template - struct delimeter { + basic_format_saver& operator=(basic_format_saver const&); + }; - CTy value[3]; - - explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ','); - - }; + typedef basic_format_saver format_saver; + typedef basic_format_saver wformat_saver; - struct order { + struct precision + { + unsigned value; - order_type value; - - explicit order(order_type); - - }; - - // functions, inlined (inline) + explicit precision(unsigned); + }; - template - FTy const& get_facet(std::basic_ios&); - template - std::basic_ios& formatted(std::basic_ios&); - template - std::basic_ios& unformattet(std::basic_ios&); - - template - std::basic_ostream& operator<<(std::basic_ostream&, precision const&); - template - std::basic_ostream& operator<<(std::basic_ostream&, width const&); - template - std::basic_ostream& operator<<(std::basic_ostream&, delimeter const&); - template - std::basic_ostream& operator<<(std::basic_ostream&, order const&); - - }//namespace io + struct width + { + unsigned value; - namespace detail - { + explicit width(unsigned); + }; - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tquat const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x4 const&); - - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, - std::pair const, - tmat4x4 const> const&); - - }//namespace detail - - /// @} + template + struct delimeter + { + CTy value[3]; + + explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ','); + }; + + struct order + { + order_type value; + + explicit order(order_type); + }; + + // functions, inlined (inline) + + template + FTy const& get_facet(std::basic_ios&); + template + std::basic_ios& formatted(std::basic_ios&); + template + std::basic_ios& unformattet(std::basic_ios&); + + template + std::basic_ostream& operator<<(std::basic_ostream&, precision const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, width const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, delimeter const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, order const&); + }//namespace io + + namespace detail + { + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tquat const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x4 const&); + + template + GLM_FUNC_DECL std::basic_ostream & operator<<( + std::basic_ostream &, + std::pair const, + tmat4x4 const> const &); + }//namespace detail + + /// @} }//namespace glm #include "io.inl" diff --git a/glm/gtx/io.inl b/glm/gtx/io.inl index 3132a88e..dbad163c 100644 --- a/glm/gtx/io.inl +++ b/glm/gtx/io.inl @@ -10,570 +10,589 @@ #include // std::setfill<>, std::fixed, std::setprecision, std::right, std::setw #include // std::basic_ostream<> -namespace glm +namespace glm{ +namespace io { - namespace io - { - - template - /* explicit */ GLM_FUNC_QUALIFIER - format_punct::format_punct(size_t a) - : std::locale::facet(a), - formatted (true), - precision (3), - width (1 + 4 + 1 + precision), - separator (','), - delim_left ('['), - delim_right (']'), - space (' '), - newline ('\n'), - order (row_major) - {} - - template - /* explicit */ GLM_FUNC_QUALIFIER - format_punct::format_punct(format_punct const& a) - : std::locale::facet(0), - formatted (a.formatted), - precision (a.precision), - width (a.width), - separator (a.separator), - delim_left (a.delim_left), - delim_right (a.delim_right), - space (a.space), - newline (a.newline), - order (a.order) - {} - - template std::locale::id format_punct::id; - - template - /* explicit */ GLM_FUNC_QUALIFIER - basic_state_saver::basic_state_saver(std::basic_ios& a) - : state_ (a), - flags_ (a.flags()), - precision_(a.precision()), - width_ (a.width()), - fill_ (a.fill()), - locale_ (a.getloc()) - {} - - template - GLM_FUNC_QUALIFIER - basic_state_saver::~basic_state_saver() - { - state_.imbue(locale_); - state_.fill(fill_); - state_.width(width_); - state_.precision(precision_); - state_.flags(flags_); - } - - template - /* explicit */ GLM_FUNC_QUALIFIER - basic_format_saver::basic_format_saver(std::basic_ios& a) - : bss_(a) - { - a.imbue(std::locale(a.getloc(), new format_punct(get_facet >(a)))); - } - - template - GLM_FUNC_QUALIFIER - basic_format_saver::~basic_format_saver() - {} - - /* explicit */ GLM_FUNC_QUALIFIER - precision::precision(unsigned a) - : value(a) - {} - - /* explicit */ GLM_FUNC_QUALIFIER - width::width(unsigned a) - : value(a) - {} - - template - /* explicit */ GLM_FUNC_QUALIFIER - delimeter::delimeter(CTy a, CTy b, CTy c) - : value() - { - value[0] = a; - value[1] = b; - value[2] = c; - } - - /* explicit */ GLM_FUNC_QUALIFIER - order::order(order_type a) - : value(a) - {} - - template - GLM_FUNC_QUALIFIER FTy const& - get_facet(std::basic_ios& ios) - { - if (!std::has_facet(ios.getloc())) { - ios.imbue(std::locale(ios.getloc(), new FTy)); - } - - return std::use_facet(ios.getloc()); - } - - template - GLM_FUNC_QUALIFIER std::basic_ios& - formatted(std::basic_ios& ios) - { - const_cast&>(get_facet >(ios)).formatted = true; - - return ios; - } - - template - GLM_FUNC_QUALIFIER std::basic_ios& - unformatted(std::basic_ios& ios) - { - const_cast&>(get_facet >(ios)).formatted = false; - - return ios; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, precision const& a) - { - const_cast&>(get_facet >(os)).precision = a.value; - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, width const& a) - { - const_cast&>(get_facet >(os)).width = a.value; - - return os; - } - - template - std::basic_ostream& operator<<(std::basic_ostream& os, - delimeter const& a) - { - format_punct& fmt(const_cast&>(get_facet >(os))); - - fmt.delim_left = a.value[0]; - fmt.delim_right = a.value[1]; - fmt.separator = a.value[2]; - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, order const& a) - { - const_cast&>(get_facet >(os)).order = a.value; - - return os; - } - - } // namespace io - - namespace detail { - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tquat const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - - if (fmt.formatted) { - io::basic_state_saver const bss(os); - - os << std::fixed - << std::right - << std::setprecision(fmt.precision) - << std::setfill(fmt.space) - << fmt.delim_left - << std::setw(fmt.width) << a.w << fmt.separator - << std::setw(fmt.width) << a.x << fmt.separator - << std::setw(fmt.width) << a.y << fmt.separator - << std::setw(fmt.width) << a.z - << fmt.delim_right; - } else { - os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tvec2 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - - if (fmt.formatted) { - io::basic_state_saver const bss(os); - - os << std::fixed - << std::right - << std::setprecision(fmt.precision) - << std::setfill(fmt.space) - << fmt.delim_left - << std::setw(fmt.width) << a.x << fmt.separator - << std::setw(fmt.width) << a.y - << fmt.delim_right; - } else { - os << a.x << fmt.space << a.y; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tvec3 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - - if (fmt.formatted) { - io::basic_state_saver const bss(os); - - os << std::fixed - << std::right - << std::setprecision(fmt.precision) - << std::setfill(fmt.space) - << fmt.delim_left - << std::setw(fmt.width) << a.x << fmt.separator - << std::setw(fmt.width) << a.y << fmt.separator - << std::setw(fmt.width) << a.z - << fmt.delim_right; - } else { - os << a.x << fmt.space << a.y << fmt.space << a.z; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tvec4 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - - if (fmt.formatted) { - io::basic_state_saver const bss(os); - - os << std::fixed - << std::right - << std::setprecision(fmt.precision) - << std::setfill(fmt.space) - << fmt.delim_left - << std::setw(fmt.width) << a.x << fmt.separator - << std::setw(fmt.width) << a.y << fmt.separator - << std::setw(fmt.width) << a.z << fmt.separator - << std::setw(fmt.width) << a.w - << fmt.delim_right; - } else { - os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat2x2 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat2x2 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat2x3 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat3x2 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat2x4 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat4x2 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.newline - << fmt.space << m[3] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat3x2 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat2x3 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat3x3 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat3x3 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat3x4 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat4x3 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.newline - << fmt.space << m[3] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat4x2 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat2x4 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat4x3 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat3x4 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, tmat4x4 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat4x4 m(a); - - if (io::row_major == fmt.order) { - m = transpose(a); - } - - if (fmt.formatted) { - os << fmt.newline - << fmt.delim_left << m[0] << fmt.newline - << fmt.space << m[1] << fmt.newline - << fmt.space << m[2] << fmt.newline - << fmt.space << m[3] << fmt.delim_right; - } else { - os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; - } - } - - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& - operator<<(std::basic_ostream& os, - std::pair const, tmat4x4 const> const& a) - { - typename std::basic_ostream::sentry const cerberus(os); - - if (cerberus) { - io::format_punct const& fmt(io::get_facet >(os)); - tmat4x4 ml(a.first); - tmat4x4 mr(a.second); - - if (io::row_major == fmt.order) { - ml = transpose(a.first); - mr = transpose(a.second); - } - - if (fmt.formatted) { - CTy const& l(fmt.delim_left); - CTy const& r(fmt.delim_right); - CTy const& s(fmt.space); - - os << fmt.newline - << l << ml[0] << s << s << l << mr[0] << fmt.newline - << s << ml[1] << s << s << s << mr[1] << fmt.newline - << s << ml[2] << s << s << s << mr[2] << fmt.newline - << s << ml[3] << r << s << s << mr[3] << r; - } else { - os << ml << fmt.space << mr; - } - } - - return os; - } - - }//namespace detail + template + /* explicit */ GLM_FUNC_QUALIFIER + format_punct::format_punct(size_t a) + : std::locale::facet(a), + formatted (true), + precision (3), + width (1 + 4 + 1 + precision), + separator (','), + delim_left ('['), + delim_right (']'), + space (' '), + newline ('\n'), + order (row_major) + {} + + template + /* explicit */ GLM_FUNC_QUALIFIER + format_punct::format_punct(format_punct const& a) + : std::locale::facet(0), + formatted (a.formatted), + precision (a.precision), + width (a.width), + separator (a.separator), + delim_left (a.delim_left), + delim_right (a.delim_right), + space (a.space), + newline (a.newline), + order (a.order) + {} + + template std::locale::id format_punct::id; + + template + /* explicit */ GLM_FUNC_QUALIFIER basic_state_saver::basic_state_saver(std::basic_ios& a) + : state_ (a), + flags_ (a.flags()), + precision_(a.precision()), + width_ (a.width()), + fill_ (a.fill()), + locale_ (a.getloc()) + {} + + template + GLM_FUNC_QUALIFIER basic_state_saver::~basic_state_saver() + { + state_.imbue(locale_); + state_.fill(fill_); + state_.width(width_); + state_.precision(precision_); + state_.flags(flags_); + } + + template + /* explicit */ GLM_FUNC_QUALIFIER basic_format_saver::basic_format_saver(std::basic_ios& a) + : bss_(a) + { + a.imbue(std::locale(a.getloc(), new format_punct(get_facet >(a)))); + } + + template + GLM_FUNC_QUALIFIER + basic_format_saver::~basic_format_saver() + {} + + /* explicit */ GLM_FUNC_QUALIFIER precision::precision(unsigned a) + : value(a) + {} + + /* explicit */ GLM_FUNC_QUALIFIER width::width(unsigned a) + : value(a) + {} + + template + /* explicit */ GLM_FUNC_QUALIFIER delimeter::delimeter(CTy a, CTy b, CTy c) + : value() + { + value[0] = a; + value[1] = b; + value[2] = c; + } + + /* explicit */ GLM_FUNC_QUALIFIER + order::order(order_type a) + : value(a) + {} + + template + GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios& ios) + { + if (!std::has_facet(ios.getloc())) { + ios.imbue(std::locale(ios.getloc(), new FTy)); + } + + return std::use_facet(ios.getloc()); + } + + template + GLM_FUNC_QUALIFIER std::basic_ios& formatted(std::basic_ios& ios) + { + const_cast&>(get_facet >(ios)).formatted = true; + + return ios; + } + + template + GLM_FUNC_QUALIFIER std::basic_ios& unformatted(std::basic_ios& ios) + { + const_cast&>(get_facet >(ios)).formatted = false; + + return ios; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, precision const& a) + { + const_cast&>(get_facet >(os)).precision = a.value; + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, width const& a) + { + const_cast&>(get_facet >(os)).width = a.value; + + return os; + } + + template + std::basic_ostream& operator<<(std::basic_ostream& os, delimeter const& a) + { + format_punct & fmt(const_cast&>(get_facet >(os))); + + fmt.delim_left = a.value[0]; + fmt.delim_right = a.value[1]; + fmt.separator = a.value[2]; + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, order const& a) + { + const_cast&>(get_facet >(os)).order = a.value; + + return os; + } +} // namespace io + +namespace detail +{ + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tquat const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + + if(fmt.formatted) + { + io::basic_state_saver const bss(os); + + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.w << fmt.separator + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z + << fmt.delim_right; + } + else + { + os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + + if(fmt.formatted) + { + io::basic_state_saver const bss(os); + + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + + if(fmt.formatted) + { + io::basic_state_saver const bss(os); + + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y << fmt.space << a.z; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + + if(fmt.formatted) + { + io::basic_state_saver const bss(os); + + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z << fmt.separator + << std::setw(fmt.width) << a.w + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x2 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x2 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x2 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x3 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x3 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat3x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x3 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if (fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x4 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if (fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x4 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x4 m(a); + + if (io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<( + std::basic_ostream & os, + std::pair const, tmat4x4 const> const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x4 ml(a.first); + tmat4x4 mr(a.second); + + if(io::row_major == fmt.order) + { + ml = transpose(a.first); + mr = transpose(a.second); + } + + if(fmt.formatted) + { + CTy const & l(fmt.delim_left); + CTy const & r(fmt.delim_right); + CTy const & s(fmt.space); + + os << fmt.newline + << l << ml[0] << s << s << l << mr[0] << fmt.newline + << s << ml[1] << s << s << s << mr[1] << fmt.newline + << s << ml[2] << s << s << s << mr[2] << fmt.newline + << s << ml[3] << r << s << s << mr[3] << r; + } + else + { + os << ml << fmt.space << mr; + } + } + + return os; + } +}//namespace detail }//namespace glm