Mercurial > hg > piper-cpp
comparison json/VampJson.h @ 56:815e94fedc1c
Introduce ListResponse type as well
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 19 Sep 2016 14:10:19 +0100 |
parents | 38780f15ac8d |
children | 7aec704705c7 |
comparison
equal
deleted
inserted
replaced
55:38780f15ac8d | 56:815e94fedc1c |
---|---|
925 return json11::Json(jo); | 925 return json11::Json(jo); |
926 } | 926 } |
927 | 927 |
928 static json11::Json | 928 static json11::Json |
929 fromVampResponse_List(std::string errorText, | 929 fromVampResponse_List(std::string errorText, |
930 const std::vector<Vamp::HostExt::PluginStaticData> &d) { | 930 const Vamp::HostExt::ListResponse &resp) { |
931 | 931 |
932 json11::Json::object jo; | 932 json11::Json::object jo; |
933 jo["type"] = "list"; | 933 jo["type"] = "list"; |
934 jo["success"] = (errorText == ""); | 934 jo["success"] = (errorText == ""); |
935 jo["errorText"] = errorText; | 935 jo["errorText"] = errorText; |
936 | 936 |
937 json11::Json::array arr; | 937 json11::Json::array arr; |
938 for (const auto &a: d) { | 938 for (const auto &a: resp.pluginData) { |
939 arr.push_back(fromPluginStaticData(a)); | 939 arr.push_back(fromPluginStaticData(a)); |
940 } | 940 } |
941 json11::Json::object po; | 941 json11::Json::object po; |
942 po["plugins"] = arr; | 942 po["plugins"] = arr; |
943 | 943 |
1117 toVampRequest_List(json11::Json j) { | 1117 toVampRequest_List(json11::Json j) { |
1118 | 1118 |
1119 checkTypeField(j, "list"); | 1119 checkTypeField(j, "list"); |
1120 } | 1120 } |
1121 | 1121 |
1122 static std::vector<Vamp::HostExt::PluginStaticData> | 1122 static Vamp::HostExt::ListResponse |
1123 toVampResponse_List(json11::Json j) { | 1123 toVampResponse_List(json11::Json j) { |
1124 | 1124 |
1125 std::vector<Vamp::HostExt::PluginStaticData> arr; | 1125 Vamp::HostExt::ListResponse resp; |
1126 if (successful(j)) { | 1126 if (successful(j)) { |
1127 for (const auto &a: j["content"]["plugins"].array_items()) { | 1127 for (const auto &a: j["content"]["plugins"].array_items()) { |
1128 arr.push_back(toPluginStaticData(a)); | 1128 resp.pluginData.push_back(toPluginStaticData(a)); |
1129 } | 1129 } |
1130 } | 1130 } |
1131 return arr; | 1131 return resp; |
1132 } | 1132 } |
1133 | 1133 |
1134 static Vamp::HostExt::LoadRequest | 1134 static Vamp::HostExt::LoadRequest |
1135 toVampRequest_Load(json11::Json j) { | 1135 toVampRequest_Load(json11::Json j) { |
1136 | 1136 |