alaCarte Maps
Renderer for OpenStreetMap tiles
eval_helpers.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef _EVAL_HELPERS_HPP
23 #define _EVAL_HELPERS_HPP
24 
25 
26 #include "settings.hpp"
27 
28 
29 
30 namespace eval {
31 
39 template<typename T>
40 bool Conv(const string& str, T* out, bool tryToCache = false)
41 {
42  assert(out);
43  std::istringstream is(str);
44  is >> *out;
45 
46  return !is.bad() && is.eof();
47 }
48 
50 template<>
51 bool Conv(const string& str, bool* out, bool tryToCache);
52 
54 template<>
55 bool Conv(const string& str, Color* out, bool tryToCache);
56 
58 template<>
59 bool Conv(const string& str, string* out, bool tryToCache );
60 
62 template<>
63 bool Conv(const string& str, MaybeCachedString* out, bool tryToCache);
64 
65 
72 template<typename T>
73 string ToString(const T& v)
74 {
75  std::ostringstream os;
76  os << v;
77 
78  return os.str();
79 }
80 
81 // Use extra Conversion if the type is a bool
82 template<>
83 string ToString(const bool& v);
84 
91 template<typename Iter1, typename Iter2>
92 string ToString(Iter1 begin, Iter2 end)
93 {
94  string result;
95 
96  while(begin != end)
97  {
98  result += ToString(*begin);
99  ++begin;
100  }
101 
102  return result;
103 }
104 
105 
106 
107 }
108 
109 
110 
111 #endif
Definition: color.hpp:40
bool Conv(const string &str, bool *out, bool tryToCache)
Use some extra function for bool conversion.
Represents a string which could be cached into an internal cache.
This file is part of alaCarte.
string ToString(const bool &v)