5#include <nlohmann/json.hpp>
6#include <nlohmann/json_fwd.hpp>
10using json = nlohmann::json;
31 for (
const auto& arg_attrs : j[
"arguments"]) {
33 argument.
copy_target = arg_attrs.value(
"copy_target",
"");
34 argument.
copy_buffer = arg_attrs.value(
"copy_buffer",
"");
35 argument.
copy_in = arg_attrs.value(
"copy_in",
false);
36 argument.
copy_out = arg_attrs.value(
"copy_out",
false);
37 argument.
alloc = arg_attrs.value(
"alloc",
false);
38 argument.
free = arg_attrs.value(
"free",
false);
40 if (arg_attrs[
"copy_size"].is_string() && !arg_attrs[
"copy_size"].get<std::string>().empty()) {
51 j[
"arguments"] = json::array();
53 std::string copy_size_str;
54 if (!arg_attrs.copy_size.is_null()) {
56 copy_size_str = printer.apply(arg_attrs.copy_size);
59 nlohmann::json attr_json;
60 attr_json[
"copy_target"] = arg_attrs.copy_target;
61 attr_json[
"copy_buffer"] = arg_attrs.copy_buffer;
62 attr_json[
"copy_in"] = arg_attrs.copy_in;
63 attr_json[
"copy_out"] = arg_attrs.copy_out;
64 attr_json[
"alloc"] = arg_attrs.alloc;
65 attr_json[
"free"] = arg_attrs.free;
66 attr_json[
"copy_size"] = copy_size_str;
68 j[
"arguments"].push_back(attr_json);
Definition json_serializer.h:155
Expression parse(const std::string &expr_str)
Parses a string into a symbolic expression.
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
nlohmann::json json
Definition interstate_edge.h:14
Definition attributes.h:15
bool copy_in
Definition attributes.h:19
bool copy_out
Definition attributes.h:20
bool free
Definition attributes.h:22
sdfg::symbolic::Expression copy_size
Definition attributes.h:18
bool alloc
Definition attributes.h:21
std::string copy_buffer
Definition attributes.h:17
std::string copy_target
Definition attributes.h:16
Definition attributes.h:25
std::vector< ArgumentAttributes > arguments
Definition attributes.h:26
static Attributes from_json(const json &j)
Definition attributes.h:28
json to_json() const
Definition attributes.h:49