ipfs-chromium
chromium_cbor_adapter.h
1 #ifndef IPFS_CHROMIUM_CBOR_ADAPTER_H_
2 #define IPFS_CHROMIUM_CBOR_ADAPTER_H_
3 
4 #include <components/cbor/values.h>
5 
6 #include <ipfs_client/ctx/cbor_parser.h>
7 #include <ipfs_client/dag_cbor_value.h>
8 
9 namespace ipfs {
12 class ChromiumCborAdapter final : public DagCborValue, public ctx::CborParser {
13  cbor::Value cbor_;
14 
15  std::unique_ptr<DagCborValue> at(std::string_view) const override;
16  std::optional<std::uint64_t> as_unsigned() const override;
17  std::optional<std::int64_t> as_signed() const override;
18  std::optional<double> as_float() const override;
19  std::optional<std::string> as_string() const override;
20  std::optional<std::vector<std::uint8_t>> as_bytes() const override;
21  std::optional<Cid> as_link() const override;
22  std::optional<bool> as_bool() const override;
23  bool is_map() const override;
24  bool is_array() const override;
25  void iterate_map(MapElementCallback) const override;
26  void iterate_array(ArrayElementCallback) const override;
27 
28  public:
29  explicit ChromiumCborAdapter();
30  ChromiumCborAdapter(cbor::Value&&);
31  ChromiumCborAdapter(cbor::Value const&);
33  ~ChromiumCborAdapter() noexcept override;
34 
35  std::unique_ptr<DagCborValue> Parse(ByteView) override;
36 };
37 } // namespace ipfs
38 
39 #endif // IPFS_CHROMIUM_CBOR_ADAPTER_H_
Definition: chromium_cbor_adapter.h:12
Definition: dag_cbor_value.h:15
Definition: cbor_parser.h:15