/* $ 01.09.2000 SVS + Новый метод, для получения параметров для .Options .Options <KeyName>=<Value> */ int GetOptionsParam(api::File& SrcFile,const wchar_t *KeyName,string &strValue, UINT nCodePage) { int Length=StrLength(L".Options"); auto CurFilePos = SrcFile.GetPointer(); string ReadStr; GetFileString GetStr(SrcFile, nCodePage); while (GetStr.GetString(ReadStr)) { if (!StrCmpNI(ReadStr.data(), L".Options", Length)) { string strFullParamName = ReadStr.substr(Length); RemoveExternalSpaces(strFullParamName); size_t pos = strFullParamName.rfind(L'='); if (pos != string::npos) { strValue = strFullParamName; strValue.erase(0, pos+1); RemoveExternalSpaces(strValue); strFullParamName.resize(pos); RemoveExternalSpaces(strFullParamName); if (!StrCmpI(strFullParamName.data(),KeyName)) { SrcFile.SetPointer(CurFilePos, nullptr, FILE_BEGIN); return TRUE; } } } } SrcFile.SetPointer(CurFilePos, nullptr, FILE_BEGIN); return FALSE; }
int GetLangParam(api::File& LangFile,const string& ParamName,string *strParam1, string *strParam2, UINT nCodePage) { string strFullParamName = L"."; strFullParamName += ParamName; int Length=(int)strFullParamName.size(); /* $ 29.11.2001 DJ не поганим позицию в файле; дальше @Contents не читаем */ BOOL Found = FALSE; auto OldPos = LangFile.GetPointer(); string ReadStr; GetFileString GetStr(LangFile, nCodePage); while (GetStr.GetString(ReadStr)) { if (!StrCmpNI(ReadStr.data(), strFullParamName.data(), Length)) { size_t Pos = ReadStr.find(L'='); if (Pos != string::npos) { *strParam1 = ReadStr.substr(Pos + 1); if (strParam2) strParam2->clear(); size_t pos = strParam1->find(L','); if (pos != string::npos) { if (strParam2) { *strParam2 = *strParam1; strParam2->erase(0, pos+1); RemoveTrailingSpaces(*strParam2); } strParam1->resize(pos); } RemoveTrailingSpaces(*strParam1); Found = TRUE; break; } } else if (!StrCmpNI(ReadStr.data(), L"@Contents", 9)) break; } LangFile.SetPointer(OldPos, nullptr, FILE_BEGIN); return Found; }