blob: 0b088bc4ee7ee94b37438c3dbab583521968c5b8 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/annotation/spantreevisitor.h>
#include <map>
#include <cstddef>
namespace vespalib { class nbostream; }
namespace document {
class AlternateSpanList;
class Annotation;
class Span;
class SpanList;
class SimpleSpanList;
struct SpanNode;
class SpanTree;
class AnnotationSerializer : private SpanTreeVisitor {
vespalib::nbostream &_stream;
std::map<const SpanNode *, size_t> _span_node_map;
void visit(const Span &node) override { writeSpan(node); }
void visit(const SpanList &node) override { writeList(node); }
void visit(const SimpleSpanList &node) override { writeList(node); }
void visit(const AlternateSpanList &node) override { writeList(node); }
public:
AnnotationSerializer(vespalib::nbostream &stream);
void write(const SpanTree &tree);
void write(const SpanNode &node);
void write(const Annotation &annotation);
void writeSpan(const Span &node);
void writeList(const SpanList &list);
void writeList(const SimpleSpanList &list);
void writeList(const AlternateSpanList &list);
};
} // namespace document
|