Skip to content
Snippets Groups Projects
Commit ee148009 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Add char type to converter.h

parent 93ed7c09
No related branches found
No related tags found
1 merge request!385Resolve "State key char instead of string"
Pipeline #5730 failed
...@@ -94,6 +94,14 @@ struct converter<bool>{ ...@@ -94,6 +94,14 @@ struct converter<bool>{
} }
}; };
template<> template<>
struct converter<char>{
static char convert(std::string val){
//Here we should check that val.length() == 1 and get val[0] into a char variable
throw std::runtime_error("Invalid char conversion. String provided: " + val);
}
};
//// TYPES ----> ToSTRING
template<>
struct converter<std::string>{ struct converter<std::string>{
static std::string convert(std::string val){ static std::string convert(std::string val){
return val; return val;
...@@ -109,6 +117,9 @@ struct converter<std::string>{ ...@@ -109,6 +117,9 @@ struct converter<std::string>{
static std::string convert(double val){ static std::string convert(double val){
return std::to_string(val); return std::to_string(val);
} }
static std::string convert(char val){
return std::to_string(val);
}
template<typename A> template<typename A>
static std::string convert(utils::list<A> val){ static std::string convert(utils::list<A> val){
std::string result = ""; std::string result = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment