/*
 * Copyright (c) 1999-2021 Hartmut Seichter
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */
#ifndef PW_CORE_SERIALIZE_HPP
#define PW_CORE_SERIALIZE_HPP

#include <pw/core/axisangle.hpp>
#include <pw/core/matrix.hpp>
#include <pw/core/quaternion.hpp>
#include <pw/core/vector.hpp>
#include <pw/core/color.hpp>


#include <sstream>
#include <string>

namespace pw {

struct serialize {

    template <typename T, auto N>
    constexpr static std::string to_string(const vector<T, N>& v) {
        std::stringstream ss;
        for (const auto& e : v)
            ss << e << ' ';
        return ss.str();
    }

    template <typename T, auto R, auto C>
    constexpr static std::string to_string(const matrix<T, R, C>& m) {
        std::stringstream ss;

        for (int r = 0; r < R; r++) {
            ss << to_string(m[r]) << '\n';
        }

        return ss.str();
    }

    template <typename T>
    constexpr static std::string to_string(const quaternion<T>& v) {
        std::stringstream ss;
        ss << to_string(v.q_);
        return ss.str();
    }

    constexpr static std::string to_string(const color& v) {
        std::stringstream ss;
        ss << to_string(v.rgba);
        return ss.str();
    }
};

} // namespace pw

#endif
