Use GLM coding convensions

This commit is contained in:
Christophe Riccio 2016-04-30 14:59:56 +02:00
parent e913a9c68b
commit a6b3632257

View File

@ -39,45 +39,43 @@ namespace glm{
namespace io
{
template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER
format_punct<CTy>::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 (column_major)
GLM_FUNC_QUALIFIER format_punct<CTy>::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(column_major)
{}
template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER
format_punct<CTy>::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)
GLM_FUNC_QUALIFIER format_punct<CTy>::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 <typename CTy> std::locale::id format_punct<CTy>::id;
template <typename CTy, typename CTr>
/* explicit */ GLM_FUNC_QUALIFIER basic_state_saver<CTy,CTr>::basic_state_saver(std::basic_ios<CTy,CTr>& a)
: state_ (a),
flags_ (a.flags()),
precision_(a.precision()),
width_ (a.width()),
fill_ (a.fill()),
locale_ (a.getloc())
GLM_FUNC_QUALIFIER basic_state_saver<CTy, CTr>::basic_state_saver(std::basic_ios<CTy, CTr>& a)
: state_(a)
, flags_(a.flags())
, precision_(a.precision())
, width_(a.width())
, fill_(a.fill())
, locale_(a.getloc())
{}
template <typename CTy, typename CTr>
@ -91,7 +89,7 @@ namespace io
}
template <typename CTy, typename CTr>
/* explicit */ GLM_FUNC_QUALIFIER basic_format_saver<CTy,CTr>::basic_format_saver(std::basic_ios<CTy,CTr>& a)
GLM_FUNC_QUALIFIER basic_format_saver<CTy, CTr>::basic_format_saver(std::basic_ios<CTy, CTr>& a)
: bss_(a)
{
a.imbue(std::locale(a.getloc(), new format_punct<CTy>(get_facet<format_punct<CTy> >(a))));
@ -102,16 +100,16 @@ namespace io
basic_format_saver<CTy, CTr>::~basic_format_saver()
{}
/* explicit */ GLM_FUNC_QUALIFIER precision::precision(unsigned a)
GLM_FUNC_QUALIFIER precision::precision(unsigned a)
: value(a)
{}
/* explicit */ GLM_FUNC_QUALIFIER width::width(unsigned a)
GLM_FUNC_QUALIFIER width::width(unsigned a)
: value(a)
{}
template <typename CTy>
/* explicit */ GLM_FUNC_QUALIFIER delimeter<CTy>::delimeter(CTy a, CTy b, CTy c)
GLM_FUNC_QUALIFIER delimeter<CTy>::delimeter(CTy a, CTy b, CTy c)
: value()
{
value[0] = a;
@ -119,16 +117,15 @@ namespace io
value[2] = c;
}
/* explicit */ GLM_FUNC_QUALIFIER order::order(order_type a)
GLM_FUNC_QUALIFIER order::order(order_type a)
: value(a)
{}
template <typename FTy, typename CTy, typename CTr>
GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios<CTy, CTr>& ios)
{
if (!std::has_facet<FTy>(ios.getloc())) {
if(!std::has_facet<FTy>(ios.getloc()))
ios.imbue(std::locale(ios.getloc(), new FTy));
}
return std::use_facet<FTy>(ios.getloc());
}
@ -137,7 +134,6 @@ namespace io
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> >(ios)).formatted = true;
return ios;
}
@ -145,7 +141,6 @@ namespace io
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> >(ios)).formatted = false;
return ios;
}
@ -153,7 +148,6 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, precision const& a)
{
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).precision = a.value;
return os;
}
@ -161,7 +155,6 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, width const& a)
{
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).width = a.value;
return os;
}
@ -181,13 +174,12 @@ namespace io
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, order const& a)
{
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).order = a.value;
return os;
}
} // namespace io
namespace detail {
namespace detail
{
template <typename CTy, typename CTr, template <typename, precision> class V, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_vector_on(std::basic_ostream<CTy, CTr>& os, V<T,P> const& a)
@ -204,34 +196,32 @@ namespace io
{
io::basic_state_saver<CTy> const bss(os);
os << std::fixed
<< std::right
<< std::setprecision(fmt.precision)
<< std::setfill(fmt.space)
<< fmt.delim_left;
os << std::fixed << std::right << std::setprecision(fmt.precision) << std::setfill(fmt.space) << fmt.delim_left;
for (length_t i(0); i < components; ++i) {
for(length_t i(0); i < components; ++i)
{
os << std::setw(fmt.width) << a[i];
if (components-1 != i) { os << fmt.separator; }
if(components-1 != i)
os << fmt.separator;
}
os << fmt.delim_right;
}
else
{
for (length_t i(0); i < components; ++i) {
for(length_t i(0); i < components; ++i)
{
os << a[i];
if (components-1 != i) { os << fmt.space; }
if(components-1 != i)
os << fmt.space;
}
}
}
return os;
}
}
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tquat<T,P> const& a)
@ -263,8 +253,8 @@ namespace io
return detail::print_vector_on(os, a);
}
namespace detail {
namespace detail
{
template <typename CTy, typename CTr, template <typename, precision> class M, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_matrix_on(std::basic_ostream<CTy, CTr>& os, M<T,P> const& a)
@ -278,55 +268,69 @@ namespace io
length_t const& cols(type<M, T, P>::cols);
length_t const& rows(type<M, T, P>::rows);
if(fmt.formatted) {
os << fmt.newline
<< fmt.delim_left;
if(fmt.formatted)
{
os << fmt.newline << fmt.delim_left;
switch (fmt.order) {
switch(fmt.order)
{
case io::column_major:
{
for (length_t i(0); i < rows; ++i) {
if (0 != i) { os << fmt.space; }
for(length_t i(0); i < rows; ++i)
{
if (0 != i)
os << fmt.space;
os << row(a, i);
if (rows-1 != i) { os << fmt.newline; }
if(rows-1 != i)
os << fmt.newline;
}
}
break;
case io::row_major:
{
for (length_t i(0); i < cols; ++i) {
if (0 != i) { os << fmt.space; }
for(length_t i(0); i < cols; ++i)
{
if(0 != i)
os << fmt.space;
os << column(a, i);
if (cols-1 != i) { os << fmt.newline; }
if(cols-1 != i)
os << fmt.newline;
}
}
break;
}
os << fmt.delim_right;
} else {
switch (fmt.order) {
}
else
{
switch (fmt.order)
{
case io::column_major:
{
for (length_t i(0); i < cols; ++i) {
for(length_t i(0); i < cols; ++i)
{
os << column(a, i);
if (cols-1 != i) { os << fmt.space; }
if(cols - 1 != i)
os << fmt.space;
}
}
break;
case io::row_major:
{
for (length_t i(0); i < rows; ++i) {
for (length_t i(0); i < rows; ++i)
{
os << row(a, i);
if (rows-1 != i) { os << fmt.space; }
if (rows-1 != i)
os << fmt.space;
}
}
break;
@ -336,8 +340,7 @@ namespace io
return os;
}
}
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x2<T,P> const& a)
@ -393,8 +396,8 @@ namespace io
return detail::print_matrix_on(os, a);
}
namespace detail {
namespace detail
{
template <typename CTy, typename CTr, template <typename, precision> class M, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
print_matrix_pair_on(std::basic_ostream<CTy, CTr>& os, std::pair<M<T, P> const, M<T, P> const> const& a)
@ -409,57 +412,59 @@ namespace io
length_t const& cols(type<M, T, P>::cols);
length_t const& rows(type<M, T, P>::rows);
if(fmt.formatted) {
os << fmt.newline
<< fmt.delim_left;
if(fmt.formatted)
{
os << fmt.newline << fmt.delim_left;
switch (fmt.order) {
switch(fmt.order)
{
case io::column_major:
{
for (length_t i(0); i < rows; ++i) {
if (0 != i) { os << fmt.space; }
for(length_t i(0); i < rows; ++i)
{
if(0 != i)
os << fmt.space;
os << row(ml, i)
<< ((rows-1 != i) ? fmt.space : fmt.delim_right)
<< fmt.space
<< ((0 != i) ? fmt.space : fmt.delim_left)
<< row(mr, i);
os << row(ml, i) << ((rows-1 != i) ? fmt.space : fmt.delim_right) << fmt.space << ((0 != i) ? fmt.space : fmt.delim_left) << row(mr, i);
if (rows-1 != i) { os << fmt.newline; }
if(rows-1 != i)
os << fmt.newline;
}
}
break;
case io::row_major:
{
for (length_t i(0); i < cols; ++i) {
if (0 != i) { os << fmt.space; }
for(length_t i(0); i < cols; ++i)
{
if(0 != i)
os << fmt.space;
os << column(ml, i)
<< ((cols-1 != i) ? fmt.space : fmt.delim_right)
<< fmt.space
<< ((0 != i) ? fmt.space : fmt.delim_left)
<< column(mr, i);
os << column(ml, i) << ((cols-1 != i) ? fmt.space : fmt.delim_right) << fmt.space << ((0 != i) ? fmt.space : fmt.delim_left) << column(mr, i);
if (cols-1 != i) { os << fmt.newline; }
if(cols-1 != i)
os << fmt.newline;
}
}
break;
}
os << fmt.delim_right;
} else {
}
else
{
os << ml << fmt.space << mr;
}
}
return os;
}
}
}//namespace detail
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr> & os,
std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const& a)
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(
std::basic_ostream<CTy, CTr> & os,
std::pair<tmat4x4<T, P> const,
tmat4x4<T, P> const> const& a)
{
return detail::print_matrix_pair_on(os, a);
}