blob: 4d24b4ce78825a48d2fb1b759f608cbf8247e0f9 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "spantree.h"
#include "spannode.h"
#include <vespa/vespalib/stllike/asciistream.h>
using std::unique_ptr;
using vespalib::stringref;
namespace document {
SpanTree::~SpanTree() = default;
size_t
SpanTree::annotate(Annotation&& annotation_) {
_annotations.push_back(std::move(annotation_));
return _annotations.size() - 1;
}
size_t
SpanTree::annotate(const SpanNode &node, Annotation&& annotation_) {
annotation_.setSpanNode(node);
return annotate(std::move(annotation_));
}
size_t
SpanTree::annotate(const SpanNode &node, const AnnotationType &annotation_type) {
return annotate(node, Annotation(annotation_type));
}
void
SpanTree::accept(SpanTreeVisitor &visitor) const {
_root->accept(visitor);
}
int
SpanTree::compare(const SpanTree &other) const {
return toString().compare(other.toString());
}
vespalib::string
SpanTree::toString() const {
vespalib::asciistream os;
os << "SpanTree(\"" << _name << "\"" << "\n ";
os <<_root->toString();
for (const Annotation & a : _annotations) {
if (a.valid()) {
os << "\n " << a.toString();
}
}
os << ")";
return os.str();
}
} // namespace document
|