enum_file_lines::enum_file_lines(const os::fs::file& SrcFile, uintptr_t CodePage) : SrcFile(SrcFile), BeginPos(SrcFile.GetPointer()), m_CodePage(CodePage), m_Eol(m_CodePage) { if (m_CodePage == CP_UNICODE || m_CodePage == CP_REVERSEBOM) m_wReadBuf.resize(ReadBufCount); else m_ReadBuf.resize(ReadBufCount); m_wStr.reserve(DELTA); }
bool GetLangParam(const os::fs::file& LangFile, string_view const ParamName, string& strParam1, string* strParam2, uintptr_t CodePage) { const auto strFullParamName = concat(L'.', ParamName); const auto CurFilePos = LangFile.GetPointer(); SCOPE_EXIT{ LangFile.SetPointer(CurFilePos, nullptr, FILE_BEGIN); }; for (const auto& i: enum_file_lines(LangFile, CodePage)) { if (starts_with_icase(i.Str, strFullParamName)) { const auto EqPos = i.Str.find(L'='); if (EqPos != string::npos) { assign(strParam1, i.Str.substr(EqPos + 1)); if (strParam2) strParam2->clear(); const auto pos = strParam1.find(L','); if (pos != string::npos) { if (strParam2) { *strParam2 = trim_right(strParam1.substr(pos + 1)); } strParam1.resize(pos); } inplace::trim_right(strParam1); return true; } } else if (starts_with(i.Str, L'"')) { // '"' indicates some meaningful string. // Parameters can be only in the header, no point to go deeper return false; } } return false; }