Mercurial > thymian
diff common/strfy.h @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/strfy.h Tue Aug 17 11:19:54 2021 +0200 @@ -0,0 +1,32 @@ +#ifndef STRFY_H +#define STRFY_H + +#include <QString> +#include <string> +#include <vector> +#include <map> + +inline QString std2q(const std::string & s) +{ + return QString::fromStdString(s); +} + +inline std::string q2std(const QString& a) +{ + return a.toStdString(); +} + +inline QString sanitize_hostname(QString hn) +{ + std::vector<std::pair<QString, QString>> replacements{ + { "-", "_" } + }; + + for (auto const &r : replacements) { + hn.replace(r.first, r.second); + } + + return hn; +} + +#endif // STRFY_H
