MCPcopy Create free account
hub / github.com/comaps/comaps / ForEach

Method ForEach

libs/i18n/string_utf8_multilang.hpp:90–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 // Calls |fn| for each pair of |lang| and |utf8s| stored in this multilang string.
89 template <typename Fn>
90 void ForEach(Fn && fn) const
91 {
92 size_t i = 0;
93 size_t const sz = m_s.size();
94 base::ControlFlowWrapper<Fn> wrapper(std::forward<Fn>(fn));
95 while (i < sz)
96 {
97 size_t const next = GetNextIndex(i);
98 localisation::LanguageIndex const languageIndex = m_s[i] & kLangCodeMask;
99 if (localisation::ConvertLanguageIndexToLanguageCode(languageIndex) != localisation::kReservedLanguageCode &&
100 wrapper(languageIndex, std::string_view(m_s).substr(i + 1, next - i - 1)) == base::ControlFlow::Break)
101 {
102 break;
103 }
104 i = next;
105 }
106 }
107
108 /*
109 /// Used for ordered languages, if you want to do something with priority of that order.

Callers 2

DebugPrintFunction · 0.45
UNIT_TESTFunction · 0.45

Calls 3

wrapperFunction · 0.50
sizeMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36