aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/ResTraits.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/ResTraits.hh')
-rw-r--r--src/FbTk/ResTraits.hh18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/FbTk/ResTraits.hh b/src/FbTk/ResTraits.hh
index 3284801..19decb5 100644
--- a/src/FbTk/ResTraits.hh
+++ b/src/FbTk/ResTraits.hh
@@ -160,14 +160,17 @@ struct EnumTraits {
160 } 160 }
161}; 161};
162 162
163template<typename Traits, const char *delim> 163template<typename Traits>
164struct VectorTraits { 164struct VectorTraits {
165 typedef std::vector<typename Traits::Type> Type; 165 typedef std::vector<typename Traits::Type> Type;
166 static std::string toString(const Type &x) { 166
167 VectorTraits(const std::string &delim) : m_delim(delim) {}
168
169 std::string toString(const Type &x) const {
167 std::string retval; 170 std::string retval;
168 for(size_t i = 0; i < x.size(); ++i) { 171 for(size_t i = 0; i < x.size(); ++i) {
169 retval.append(Traits::toString(x[i])); 172 retval += Traits::toString(x[i]);
170 retval.append(" "); 173 retval += m_delim[0];
171 } 174 }
172 175
173 return retval; 176 return retval;
@@ -184,9 +187,9 @@ struct VectorTraits {
184 } 187 }
185 } 188 }
186 189
187 static Type fromString(const std::string &x) { 190 Type fromString(const std::string &x) const {
188 std::vector<std::string> val; 191 std::vector<std::string> val;
189 StringUtil::stringtok(val, x, delim); 192 StringUtil::stringtok(val, x, m_delim.c_str());
190 Type retval; 193 Type retval;
191 194
192 for(size_t i = 0; i < val.size(); i++) { 195 for(size_t i = 0; i < val.size(); i++) {
@@ -218,6 +221,9 @@ struct VectorTraits {
218 throw ConversionError( std::string("Cannot convert to vector from lua type ") 221 throw ConversionError( std::string("Cannot convert to vector from lua type ")
219 + l.type_name(l.type(-1)) ); 222 + l.type_name(l.type(-1)) );
220 } 223 }
224
225private:
226 std::string m_delim;
221}; 227};
222 228
223} // end namespace FbTk 229} // end namespace FbTk