Revert "Use uniform initializer syntax everywhere"
This reverts commit 49b41704e0
.
This commit is contained in:
parent
49b41704e0
commit
f463a6c794
|
@ -26,9 +26,9 @@ using namespace std;
|
||||||
|
|
||||||
vector<string> split(const string &in)
|
vector<string> split(const string &in)
|
||||||
{
|
{
|
||||||
istringstream stream{in};
|
istringstream stream(in);
|
||||||
vector<string> parts{};
|
vector<string> parts;
|
||||||
string part{};
|
string part;
|
||||||
while (getline(stream, part, '.')) {
|
while (getline(stream, part, '.')) {
|
||||||
parts.push_back(part);
|
parts.push_back(part);
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,11 @@ public:
|
||||||
// If the entry is present, it is moved to the head of the queue.
|
// If the entry is present, it is moved to the head of the queue.
|
||||||
optional<const string> get(const string &key)
|
optional<const string> get(const string &key)
|
||||||
{
|
{
|
||||||
auto location{map.find(key)};
|
auto location = map.find(key);
|
||||||
if (location == map.end())
|
if (location == map.end())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto val{*(location->second)};
|
auto val = *(location->second);
|
||||||
queue.erase(location->second);
|
queue.erase(location->second);
|
||||||
queue.push_front(val);
|
queue.push_front(val);
|
||||||
//cout << "get push " << val.second << endl;
|
//cout << "get push " << val.second << endl;
|
||||||
|
@ -71,12 +71,12 @@ public:
|
||||||
// recently used entry.
|
// recently used entry.
|
||||||
void put(const string &key, const string &value)
|
void put(const string &key, const string &value)
|
||||||
{
|
{
|
||||||
auto location{map.find(key)};
|
auto location = map.find(key);
|
||||||
if (location != map.end())
|
if (location != map.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (queue.size() == size) {
|
if (queue.size() == size) {
|
||||||
auto last{queue.back()};
|
auto last = queue.back();
|
||||||
//cout << "put pop " << last.second << endl;
|
//cout << "put pop " << last.second << endl;
|
||||||
queue.pop_back();
|
queue.pop_back();
|
||||||
map.erase(last.first);
|
map.erase(last.first);
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
web::http::client::http_client client{"https://zuul.opendev.org"};
|
web::http::client::http_client client("https://zuul.opendev.org");
|
||||||
|
|
||||||
string hostname;
|
string hostname;
|
||||||
Cache cache{2};
|
Cache cache{2};
|
||||||
|
@ -104,20 +104,20 @@ int main(int, char**)
|
||||||
// site.688b70499b9a41a08f498ed6e932960c.openstack
|
// site.688b70499b9a41a08f498ed6e932960c.openstack
|
||||||
// site.dbefc23dcc594577a8bfa4db4f9b0a8f.openstack
|
// site.dbefc23dcc594577a8bfa4db4f9b0a8f.openstack
|
||||||
|
|
||||||
auto val{cache.get(hostname)};
|
auto val = cache.get(hostname);
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
cout << val.value() << endl;
|
cout << val.value() << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parts{split(hostname)};
|
auto parts = split(hostname);
|
||||||
if (parts.size() < 3) {
|
if (parts.size() < 3) {
|
||||||
cout << "not enough args" << endl;
|
cout << "not enough args" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto artifact{parts[0]};
|
auto artifact = parts[0];
|
||||||
auto buildid{parts[1]};
|
auto buildid = parts[1];
|
||||||
auto tenant{parts[2]};
|
auto tenant = parts[2];
|
||||||
/*
|
/*
|
||||||
cout << artifact << endl
|
cout << artifact << endl
|
||||||
<< buildid << endl
|
<< buildid << endl
|
||||||
|
@ -126,13 +126,13 @@ int main(int, char**)
|
||||||
|
|
||||||
// 75031cad206c4014ad7a3387091d15ab
|
// 75031cad206c4014ad7a3387091d15ab
|
||||||
try {
|
try {
|
||||||
web::uri_builder uri{"/api/tenant/" + tenant + "/build"};
|
auto uri = web::uri_builder("/api/tenant/" + tenant + "/build");
|
||||||
uri.append_path(buildid);
|
uri.append_path(buildid);
|
||||||
auto response{client.request(
|
auto response = client.request(
|
||||||
web::http::methods::GET, uri.to_string()).get()};
|
web::http::methods::GET, uri.to_string()).get();
|
||||||
// body is a web::json::value
|
// body is a web::json::value
|
||||||
// cout << response.status_code() << endl;
|
// cout << response.status_code() << endl;
|
||||||
auto body{response.extract_json().get()};
|
auto body = response.extract_json().get();
|
||||||
//cout << body.serialize() << endl;
|
//cout << body.serialize() << endl;
|
||||||
|
|
||||||
// TODO: use artifact
|
// TODO: use artifact
|
||||||
|
|
Loading…
Reference in New Issue