Beispiel #1
0
 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;
   }
 }
Beispiel #2
0
 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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
template<> inline string to_string<unsigned int> (unsigned int v)  { return strunsigned(v); }
Beispiel #5
0
string& string::append(unsigned int value) { append(strunsigned(value)); return *this; }