basic email parsing
This commit is contained in:
@@ -42,6 +42,7 @@ std::string get_local_ip_address() {
|
||||
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
|
||||
|
||||
std::string value(addressBuffer);
|
||||
//TODO: better way to determine local IP address
|
||||
if (!strncmp(value.c_str(), "192.168", 7)) {
|
||||
return value;
|
||||
}
|
||||
@@ -68,6 +69,26 @@ std::string get_path_relative_to_home(std::string path) {
|
||||
return std::string(std::getenv("HOME")) + "/" + path;
|
||||
}
|
||||
|
||||
std::string get_application_home_path() {
|
||||
return get_path_relative_to_home(".local/share/checks_parser");
|
||||
}
|
||||
|
||||
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"), "=");
|
||||
|
||||
std::vector<std::string> parameters = split(parametersString, "&");
|
||||
|
||||
std::map<std::string, std::string> paramsMap;
|
||||
|
||||
for (auto ¶meter : parameters) {
|
||||
std::vector<std::string> values = split(parameter, "=");
|
||||
paramsMap.insert(std::pair<std::string, std::string> (values[0], values[1]));
|
||||
}
|
||||
return paramsMap;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool vector_contains_element(const std::vector<T>& vector, const T& to_find) {
|
||||
for (const T& element : vector) {
|
||||
|
||||
@@ -11,6 +11,9 @@ std::string to_utf8(std::wstring wide_string);
|
||||
std::wstring from_utf8(std::string string);
|
||||
|
||||
std::string get_path_relative_to_home(std::string path);
|
||||
std::string get_application_home_path();
|
||||
|
||||
std::map<std::string, std::string> get_params_from_string(std::string);
|
||||
|
||||
const std::map<std::string, ColumnType> column_names = {
|
||||
{"date", ColumnType::date},
|
||||
|
||||
Reference in New Issue
Block a user