Example #1
0
static std::string repeat(std::string str, size_t n)
{
	if(n == 0)
	{
		str.clear();
		str.shrink_to_fit();
		return str;
	}
	else if(n == 1 || str.empty())
	{
		return str;
	}

	auto period = str.size();
	if(period == 1)
	{
		str.append(n - 1, str.front());
		return str;
	}

	str.reserve(period * n);
	size_t m = 2;
	for(; m < n; m *= 2)
		str += str;

	str.append(str.c_str(), (n - (m / 2)) * period);

	return str;
}
 bool ShowAndGetNewPassword(
       std::string&            strNewPassword,
       unsigned int            autoCloseMs)
 {
   strNewPassword.resize(1024);
   unsigned int size = (unsigned int)strNewPassword.capacity();
   bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetNewPassword(strNewPassword[0], size, autoCloseMs);
   strNewPassword.resize(size);
   strNewPassword.shrink_to_fit();
   return ret;
 }
 bool ShowAndGetInput(
       std::string&            strText,
       bool                    allowEmptyResult,
       unsigned int            autoCloseMs)
 {
   strText.resize(1024);
   unsigned int size = (unsigned int)strText.capacity();
   bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetInput(strText[0], size, allowEmptyResult, autoCloseMs);
   strText.resize(size);
   strText.shrink_to_fit();
   return ret;
 }
 bool ShowAndGetFilter(
       std::string&            strText,
       bool                    searching,
       unsigned int            autoCloseMs)
 {
   strText.resize(1024);
   unsigned int size = (unsigned int)strText.capacity();
   bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetFilter(strText[0], size, searching, autoCloseMs);
   strText.resize(size);
   strText.shrink_to_fit();
   return ret;
 }
 bool ShowAndVerifyNewPassword(
       std::string&            strNewPassword,
       const std::string&      strHeading,
       bool                    allowEmptyResult,
       unsigned int            autoCloseMs)
 {
   strNewPassword.resize(1024);
   unsigned int size = (unsigned int)strNewPassword.capacity();
   bool ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndGetNewPasswordWithHead(strNewPassword[0], size, strHeading.c_str(), allowEmptyResult, autoCloseMs);
   strNewPassword.resize(size);
   strNewPassword.shrink_to_fit();
   return ret;
 }
 int ShowAndVerifyPassword(
       std::string&            strPassword,
       const std::string&      strHeading,
       int                     iRetries,
       unsigned int            autoCloseMs)
 {
   strPassword.resize(1024);
   unsigned int size = (unsigned int)strPassword.capacity();
   int ret = g_interProcess.m_Callbacks->GUI.Dialogs.Keyboard.ShowAndVerifyPassword(strPassword[0], size, strHeading.c_str(), iRetries, autoCloseMs);
   strPassword.resize(size);
   strPassword.shrink_to_fit();
   return ret;
 }