blob: 6be6788045ca7bfa5cdb66b8549cc94592df4fa9 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "route.h"
#include "routeparser.h"
namespace mbus {
Route::Route() = default;
Route::Route(std::vector<Hop> lst) :
_hops(std::move(lst))
{ }
Route::~Route() = default;
Route &
Route::addHop(Hop hop)
{
_hops.emplace_back(std::move(hop));
return *this;
}
Route &
Route::setHop(uint32_t i, Hop hop)
{
_hops[i] = std::move(hop);
return *this;
}
Hop
Route::removeHop(uint32_t i)
{
Hop ret = std::move(_hops[i]);
_hops.erase(_hops.begin() + i);
return ret;
}
string
Route::toString() const {
string ret = "";
for (uint32_t i = 0; i < _hops.size(); ++i) {
ret.append(_hops[i].toString());
if (i < _hops.size() - 1) {
ret.append(" ");
}
}
return ret;
}
string
Route::toDebugString() const {
string ret = "Route(hops = { ";
for (uint32_t i = 0; i < _hops.size(); ++i) {
ret.append(_hops[i].toDebugString());
if (i < _hops.size() - 1) {
ret.append(", ");
}
}
ret.append(" })");
return ret;
}
Route
Route::parse(vespalib::stringref route)
{
return RouteParser::createRoute(route);
}
} // namespace mbus
|