summaryrefslogtreecommitdiffstats
path: root/src/Util.cpp
blob: 78dd8d2399e2782bc7f2093a3702d73a09367b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Util.hpp"

namespace Util {
    QString trimQuotes(QString string, bool& trimmed)
    {
        if(string.isEmpty()) return string;

        trimmed = false;
        if(string.length() >= 2 && string.at(0) == '"' && string.at(string.length() - 1) == '"')
        {
            string.remove(0, 1);
            string.remove(string.length() - 1, 1);
            trimmed = true;
        }
        return string;
    }

    QString& trimQuotes(const QString& string, bool& trimmed)
    {
        return trimQuotes(QString(string), trimmed);
    }
}