summaryrefslogtreecommitdiffstats
blob: a8c9f95b4f07327900c55381490d4465a8c96bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2011-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <map>
#include <string>

#include <Swiften/JID/JID.h>

namespace Swift {
    // TODO: Implement using Base/URI
    class XMPPURI {
        public:
            XMPPURI();

            const JID& getAuthority() const {
                return authority;
            }

            void setAuthority(const JID& j) {
                authority = j;
            }

            const JID& getPath() const {
                return path;
            }

            void setPath(const JID& j) {
                path = j;
            }

            const std::string& getQueryType() const {
                return queryType;
            }

            void setQueryType(const std::string& q) {
                queryType = q;
            }

            const std::map<std::string, std::string>& getQueryParameters() const {
                return queryParameters;
            }

            void addQueryParameter(const std::string& key, const std::string& path) {
                queryParameters[key] = path;
            }

            const std::string& getFragment() const {
                return fragment;
            }

            void setFragment(const std::string& f) {
                fragment = f;
            }

            bool isNull() const {
                return !authority.isValid() && !path.isValid();
            }

            static XMPPURI fromString(const std::string&);

        private:
            JID authority;
            JID path;
            std::string fragment;
            std::string queryType;
            std::map<std::string, std::string> queryParameters;
    };
}