Browse Source

Use uniform initializer syntax everywhere

changes/91/636791/1
Monty Taylor 3 months ago
parent
commit
49b41704e0
1 changed files with 17 additions and 17 deletions
  1. 17
    17
      zuul-preview/main.cc

+ 17
- 17
zuul-preview/main.cc View File

@@ -26,9 +26,9 @@ using namespace std;
26 26
 
27 27
 vector<string> split(const string &in)
28 28
 {
29
-  istringstream stream(in);
30
-  vector<string> parts;
31
-  string part;
29
+  istringstream stream{in};
30
+  vector<string> parts{};
31
+  string part{};
32 32
   while (getline(stream, part, '.')) {
33 33
     parts.push_back(part);
34 34
   }
@@ -56,11 +56,11 @@ public:
56 56
   // If the entry is present, it is moved to the head of the queue.
57 57
   optional<const string> get(const string &key)
58 58
   {
59
-    auto location = map.find(key);
59
+    auto location{map.find(key)};
60 60
     if (location == map.end())
61 61
       return {};
62 62
 
63
-    auto val = *(location->second);
63
+    auto val{*(location->second)};
64 64
     queue.erase(location->second);
65 65
     queue.push_front(val);
66 66
     //cout << "get push " << val.second << endl;
@@ -71,12 +71,12 @@ public:
71 71
   // recently used entry.
72 72
   void put(const string &key, const string &value)
73 73
   {
74
-    auto location = map.find(key);
74
+    auto location{map.find(key)};
75 75
     if (location != map.end())
76 76
       return;
77 77
 
78 78
     if (queue.size() == size) {
79
-      auto last = queue.back();
79
+      auto last{queue.back()};
80 80
       //cout << "put pop " << last.second << endl;
81 81
       queue.pop_back();
82 82
       map.erase(last.first);
@@ -91,7 +91,7 @@ public:
91 91
 
92 92
 int main(int, char**)
93 93
 {
94
-  web::http::client::http_client client("https://zuul.opendev.org");
94
+  web::http::client::http_client client{"https://zuul.opendev.org"};
95 95
 
96 96
   string hostname;
97 97
   Cache cache{2};
@@ -104,20 +104,20 @@ int main(int, char**)
104 104
     // site.688b70499b9a41a08f498ed6e932960c.openstack
105 105
     // site.dbefc23dcc594577a8bfa4db4f9b0a8f.openstack
106 106
 
107
-    auto val = cache.get(hostname);
107
+    auto val{cache.get(hostname)};
108 108
     if (val.has_value()) {
109 109
       cout << val.value() << endl;
110 110
       continue;
111 111
     }
112 112
 
113
-    auto parts = split(hostname);
113
+    auto parts{split(hostname)};
114 114
     if (parts.size() < 3) {
115 115
       cout << "not enough args" << endl;
116 116
       continue;
117 117
     }
118
-    auto artifact = parts[0];
119
-    auto buildid = parts[1];
120
-    auto tenant = parts[2];
118
+    auto artifact{parts[0]};
119
+    auto buildid{parts[1]};
120
+    auto tenant{parts[2]};
121 121
     /*
122 122
     cout << artifact << endl
123 123
          << buildid << endl
@@ -126,13 +126,13 @@ int main(int, char**)
126 126
 
127 127
      // 75031cad206c4014ad7a3387091d15ab
128 128
     try {
129
-      auto uri = web::uri_builder("/api/tenant/" + tenant + "/build");
129
+      web::uri_builder uri{"/api/tenant/" + tenant + "/build"};
130 130
       uri.append_path(buildid);
131
-      auto response = client.request(
132
-        web::http::methods::GET, uri.to_string()).get();
131
+      auto response{client.request(
132
+        web::http::methods::GET, uri.to_string()).get()};
133 133
       // body is a web::json::value
134 134
       // cout << response.status_code() << endl;
135
-      auto body = response.extract_json().get();
135
+      auto body{response.extract_json().get()};
136 136
       //cout << body.serialize() << endl;
137 137
 
138 138
       // TODO: use artifact

Loading…
Cancel
Save