Mercurial > thymian
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 #ifndef STRFY_H | |
| 2 #define STRFY_H | |
| 3 | |
| 4 #include <QString> | |
| 5 #include <string> | |
| 6 #include <vector> | |
| 7 #include <map> | |
| 8 | |
| 9 inline QString std2q(const std::string & s) | |
| 10 { | |
| 11 return QString::fromStdString(s); | |
| 12 } | |
| 13 | |
| 14 inline std::string q2std(const QString& a) | |
| 15 { | |
| 16 return a.toStdString(); | |
| 17 } | |
| 18 | |
| 19 inline QString sanitize_hostname(QString hn) | |
| 20 { | |
| 21 std::vector<std::pair<QString, QString>> replacements{ | |
| 22 { "-", "_" } | |
| 23 }; | |
| 24 | |
| 25 for (auto const &r : replacements) { | |
| 26 hn.replace(r.first, r.second); | |
| 27 } | |
| 28 | |
| 29 return hn; | |
| 30 } | |
| 31 | |
| 32 #endif // STRFY_H |
