コード例 #1
0
ファイル: szarpconfigs.cpp プロジェクト: cyclefusion/szarp
void SzarpConfigs::CreateOneElementGroups(ConfigList* config_groups, ConfigNameHash& titles) {
	for (ConfigNameHash::iterator i = titles.begin(); i != titles.end() ; ++i) {
		const wxString& prefix = i->first;
		ConfigGroup* confgroup = new ConfigGroup;
		confgroup->AppendConfig(prefix, titles[prefix]);
		confgroup->group_name = titles[prefix];
		config_groups->push_back(confgroup);
	}
}
コード例 #2
0
ファイル: szarpconfigs.cpp プロジェクト: cyclefusion/szarp
void SzarpConfigs::CreateGroups(ConfigList* result, MPW& prefix_map, ConfigNameHash &titles) {
	for (MPW::iterator i = prefix_map.begin(); i != prefix_map.end(); ++i) {
		const set<wxString>& prefixes = i->first;
		set<wxString, NoCaseCmp>& words = i->second;
		if (prefixes.size() <= 1) 
			continue;

		set<wxString>::iterator j;
		wxString title;
		for (j = prefixes.begin(); j != prefixes.end(); j++)  {
			ConfigNameHash::iterator k  = titles.find(*j);
			if (k != titles.end()) {
				title = k->second;
				break;
			}
		}

		if (j == prefixes.end())
			continue;

		ConfigGroup* confgroup = new ConfigGroup;
		wxString& group_name = confgroup->group_name;
			
		wxStringTokenizer tknz(title, 
					_T(" \t\r\n"), 
					wxTOKEN_STRTOK);
		while (tknz.HasMoreTokens()) {
			wxString token = tknz.GetNextToken();
			if (words.find(token) != words.end()) 
				group_name += token + _T(" ");
		}

		int prefix_count = 0;
		for (set<wxString>::iterator k = prefixes.begin(); k != prefixes.end(); k++) {
			ConfigNameHash::iterator l = titles.find(*k);
			if (l == titles.end())
				continue;
			prefix_count++;
			confgroup->AppendConfig(*k, l->second);
		}

		if (prefix_count <= 1) {
			delete confgroup;
			continue;
		}

		result->push_back(confgroup);
		for (set<wxString>::iterator k = prefixes.begin(); k != prefixes.end(); k++)  {
			titles.erase(*k);
		}
	}
}