summaryrefslogtreecommitdiffstats
path: root/include/orcus/orcus_json.hpp
blob: 7ec487f7b2967e4b01e08dec9032ebd85c28ad87 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_ORCUS_ORCUS_JSON_HPP
#define INCLUDED_ORCUS_ORCUS_JSON_HPP

#include "env.hpp"
#include "./spreadsheet/types.hpp"

#include <memory>
#include <string_view>

namespace orcus {

namespace spreadsheet { namespace iface {

class import_factory;

}}

class ORCUS_DLLPUBLIC orcus_json
{
    struct impl;
    std::unique_ptr<impl> mp_impl;

public:

    orcus_json(const orcus_json&) = delete;
    orcus_json& operator= (const orcus_json&) = delete;

    orcus_json(spreadsheet::iface::import_factory* im_fact);
    ~orcus_json();

    void set_cell_link(std::string_view path, std::string_view sheet, spreadsheet::row_t row, spreadsheet::col_t col);

    void start_range(
        std::string_view sheet, spreadsheet::row_t row, spreadsheet::col_t col, bool row_header);

    void append_field_link(std::string_view path, std::string_view label);
    void set_range_row_group(std::string_view path);
    void commit_range();

    void append_sheet(std::string_view name);

    void read_stream(std::string_view stream);

    /**
     * Read a JSON string that contains an entire set of mapping rules.
     *
     * This method also inserts all necessary sheets into the document model.
     *
     * @param stream JSON string.
     */
    void read_map_definition(std::string_view stream);

    /**
     * Read a JSON string, and detect and define mapping rules for one or more
     * ranges.
     *
     * @param stream JSON string.
     */
    void detect_map_definition(std::string_view stream);
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */