For source_package_publishing_history::getBuilds(), use an std::generator instead of an std::vector
This commit is contained in:
parent
ea548faaf5
commit
6bcc090407
@ -51,13 +51,12 @@ void source_package_publishing_history::parse_json(const std::string& json_data)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<build> source_package_publishing_history::getBuilds() const {
|
||||
std::vector<build> builds;
|
||||
if (self_link.empty()) { return builds; }
|
||||
std::generator<build> source_package_publishing_history::getBuilds() const {
|
||||
if (self_link.empty()) { co_return; }
|
||||
|
||||
std::map<std::string, std::string> params = {{"ws.op", "getBuilds"}};
|
||||
auto response = lp->api_get(self_link, params);
|
||||
if (!response.has_value()) { return builds; }
|
||||
if (!response.has_value()) { co_return; }
|
||||
|
||||
try {
|
||||
auto data = nlohmann::json::parse(response.value());
|
||||
@ -66,14 +65,12 @@ std::vector<build> source_package_publishing_history::getBuilds() const {
|
||||
auto b_opt = build::parse(entry.dump());
|
||||
if(!b_opt.has_value()) continue;
|
||||
b_opt->set_lp(lp);
|
||||
builds.push_back(b_opt.value());
|
||||
co_yield b_opt.value();
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error parsing builds: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return builds;
|
||||
}
|
||||
|
||||
void source_package_publishing_history::set_lp(launchpad* lp_ptr) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <generator>
|
||||
#include "build.h"
|
||||
|
||||
class launchpad;
|
||||
@ -40,7 +40,7 @@ public:
|
||||
static std::optional<source_package_publishing_history> parse(const std::string& json_data);
|
||||
void parse_json(const std::string& json_data);
|
||||
|
||||
std::vector<build> getBuilds() const;
|
||||
std::generator<build> getBuilds() const;
|
||||
|
||||
std::string self_link;
|
||||
std::string source_package_name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user