#ifndef TEST_CONFORMANCE_CLCPP_UTILS_COMMON_STRING_HPP
#define TEST_CONFORMANCE_CLCPP_UTILS_COMMON_STRING_HPP
#include <string>
#include <sstream>
#include <iomanip>
#include <type_traits>
#include "is_vector_type.hpp"
#include "scalar_type.hpp"
#include "type_name.hpp"
#include "../common.hpp"
template<class type>
std::string format_value(const type& value,
typename std::enable_if<is_vector_type<type>::value>::type* = 0)
{
std::stringstream s;
s << type_name<type>() << "{ ";
s << std::scientific << std::setprecision(6);
for (size_t j = 0; j < vector_size<type>::value; j++)
{
if (j > 0)
s << ", ";
s << value.s[j];
}
s << " }";
return s.str();
}
template<class type>
std::string format_value(const type& value,
typename std::enable_if<!is_vector_type<type>::value>::type* = 0)
{
std::stringstream s;
s << type_name<type>() << "{ ";
s << std::scientific << std::setprecision(6);
s << value;
s << " }";
return s.str();
}
void replace_all(std::string& str, const std::string& from, const std::string& to)
{
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length();
}
}
#endif