summaryrefslogtreecommitdiffstats
blob: b9a394e02b42845d4f08487ed95bcdcf64752dbd (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
/*
 * Copyright (c) 2018 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <string>
#include <vector>

#include <boost/optional.hpp>

#include <Swiften/Base/API.h>
#include <Swiften/Elements/Payload.h>

namespace Swift {
    /**
     * reference from XEP-0372
     */
    class SWIFTEN_API ReferencePayload : public Payload {

    public:

        typedef std::shared_ptr<ReferencePayload> ref;

        enum class Type {
            Data,
            Mention,
            PubSub,
            Unknown
        };

        ReferencePayload();

        const Type& getType() const;
        const boost::optional<std::string>& getUri() const;
        const boost::optional<std::string>& getBegin() const;
        const boost::optional<std::string>& getEnd() const;
        const boost::optional<std::string>& getAnchor() const;

        const std::vector<std::shared_ptr<Payload>>& getPayloads() const;

        void setType(const Type& type);
        void setUri(const boost::optional<std::string>& uri);
        void setBegin(const boost::optional<std::string>& begin);
        void setEnd(const boost::optional<std::string>& end);
        void setAnchor(const boost::optional<std::string>& anchor);

        void addPayload(const std::shared_ptr<Payload>& payload);

    private:

        Type type_;
        boost::optional<std::string> uri_;
        boost::optional<std::string> begin_;
        boost::optional<std::string> end_;
        boost::optional<std::string> anchor_;

        std::vector<std::shared_ptr<Payload>> payloads_;
    };
}