Exemple #1
0
Parser::cps_key Parser::get_decomposition_mapping (const Item & item) {

	auto & str=item.Get();
	
	if (
		(str.size()==0) ||
		(str[0]=='<')
	) return cps.Add();
	
	auto dcm=item.CodePoints();
	if (!dcm) throw std::runtime_error("Bad decomposition mapping in UnicodeData.txt");
	
	return cps.Add(std::move(*dcm));

}
Exemple #2
0
static std::optional<CodePoint::Type> get_simple_case_mapping (const Item & i) {

	auto mapping=i.CodePoints();
	
	if (!mapping) bad_case_mapping();
	
	switch (mapping->size()) {
	
		case 0:
			return std::optional<CodePoint::Type>{};
		case 1:
			return (*mapping)[0];
		default:
			bad_case_mapping();
	
	}

}
Exemple #3
0
void CasingParser::get_folding (Entry & entry, const Item & item, bool turkic) {

	//	Get the code points
	auto mapping=item.CodePoints();
	
	if (!mapping) throw std::runtime_error("Expected code points");
	
	if (turkic) {
	
		auto mapping_key=cps.Add(std::move(*mapping));
		casings.Add(
			entry.Folding,
			Casing{
				get_tr(),
				mapping_key
			}
		);
		casings.Add(
			entry.Folding,
			Casing{
				get_az(),
				mapping_key
			}
		);
	
	} else {
	
		add_casing(
			entry.Folding,
			std::optional<conds_key>{},
			std::move(*mapping)
		);
	
	}

}