-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67cc51f
commit 6163de3
Showing
16 changed files
with
110 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "json_parser_adapter.h" | ||
|
||
#include "chromium_json_adapter.h" | ||
|
||
#include <base/json/json_reader.h> | ||
|
||
using Self = ipfs::JsonParserAdapter; | ||
|
||
auto Self::Parse(std::string_view j_str) -> std::unique_ptr<ipfs::DagJsonValue> { | ||
auto d = base::JSONReader::Read(j_str, base::JSON_ALLOW_TRAILING_COMMAS); | ||
if (d) { | ||
return std::make_unique<ChromiumJsonAdapter>(std::move(d.value())); | ||
} | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef IPFS_CHROMIUM_CBOR_PARSER_H | ||
#define IPFS_CHROMIUM_CBOR_PARSER_H | ||
|
||
#include <vocab/byte_view.h> | ||
|
||
#include <memory> | ||
|
||
namespace ipfs { | ||
class DagCborValue; | ||
} | ||
|
||
namespace ipfs::ctx { | ||
class CborParser { | ||
public: | ||
virtual std::unique_ptr<DagCborValue> Parse(ByteView) = 0; | ||
virtual ~CborParser() noexcept {} | ||
}; | ||
} // namespace ipfs::ctx | ||
|
||
#endif // IPFS_CHROMIUM_CBOR_PARSER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef IPFS_CHROMIUM_NLOHMANN_CBOR_PARSER_H | ||
#define IPFS_CHROMIUM_NLOHMANN_CBOR_PARSER_H | ||
|
||
#include "cbor_parser.h" | ||
|
||
#include <ipfs_client/json_cbor_adapter.h> | ||
|
||
#if HAS_JSON_CBOR_ADAPTER | ||
|
||
namespace ipfs::ctx { | ||
class NlohmannCborParser final : public CborParser { | ||
public: | ||
std::unique_ptr<DagCborValue> Parse(ByteView) override; | ||
~NlohmannCborParser() noexcept override {} | ||
}; | ||
} // namespace ipfs::ctx | ||
|
||
#endif // HAS_CBOR_CBOR_ADAPTER | ||
#endif // IPFS_CHROMIUM_NLOHMANN_CBOR_PARSER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <ipfs_client/ctx/nlohmann_cbor_parser.h> | ||
|
||
#if HAS_JSON_CBOR_ADAPTER | ||
|
||
using Self = ipfs::ctx::NlohmannCborParser; | ||
|
||
auto Self::Parse(ipfs::ByteView bytes) -> std::unique_ptr<DagCborValue> { | ||
auto data = nlohmann::json::from_cbor( | ||
bytes, false, true, nlohmann::detail::cbor_tag_handler_t::store); | ||
return std::make_unique<ipfs::JsonCborAdapter>(data); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
test_data/blocks/QmVJGicxaTtjxhyKXu67x9ids6qsxVKJUP3QVPxNH9dUfZ
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
test_data/blocks/QmVKjXjtZq8si4b96DAsfZrKxjSt9mjwM8saGwLAb995bk
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
test_data/blocks/bafkreibff4imqnqq5pfbubm4boxievplul4vxzgr266pvcoxesfifwprce
This file was deleted.
Oops, something went wrong.