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

#pragma once

#include <memory>
#include <ostream>
#include <string>
#include <vector>

#include <boost/optional.hpp>

namespace Swift {

class Presence;
class BOSHError;

template <typename T>
std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<T>& ptr) {
    if (ptr) {
        stream << *ptr;
    }
    else {
        stream << "nullptr";
    }
    return stream;
}

template <typename T>
std::ostream& operator<<(std::ostream& stream, const std::vector<T>& vec) {
    stream << "[";
    if (!vec.empty()) {
        auto it = std::begin(vec);
        stream << *it;

        ++it;
        for (auto end = std::end(vec); it != end; ++it) {
            stream << ", " << *it;
        }
     }
    stream << "]";
    return stream;
}

std::ostream& operator<<(std::ostream& stream, const Presence& presence);

std::ostream& operator<<(std::ostream& stream, const BOSHError& boshError);

};

::std::ostream& operator<<(::std::ostream& os, const boost::optional<std::string>& optStr);