changes to how formatter works
parent
b564b3e57b
commit
7e405a27ee
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
|
|
||||||
set(BLT_VERSION 0.14.13)
|
set(BLT_VERSION 0.14.14)
|
||||||
set(BLT_TEST_VERSION 0.0.1)
|
set(BLT_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
|
@ -73,11 +73,16 @@ namespace blt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<int decimal_places>
|
template<int decimal_places>
|
||||||
static inline double round_up(double value)
|
constexpr static inline double round_up(double value)
|
||||||
|
{
|
||||||
|
if constexpr (decimal_places < 0)
|
||||||
|
return value;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
constexpr double multiplier = pow(10, decimal_places);
|
constexpr double multiplier = pow(10, decimal_places);
|
||||||
return ((int) (value * multiplier) + 1) / multiplier;
|
return ((int) (value * multiplier) + 1) / multiplier;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*inline std::ostream& operator<<(std::ostream& out, const mat4x4& v) {
|
/*inline std::ostream& operator<<(std::ostream& out, const mat4x4& v) {
|
||||||
return out << "\rMatrix4x4{" << v.m00() << ", " << v.m01() << ", " << v.m02() << ", " << v.m03() << "} \n"\
|
return out << "\rMatrix4x4{" << v.m00() << ", " << v.m01() << ", " << v.m02() << ", " << v.m03() << "} \n"\
|
||||||
|
|
|
@ -970,7 +970,12 @@ namespace blt
|
||||||
deallocate(p);
|
deallocate(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const auto& getStats()
|
inline void resetStats()
|
||||||
|
{
|
||||||
|
stats = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const auto& getStats() const
|
||||||
{
|
{
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,20 +39,21 @@ namespace blt::string
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int decimal_places = 0>
|
||||||
static inline std::string fromBytes(unsigned long bytes)
|
static inline std::string fromBytes(unsigned long bytes)
|
||||||
{
|
{
|
||||||
if (bytes > 1073741824)
|
if (bytes > 1073741824)
|
||||||
{
|
{
|
||||||
// gigabyte
|
// gigabyte
|
||||||
return std::to_string(round_up<3>((double) bytes / 1024.0 / 1024.0 / 1024.0)) += "gb";
|
return std::to_string(round_up<decimal_places>((double) bytes / 1024.0 / 1024.0 / 1024.0)) += "gb";
|
||||||
} else if (bytes > 1048576)
|
} else if (bytes > 1048576)
|
||||||
{
|
{
|
||||||
// megabyte
|
// megabyte
|
||||||
return std::to_string(round_up<3>((double) bytes / 1024.0 / 1024.0)) += "mb";
|
return std::to_string(round_up<decimal_places>((double) bytes / 1024.0 / 1024.0)) += "mb";
|
||||||
} else if (bytes > 1024)
|
} else if (bytes > 1024)
|
||||||
{
|
{
|
||||||
// kilobyte
|
// kilobyte
|
||||||
return std::to_string(round_up<3>((double) bytes / 1024.0)) += "kb";
|
return std::to_string(round_up<decimal_places>((double) bytes / 1024.0)) += "kb";
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
return std::to_string(bytes) += "b";
|
return std::to_string(bytes) += "b";
|
||||||
|
|
Loading…
Reference in New Issue