java - How to obtain individual strings returned from GetPrivateProfileSection() -
i use java programming. have basic knowledge of c++. using jni call windows api getprivateprofilesection().
i understand have write c++ function this. vaguely familiar how this. problem face returned c++ string getprivateprofilesection().
from microsoft documentation, understand returned string contains name=value pairs each separated null character. last name=value pair ends 2 null characters.
what want collect individual name=value strings , put them in array. have absolutely no clue how returned string getprivateprofilesection(). have heard need known pointer arithmetics have no knowledge how this.
could me out? thanks!
the code reads ini file std::map looks this:
lptstr str_settings = new tchar[buffersize]; ::getprivateprofilesection(_t("mysection"), str_settings , buffersize, _t("myini.ini")); std::map<std::string, std::string> settings; // map key -> value ini file std::string sett_string; (;*str_settings; str_settings += sett_string.length() + 1) { sett_string = str_settings; size_t pos = sett_string.find('='); std::string key; std::string value; if (pos == std::string::npos) { key = sett_string; } else { key.assign(sett_string.begin(), sett_string.begin() + pos); value.assign(sett_string.begin() + pos + 1, sett_string.end()); } settings[key] = value; }
Comments
Post a Comment