aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/objects/object2slime.h
blob: ffab739ed15f75577e4ab2295169b4a6548e1d9c (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "objectvisitor.h"
#include <vector>
#include <memory>

namespace vespalib {

namespace slime { struct Cursor; }

/**
 * This is a concrete object visitor that will build up a structured
 * slime representation of an object.
 **/
class Object2Slime : public ObjectVisitor
{
private:
    std::reference_wrapper<slime::Cursor> _cursor;
    std::vector<std::reference_wrapper<slime::Cursor>> _stack;

public:
    Object2Slime(slime::Cursor & cursor);
    ~Object2Slime();

    void openStruct(const vespalib::string &name, const vespalib::string &type) override;
    void closeStruct() override;
    void visitBool(const vespalib::string &name, bool value) override;
    void visitInt(const vespalib::string &name, int64_t value) override;
    void visitFloat(const vespalib::string &name, double value) override;
    void visitString(const vespalib::string &name, const vespalib::string &value) override;
    void visitNull(const vespalib::string &name) override;
    void visitNotImplemented() override;
};

} // namespace vespalib