Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
225 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TURL_H__
20
#define __TURL_H__
21
 
22
#include <string>
23
 
24
class TUrl
25
{
26
    public:
27
        TUrl();
28
        TUrl(const std::string& url);
29
        ~TUrl();
30
 
31
        bool setUrl(const std::string& url);
32
        std::string& getUrl() { return mUrl; }
33
 
34
        std::string getProtocol() { return mProtocol; } // The protocol of the URL (https, sftp, ...)
35
        std::string getUser() { return mUser; }         // The user name, if any
36
        std::string getPassword() { return mPassword; } // The password, if any --> should not be set in a URL for security reasons!
37
        std::string getDomain() { return mDomain; }     // The host name; either a FQDN name or an IP address.
38
        int getPort() { return mPort; }                 // The port number; If no port number was set it depends on the protocol.
39
        std::string getPath() { return mPath; }         // The path of the URL.
40
        std::string getQuery() { return mQuery; }       // The query part appended to the path, if any
41
 
42
    protected:
43
        bool parse();
44
        std::string _trim(const std::string& str);
45
 
46
    private:
47
        std::string mUrl;
48
        std::string mProtocol;
49
        std::string mDomain;
50
        int mPort{0};
51
        std::string mUser;
52
        std::string mPassword;
53
        std::string mPath;
54
        std::string mQuery;
55
};
56
 
57
#endif