#pragma once

namespace xtr::mfc {

static constexpr auto noItems = -1;

CString ToMFC(std::string_view str);
CString ToMFC(std::u8string_view str);
std::string ToSTL(CString str);
std::u8string ToUTF8(CString str);

CString LoadSID(uint32_t sid);

template<typename ...Args>
CString FormatSID(uint32_t sid, Args ...args) {
  // Note: this requirement is imposed by MFC FormatMessgeW
  // vararg functions are breaking static typing and using opType punning

  auto result = LoadSID(sid);
  result.FormatMessageW(sid, args...);
  return result;
}

std::optional<CFileStatus> FileStatus(const CFile& file);

// Parameters for bracket search
struct BracketSearchParams {
  wchar_t openBracket{ '(' };
  wchar_t closeBracket{ ')' };
  int initialPosition{ 0 };
};

// Backet searchers
std::optional<int> FindBracketBlockStart(CString inputText, const BracketSearchParams& searchParams);
std::optional<int> FindBracketBlockEnd(CString inputText, const BracketSearchParams& searchParams);
std::optional<int> FindOpeningParanthesis(CString text, int startPos = 0);
std::optional<int> FindClosingParanthesis(CString text, int startPos = 0);

CString FirstWordOf(CString str);

} // namespace xtr::mfc