view 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 source
#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