#include <string>
#include "common.hpp"
#include <iostream>
#include <algorithm>

std::string Replace(std::string source, std::string from, std::string out)
{
	std::string res("");
	size_t start = 0, stop = 0;
	start = source.find(from);
	stop = from.length();
	if (start >= 0)
		res = source.replace(start, stop, out);
	return res;
}
std::string ReplaceAll(std::string str, const std::string &from, const std::string &to)
{
	size_t start_pos = 0;
	while ((start_pos = str.find(from, start_pos)) != std::string::npos)
	{
		str.replace(start_pos, from.length(), to);
		start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
	}
	return str;
}

int NoResponse(std::string mgs)
{
	std::cout << "No response from the server. " + mgs << std::endl;
	return 1;
}
