Skip to content

Commit 55922d6

Browse files
committed
Replace BOOST_FOREACH with new C++11 for loops
1 parent 2cf2669 commit 55922d6

File tree

7 files changed

+26
-33
lines changed

7 files changed

+26
-33
lines changed

middle-pgsql.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ using namespace std;
5252
#include <cstring>
5353
#include <ctime>
5454
#include <boost/format.hpp>
55-
#include <boost/foreach.hpp>
5655
#include <boost/unordered_map.hpp>
5756

5857
enum table_id {
@@ -131,7 +130,7 @@ char *pgsql_store_nodes(const idlist_t &nds) {
131130
// Special escape routine for escaping strings in array constants: double quote, backslash,newline, tab*/
132131
inline char *escape_tag( char *ptr, const std::string &in, bool escape )
133132
{
134-
BOOST_FOREACH(const char c, in)
133+
for (const char c: in)
135134
{
136135
switch(c)
137136
{

osmdata.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "middle.hpp"
44
#include "node-ram-cache.hpp"
55

6-
#include <boost/foreach.hpp>
76
#include <boost/thread/thread.hpp>
87
#include <boost/unordered_map.hpp>
98
#include <boost/thread.hpp>
@@ -38,7 +37,7 @@ int osmdata_t::node_add(osmid_t id, double lat, double lon, const taglist_t &tag
3837
ramNode n(lon, lat);
3938

4039
int status = 0;
41-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
40+
for (auto& out: outs) {
4241
status |= out->node_add(id, n.lat(), n.lon(), tags);
4342
}
4443
return status;
@@ -48,7 +47,7 @@ int osmdata_t::way_add(osmid_t id, const idlist_t &nodes, const taglist_t &tags)
4847
mid->ways_set(id, nodes, tags);
4948

5049
int status = 0;
51-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
50+
for (auto& out: outs) {
5251
status |= out->way_add(id, nodes, tags);
5352
}
5453
return status;
@@ -58,7 +57,7 @@ int osmdata_t::relation_add(osmid_t id, const memberlist_t &members, const tagli
5857
mid->relations_set(id, members, tags);
5958

6059
int status = 0;
61-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
60+
for (auto& out: outs) {
6261
status |= out->relation_add(id, members, tags);
6362
}
6463
return status;
@@ -74,7 +73,7 @@ int osmdata_t::node_modify(osmid_t id, double lat, double lon, const taglist_t &
7473
ramNode n(lon, lat);
7574

7675
int status = 0;
77-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
76+
for (auto& out: outs) {
7877
status |= out->node_modify(id, n.lat(), n.lon(), tags);
7978
}
8079

@@ -90,7 +89,7 @@ int osmdata_t::way_modify(osmid_t id, const idlist_t &nodes, const taglist_t &ta
9089
slim->ways_set(id, nodes, tags);
9190

9291
int status = 0;
93-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
92+
for (auto& out: outs) {
9493
status |= out->way_modify(id, nodes, tags);
9594
}
9695

@@ -106,7 +105,7 @@ int osmdata_t::relation_modify(osmid_t id, const memberlist_t &members, const ta
106105
slim->relations_set(id, members, tags);
107106

108107
int status = 0;
109-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
108+
for (auto& out: outs) {
110109
status |= out->relation_modify(id, members, tags);
111110
}
112111

@@ -119,7 +118,7 @@ int osmdata_t::node_delete(osmid_t id) {
119118
slim_middle_t *slim = dynamic_cast<slim_middle_t *>(mid.get());
120119

121120
int status = 0;
122-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
121+
for (auto& out: outs) {
123122
status |= out->node_delete(id);
124123
}
125124

@@ -132,7 +131,7 @@ int osmdata_t::way_delete(osmid_t id) {
132131
slim_middle_t *slim = dynamic_cast<slim_middle_t *>(mid.get());
133132

134133
int status = 0;
135-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
134+
for (auto& out: outs) {
136135
status |= out->way_delete(id);
137136
}
138137

@@ -145,7 +144,7 @@ int osmdata_t::relation_delete(osmid_t id) {
145144
slim_middle_t *slim = dynamic_cast<slim_middle_t *>(mid.get());
146145

147146
int status = 0;
148-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
147+
for (auto& out: outs) {
149148
status |= out->relation_delete(id);
150149
}
151150

@@ -155,7 +154,7 @@ int osmdata_t::relation_delete(osmid_t id) {
155154
}
156155

157156
void osmdata_t::start() {
158-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
157+
for (auto& out: outs) {
159158
out->start();
160159
}
161160
mid->start(outs[0]->get_options());
@@ -213,7 +212,7 @@ struct pending_threaded_processor : public middle_t::pending_processor {
213212

214213
//clone the outs
215214
output_vec_t out_clones;
216-
BOOST_FOREACH(const std::shared_ptr<output_t>& out, outs) {
215+
for (const auto& out: outs) {
217216
out_clones.push_back(out->clone(mid_clone.get()));
218217
}
219218

@@ -261,7 +260,7 @@ struct pending_threaded_processor : public middle_t::pending_processor {
261260

262261
//collect all the new rels that became pending from each
263262
//output in each thread back to their respective main outputs
264-
BOOST_FOREACH(const clone_t& clone, clones) {
263+
for (const auto& clone: clones) {
265264
//for each clone/original output
266265
for(output_vec_t::const_iterator original_output = outs.begin(), clone_output = clone.second.begin();
267266
original_output != outs.end() && clone_output != clone.second.end(); ++original_output, ++clone_output) {
@@ -307,7 +306,7 @@ struct pending_threaded_processor : public middle_t::pending_processor {
307306
ids_done = 0;
308307

309308
//collect all expiry tree informations together into one
310-
BOOST_FOREACH(const clone_t& clone, clones) {
309+
for (const auto& clone: clones) {
311310
//for each clone/original output
312311
for(output_vec_t::const_iterator original_output = outs.begin(), clone_output = clone.second.begin();
313312
original_output != outs.end() && clone_output != clone.second.end(); ++original_output, ++clone_output) {
@@ -347,7 +346,7 @@ void osmdata_t::stop() {
347346
*/
348347
size_t pending_count = mid->pending_count();
349348
mid->commit();
350-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
349+
for (auto& out: outs) {
351350
//TODO: each of the outs can be in parallel
352351
out->commit();
353352
pending_count += out->pending_count();
@@ -374,7 +373,7 @@ void osmdata_t::stop() {
374373
//Clustering, index creation, and cleanup.
375374
//All the intensive parts of this are long-running PostgreSQL commands
376375
boost::thread_group threads;
377-
BOOST_FOREACH(std::shared_ptr<output_t>& out, outs) {
376+
for (auto& out: outs) {
378377
threads.add_thread(new boost::thread(boost::bind( &output_t::stop, out.get() )));
379378
}
380379
threads.add_thread(new boost::thread(boost::bind( &middle_t::stop, mid.get() )));

output-gazetteer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
380380
const std::string &wkt,
381381
std::string &buffer)
382382
{
383-
BOOST_FOREACH(const tag &place, places) {
383+
for (const tag &place: places) {
384384
std::string name;
385385
if (place.key == "bridge" || place.key == "tunnel") {
386386
name = domain_name(place.key);
@@ -410,7 +410,7 @@ void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
410410
bool shop = (place.key == "shop") ||
411411
(place.key == "amenity") ||
412412
(place.key == "tourism");
413-
BOOST_FOREACH(const tag *entry, names) {
413+
for (const tag *entry: names) {
414414
if (!shop && (entry->key == "operator"))
415415
continue;
416416

@@ -439,7 +439,7 @@ void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
439439
copy_opt_string(addr_place, buffer);
440440
// isin
441441
if (!address.empty()) {
442-
BOOST_FOREACH(const tag *entry, address) {
442+
for (const tag *entry: address) {
443443
if (entry->key == "tiger:county") {
444444
escape(std::string(entry->value, 0, entry->value.find(",")),
445445
buffer);
@@ -461,7 +461,7 @@ void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
461461
buffer += "\\N\t";
462462
} else {
463463
bool first = true;
464-
BOOST_FOREACH(const tag *entry, extratags) {
464+
for (const tag *entry: extratags) {
465465
if (first)
466466
first = false;
467467
else

output-gazetteer.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "pgsql.hpp"
88
#include "util.hpp"
99

10-
#include <boost/foreach.hpp>
1110
#include <boost/format.hpp>
1211
#include <boost/algorithm/string/predicate.hpp>
1312

@@ -37,7 +36,7 @@ class place_tag_processor
3736

3837
bool has_place(const std::string &cls)
3938
{
40-
BOOST_FOREACH(const tag &item, places) {
39+
for (const tag &item: places) {
4140
if (cls == item.key)
4241
return true;
4342
}
@@ -91,7 +90,7 @@ class place_tag_processor
9190

9291
void escape_array_record(const std::string &in, std::string &out)
9392
{
94-
BOOST_FOREACH(const char c, in) {
93+
for (const char c: in) {
9594
switch(c) {
9695
case '\\': out += "\\\\\\\\\\\\\\\\"; break;
9796
case '\n':

output-pgsql.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
#include <boost/bind.hpp>
3838
#include <boost/format.hpp>
39-
#include <boost/foreach.hpp>
4039
#include <boost/algorithm/string/predicate.hpp>
4140
#include <boost/exception_ptr.hpp>
4241
#include <iostream>

output.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <stdexcept>
1010

1111
#include <boost/format.hpp>
12-
#include <boost/foreach.hpp>
1312
#include <boost/functional/hash.hpp>
1413
#include <boost/property_tree/ptree.hpp>
1514
#include <boost/property_tree/json_parser.hpp>
@@ -51,7 +50,7 @@ std::shared_ptr<output_t> parse_multi_single(const pt::ptree &conf,
5150
hstores_t hstore_columns;
5251
boost::optional<const pt::ptree &> hstores = conf.get_child_optional("hstores");
5352
if (hstores) {
54-
BOOST_FOREACH(const pt::ptree::value_type &val, *hstores) {
53+
for (const pt::ptree::value_type &val: *hstores) {
5554
hstore_columns.push_back(val.second.get_value<std::string>());
5655
}
5756
}
@@ -66,7 +65,7 @@ std::shared_ptr<output_t> parse_multi_single(const pt::ptree &conf,
6665

6766
export_list columns;
6867
const pt::ptree &tags = conf.get_child("tags");
69-
BOOST_FOREACH(const pt::ptree::value_type &val, tags) {
68+
for (const pt::ptree::value_type &val: tags) {
7069
const pt::ptree &tag = val.second;
7170
taginfo info;
7271
info.name = tag.get<std::string>("name");
@@ -92,7 +91,7 @@ std::vector<std::shared_ptr<output_t> > parse_multi_config(const middle_query_t
9291
pt::ptree conf;
9392
pt::read_json(file_name, conf);
9493

95-
BOOST_FOREACH(const pt::ptree::value_type &val, conf) {
94+
for (const pt::ptree::value_type &val: conf) {
9695
outputs.push_back(parse_multi_single(val.second, mid, options));
9796
}
9897

pgsql.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
#include <cstdarg>
77
#include <memory>
88
#include <boost/format.hpp>
9-
#include <boost/foreach.hpp>
109

1110
void escape(const std::string &src, std::string &dst)
1211
{
13-
BOOST_FOREACH(const char c, src)
14-
{
12+
for (const char c: src) {
1513
switch(c) {
1614
case '\\': dst.append("\\\\"); break;
1715
//case 8: dst.append("\\\b"); break;

0 commit comments

Comments
 (0)