Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplemented io support for basic types #144

Merged
merged 7 commits into from
Jun 19, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
un/formatted() usage to un/formatted
  • Loading branch information
regnirpsj committed Dec 26, 2013
commit 39179ba1adde7f860826bc5e667f0f224758e5b3
11 changes: 4 additions & 7 deletions glm/gtx/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ namespace glm
typedef basic_format_saver<char> format_saver;
typedef basic_format_saver<wchar_t> wformat_saver;

struct formatted { /* empty */ };
struct unformatted { /* empty */ };

struct precision {

unsigned value;
Expand Down Expand Up @@ -178,11 +175,11 @@ namespace glm

template <typename FTy, typename CTy, typename CTr>
FTy const& get_facet(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&);

template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, formatted const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, unformatted const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
template <typename CTy, typename CTr>
Expand Down
18 changes: 9 additions & 9 deletions glm/gtx/io.inl
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ namespace glm
}

template <typename CTy, typename CTr>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
operator<<(std::basic_ostream<CTy, CTr>& os, formatted const&)
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
formatted(std::basic_ios<CTy,CTr>& ios)
{
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(os)).formatted = true;
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(ios)).formatted = true;

return os;
return ios;
}

template <typename CTy, typename CTr>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
operator<<(std::basic_ostream<CTy, CTr>& os, unformatted const&)
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
unformatted(std::basic_ios<CTy,CTr>& ios)
{
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(os)).formatted = false;
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(ios)).formatted = false;

return os;
return ios;
}

template <typename CTy, typename CTr>
Expand Down
4 changes: 2 additions & 2 deletions test/gtx/gtx_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int test_io_quat(OS& os)
{
glm::io::basic_format_saver<typename OS::char_type> const iofs(os);

os << glm::io::unformatted()
os << glm::io::unformatted
<< type_name<T,P>(os, q) << ": " << q << '\n';
}

Expand Down Expand Up @@ -157,7 +157,7 @@ int test_io_mat(OS& os)
<< "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';

os << glm::io::unformatted()
os << glm::io::unformatted
<< glm::io::order(glm::io::order_type::column_major)
<< "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x3<T,P>(v3_1, v3_2) << '\n'
Expand Down