bool Satori::FindEventTalk(string& ioevent) { static strmap replace_map; static bool isinit=false; if ( !isinit ) { replace_map["OnBoot"]="起動"; replace_map["OnClose"]="終了"; replace_map["OnFirstBoot"]="初回"; replace_map["OnGhostChanged"]="他のゴーストから変更"; replace_map["OnGhostChanging"]="他のゴーストへ変更"; //replace_map["OnMouseDoubleClick"]="OnTalk"; replace_map["初回"]="OnBoot"; replace_map["他のゴーストから変更"]="OnBoot"; replace_map["他のゴーストへ変更"]="OnClose"; replace_map["OnVanishSelecting"]="消滅指示"; replace_map["OnVanishCancel"]="消滅撤回"; replace_map["OnVanishSelected"]="消滅決定"; replace_map["OnVanishButtonHold"]="消滅中断"; replace_map["OnTalk"]=""; //replace_map[""]=""; isinit = true; } while (true) { if ( talks.is_exist(ioevent) ) return true; // イベントが存在、それに決定 if ( replace_map.find(ioevent) == replace_map.end() ) return false; // 置き換え対象がもう無い sender << "event replaced " << ioevent << " → " << replace_map[ioevent] << endl; ioevent = replace_map[ioevent]; } }
strmap form::validate(const strmap& values) const { strmap valid_values; // filter posted values for valid names std::vector<form_base::ptr>::const_iterator i = _children.begin(); for (; i!=_children.end(); i++) { string n = (*i)->name(); strmap::const_iterator v; if ((v = values.find(n)) != values.end()) { valid_values[n] = v->second; } else if ((*i)->type() == t_checkbox) { // possibly add names that weren't posted (checkboxes) valid_values[n] = ""; } } // validate valid names against validators specified by json text return valid_values; }
void fillAndPrint(strmap &coll) { coll["Deutschl"] = "Germany" ; coll["deutsch"] = "German" ; coll["Haken"] = "snag" ; coll["arbeiten"] = "work" ; coll["hund"] = "dog" ; coll["gehen"] = "go" ; coll["Unternehmen"] = "enter" ; coll["unternehmen"] = "under" ; coll["gehen"] = "walk" ; coll["estar"] = "undertaker" ; strmap::iterator pos ; for (pos = coll.begin();pos != coll.end(); ++pos) { cout << pos->first.c_str() << " " << pos->second << endl ; } cout << endl ; }
string replace_by_char(string const & text, strmap const & list) { auto result = string(); auto keys = mapkeys(list); auto i = size_t(0); while(i < text.length()) { auto it = subfind(text, keys, i); if(it != keys.end()) { auto mapit = list.find(*it); result += mapit->second; i += mapit->first.length(); } else { result += text[i]; i++; } } return result; }