more advanced parsing

This commit is contained in:
2025-06-10 22:43:44 +03:00
parent 9da589839c
commit c9f447009b
9 changed files with 149 additions and 50 deletions

View File

@@ -75,7 +75,7 @@ std::string get_application_home_path() {
std::map<std::string, std::string> get_params_from_string(std::string parametersString) {
parametersString = boost::regex_replace(parametersString, boost::regex("%26"), "&");
parametersString = boost::regex_replace(parametersString, boost::regex("%3D"), "=");
parametersString = boost::regex_replace(parametersString, boost::regex("%3[Dd]"), "=");
std::vector<std::string> parameters = split(parametersString, "&");
@@ -352,15 +352,13 @@ void generate_qr_code(std::string data) {
#endif // ifdef BUILD_OFD_BINARYEYE_SCAN
#ifdef BUILD_EMAIL_MODE
std::vector<std::string> read_file(std::string path) {
std::ifstream stream(path);
std::vector<std::string> lines;
std::string buffer;
while(getline(stream, buffer)) {
lines.push_back(buffer);
}
stream.close();
return lines;
std::string read_file(std::string &path) {
std::ifstream ifile(path, std::ios::in | std::ios::binary);
const unsigned int size = std::filesystem::file_size(path);
std::string content(size, '\0');
ifile.read(content.data(), size);
ifile.close();
return content;
}
#endif // ifdef BUILD_EMAIL_MODE

View File

@@ -50,6 +50,6 @@ std::string get_local_ip_address();
void fetch_and_download_modules();
#ifdef BUILD_EMAIL_MODE
std::vector<std::string> read_file(std::string path);
std::string read_file(std::string &path);
#endif
#endif // UTILS_H