void set(string s) { switch(type) { case boolean_t: *(bool*)data = (s == "true"); break; case signed_t: *(signed*)data = strsigned(s); break; case unsigned_t: *(unsigned*)data = strunsigned(s); break; case double_t: *(double*)data = strdouble(s); break; case string_t: trim(s, "\""); *(string*)data = s; break; } }
static uint16_t decode(const char *name) { string s(name); if(!strbegin(name, "KB")) return 0; ltrim(s, "KB"); unsigned id = strunsigned(s); auto pos = strpos(s, "::"); if(!pos) return 0; s = substr(s, pos() + 2); for(unsigned i = 0; i < Limit; i++) { if(s == KeyboardScancodeName[i]) return Base + Size * id + i; } return 0; }
static uint16_t decode(const char *name) { string s(name); if(!strbegin(name, "JP")) return 0; ltrim(s, "JP"); unsigned id = strunsigned(s); int pos = strpos(s, "::"); if(pos < 0) return 0; s = substr(s, pos + 2); for(unsigned i = 0; i < Limit; i++) { if(s == JoypadScancodeName[i]) return Base + Size * id + i; } return 0; }
template<> inline string to_string<unsigned int> (unsigned int v) { return strunsigned(v); }
string& string::append(unsigned int value) { append(strunsigned(value)); return *this; }