17 template <
class T,
int Dim,
bool Packed>
18 std::ostream& operator<<(std::ostream& os, const mathter::Vector<T, Dim, Packed>& v) {
20 for (
int x = 0; x < Dim; ++x) {
21 os << v(x) << (x == Dim - 1 ?
"" :
", ");
30 struct dependent_false {
31 static constexpr
bool value =
false;
36 template <class AritT, typename std::enable_if<std::is_integral<AritT>::value && std::is_signed<AritT>::value,
int>::type = 0>
37 AritT
strtonum(
const char* str,
const char** end) {
39 value = (AritT)strtoll(str, (
char**)end, 10);
42 template <class AritT, typename std::enable_if<std::is_integral<AritT>::value && !std::is_signed<AritT>::value,
int>::type = 0>
43 AritT
strtonum(
const char* str,
const char** end) {
45 value = (AritT)strtoull(str, (
char**)end, 10);
48 template <class AritT, typename std::enable_if<std::is_floating_point<AritT>::value,
int>::type = 0>
49 AritT
strtonum(
const char* str,
const char** end) {
51 value = (AritT)strtold(str, (
char**)end);
56 while (*str !=
'\0' && isspace(*str))
64 template <
class T,
int Dim,
bool Packed>
68 const char* strproc = str;
72 if (*strproc ==
'\0') {
77 char startBracket = *strproc;
79 bool hasBrackets =
false;
80 switch (startBracket) {
99 for (
int i = 0; i < Dim; ++i) {
101 T elem = impl::strtonum<T>(strproc, &elemend);
102 if (elemend == strproc) {
111 if (*strproc ==
',') {
119 if (*strproc != endBracket) {
130 template <
class VectorT>
131 VectorT
strtovec(
const char* str,
const char** end) {
145 template <
class T,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool Packed>
146 std::ostream& operator<<(std::ostream& os, const Matrix<T, Rows, Columns, Order, Layout, Packed>& mat) {
148 for (
int i = 0; i < mat.Height(); ++i) {
149 for (
int j = 0; j < mat.Width(); ++j) {
150 os << mat(i, j) << (j == mat.Width() - 1 ?
"" :
", ");
161 template <
class T,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool Packed>
167 const char* strproc = str;
171 if (*strproc ==
'\0') {
176 char startBracket = *strproc;
178 bool hasBrackets =
false;
179 switch (startBracket) {
198 for (
int i = 0; i < Rows; ++i) {
200 VectorT row = strtovec<VectorT>(strproc, &rowend);
201 if (rowend == strproc) {
211 if (*strproc ==
';') {
224 if (*strproc != endBracket) {
235 template <
class MatrixT>
236 MatrixT
strtomat(
const char* str,
const char** end) {
250 template <
class T,
bool Packed>
251 std::ostream& operator<<(std::ostream& os, const Quaternion<T, Packed>& q) {
253 << q.Angle() * T(180.0) / T(3.1415926535897932384626)
Matrix< T, Rows, Columns, Order, Layout, Packed > strtomat(const char *str, const char **end)
Definition: IoStream.hpp:162
Definition: Traits.hpp:113
Definition: Traits.hpp:144
Definition: Traits.hpp:29
eEnclosingBracket
Definition: IoStream.hpp:9
Represents a vector in N-dimensional space.
Definition: Definitions.hpp:57
Definition: Traits.hpp:48
const char * StripSpaces(const char *str)
Definition: IoStream.hpp:55
constexpr bool dependent_false_v
Definition: IoStream.hpp:34
Definition: Approx.hpp:11
Vector< T, Dim, Packed > strtovec(const char *str, const char **end)
Parses a vector from a string.
Definition: IoStream.hpp:65
Definition: Definitions.hpp:63
AritT strtonum(const char *str, const char **end)
Definition: IoStream.hpp:37