#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <algorithm>
#include <vector>

size_t find(const std::string& line, std::vector<std::string> vect, int pos=0) {
	int eol1;
	eol1 = 0;
	for (std::vector<std::string>::iterator iter = vect.begin(); iter != vect.end(); ++iter) {
		//std::cout << *iter << std::endl;
		int eol2 = line.find(*iter, pos);
		if (eol1 == 0 && eol2 > 0)
			eol1 = eol2;
		else if (eol2 > 0 && eol2 < eol1)
			eol1 = eol2;
	}
	return eol1;
}

std::map<std::string, std::string> mappify(std::string const& s, char delim='=') {
	std::map<std::string, std::string> m;

	std::string::size_type key_pos = 0, i, j;
	std::string::size_type key_end;
	std::string::size_type val_pos;
	std::string::size_type lim_pos;
	std::string::size_type val_end;

	while ((key_end = s.find(delim, key_pos)) != std::string::npos) {
		if ((val_pos = s.find_first_not_of(delim, key_end + 1)) == std::string::npos)break;
		while (key_end - 1 > 0 && (s[key_end - 1] <= 32 || s[key_end - 1] == ';'))
			key_end--;
		while (val_pos < s.size() && (s[val_pos] <= 32 || s[val_pos] == ';'))
			val_pos++;
		val_end = s.find('\n', val_pos);
		i = s.find('\"', val_pos);
		if (i != std::string::npos)
			j = s.find('\"', i + 1);
		else
			j = 0;
		lim_pos = find(s.substr(0, i), { " ",";","\t" }, val_pos + 1);
		//std::cout << "s.substr(j):" << s.substr(j)<<std::endl;
		if (lim_pos == 0 && j != std::string::npos)lim_pos = find(s.substr(j), { " ",";","\t" }) + j;
		if (lim_pos < val_pos)lim_pos = val_pos + 1;
		if (j > 0)val_end = j + 1;
		if (val_end > lim_pos)val_end = lim_pos;
		m.emplace(s.substr(key_pos, key_end - key_pos), s.substr(val_pos, val_end - val_pos));
		key_pos = val_end;
		while ((key_pos < s.size() && s[key_pos] <= 32 || s[key_pos] == ';'))
			++key_pos;
		if (val_end == 0)break;
	}
	return m;
}
int main() {
    std::string s ="\
File=\"c:\\dir\\ocean\\\nCCS_test.txt\"\n\
iEcho=10000; iHrShift=0 rho_Co2 = 1.15d0;\n\
Liner=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
  auto m = mappify(s);
    for (auto const& p : m)
      std::cout << '{' << p.first << " :=> " << p.second << '}' << '\n';

	return 0;
}