File: SchemaImpl.hpp

package info (click to toggle)
reflect-cpp 0.21.0%2Bds-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,140 kB
  • sloc: cpp: 50,336; python: 139; makefile: 29; sh: 3
file content (44 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (2)
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
#ifndef RFL_CAPNPROTO_SCHEMAIMPL_HPP_
#define RFL_CAPNPROTO_SCHEMAIMPL_HPP_

#include <capnp/schema-parser.h>

#include <memory>
#include <string>

#include "../Box.hpp"
#include "../Result.hpp"

namespace rfl::capnproto {

class SchemaImpl {
 public:
  SchemaImpl(const std::string& _str);

  ~SchemaImpl() = default;

  /// The JSON string used to create this schema.
  const std::string& str() const { return str_; }

  /// The interface used to create new values.
  const capnp::ParsedSchema& value() const { return *schema_; };

 private:
  static capnp::ParsedSchema make_schema(const std::string& _str,
                                         capnp::SchemaParser* _parser);

 private:
  /// The string used to create the schema.
  std::string str_;

  /// The schema parser - we need to hold onto this during the lifetime of the
  /// schema.
  Box<capnp::SchemaParser> schema_parser_;

  /// The actual schema
  Box<capnp::ParsedSchema> schema_;
};

}  // namespace rfl::capnproto

#endif