Skip to content

Commit e3301ca

Browse files
committed
Use BOOST_FOREACH instead of C++11
1 parent 9862779 commit e3301ca

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

modules/geoipbackend/geoipbackend.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
#include <glob.h>
55

66
pthread_rwlock_t GeoIPBackend::s_state_lock=PTHREAD_RWLOCK_INITIALIZER;
7+
typedef map<string, string> service_map_t;
8+
typedef map<string, vector<DNSResourceRecord> > record_map_t;
79

810
class GeoIPDomain {
911
public:
1012
int id;
1113
string domain;
1214
int ttl;
13-
map<string, string> services;
14-
map<string, vector<DNSResourceRecord> > records;
15+
service_map_t services;
16+
record_map_t records;
1517
};
1618

1719
static vector<GeoIPDomain> s_domains;
@@ -129,10 +131,10 @@ void GeoIPBackend::initialize() {
129131
}
130132

131133
// rectify the zone, first static records
132-
for(auto &item : dom.records) {
134+
BOOST_FOREACH(record_map_t::value_type& item, dom.records) {
133135
// ensure we have parent in records
134-
DNSName name = item.first;
135-
while(name.chopOff() && name.isPartOf(dom.domain)) {
136+
string name = item.first;
137+
while(chopOff(name) && endsOn(name, dom.domain)) {
136138
if (dom.records.find(name) == dom.records.end()) {
137139
DNSResourceRecord rr;
138140
vector<DNSResourceRecord> rrs;
@@ -150,10 +152,10 @@ void GeoIPBackend::initialize() {
150152
}
151153

152154
// then services
153-
for(auto &item : dom.services) {
155+
BOOST_FOREACH(service_map_t::value_type& item, dom.services) {
154156
// ensure we have parent in records
155-
DNSName name = item.first;
156-
while(name.chopOff() && name.isPartOf(dom.domain)) {
157+
string name = item.first;
158+
while(chopOff(name) && endsOn(name, dom.domain)) {
157159
if (dom.records.find(name) == dom.records.end()) {
158160
DNSResourceRecord rr;
159161
vector<DNSResourceRecord> rrs;
@@ -245,7 +247,7 @@ void GeoIPBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *
245247

246248
// see if the record can be found
247249
if (dom.records.count(format)) { // return static value
248-
map<DNSName, vector<DNSResourceRecord> >::iterator i = dom.records.find(format);
250+
record_map_t::iterator i = dom.records.find(format);
249251
BOOST_FOREACH(DNSResourceRecord rr, i->second) {
250252
if (qtype == QType::ANY || rr.qtype == qtype) {
251253
rr.scopeMask = (v6 ? 128 : 32);

0 commit comments

Comments
 (0)