Skip to content

Commit a7b9b6a

Browse files
authored
Rename some variable so that all this-> can be dropped, and do so. (etr#180)
* Use default constructor and operator= where possible: etr#177 * Remove some noexcept's from operator=(T&&) that newer versions of clang reject. * Remove more noexcept's from operator=(T&&) that newer versions of clang reject. * Remove more noexcept's from operator=(T&&) that newer versions of clang reject. * Remove more noexcept's from operator=(T&&) that newer versions of clang reject. * Revert some incedental changes for now. * Revert some incedental changes for now (http_request). * Refactor another class that got missed in the first pass. * Rename some variable so that all `this->` can be dropped, and do so. * Rename some variable so that all `this->` can be dropped, and do so. * Re-add the `this->` for setter methods.
1 parent 9cdc901 commit a7b9b6a

File tree

11 files changed

+111
-112
lines changed

11 files changed

+111
-112
lines changed

src/details/http_endpoint.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ http_endpoint::~http_endpoint()
3636
{
3737
if(reg_compiled)
3838
{
39-
regfree(&(this->re_url_normalized));
39+
regfree(&re_url_normalized);
4040
}
4141
}
4242

@@ -50,7 +50,7 @@ http_endpoint::http_endpoint
5050
family_url(family),
5151
reg_compiled(false)
5252
{
53-
this->url_normalized = use_regex ? "^/" : "/";
53+
url_normalized = use_regex ? "^/" : "/";
5454
vector<string> parts;
5555

5656
#ifdef CASE_INSENSITIVE
@@ -77,10 +77,10 @@ http_endpoint::http_endpoint
7777
{
7878
if(!registration)
7979
{
80-
this->url_normalized += (first ? "" : "/") + parts[i];
80+
url_normalized += (first ? "" : "/") + parts[i];
8181
first = false;
8282

83-
this->url_pieces.push_back(parts[i]);
83+
url_pieces.push_back(parts[i]);
8484

8585
continue;
8686
}
@@ -89,14 +89,14 @@ http_endpoint::http_endpoint
8989
{
9090
if(first)
9191
{
92-
this->url_normalized = (parts[i][0] == '^' ? "" : this->url_normalized) + parts[i];
92+
url_normalized = (parts[i][0] == '^' ? "" : url_normalized) + parts[i];
9393
first = false;
9494
}
9595
else
9696
{
97-
this->url_normalized += "/" + parts[i];
97+
url_normalized += "/" + parts[i];
9898
}
99-
this->url_pieces.push_back(parts[i]);
99+
url_pieces.push_back(parts[i]);
100100

101101
continue;
102102
}
@@ -105,23 +105,23 @@ http_endpoint::http_endpoint
105105
throw std::invalid_argument("Bad URL format");
106106

107107
std::string::size_type bar = parts[i].find_first_of('|');
108-
this->url_pars.push_back(parts[i].substr(1, bar != string::npos ? bar - 1 : parts[i].size() - 2));
109-
this->url_normalized += (first ? "" : "/") + (bar != string::npos ? parts[i].substr(bar + 1, parts[i].size() - bar - 2) : "([^\\/]+)");
108+
url_pars.push_back(parts[i].substr(1, bar != string::npos ? bar - 1 : parts[i].size() - 2));
109+
url_normalized += (first ? "" : "/") + (bar != string::npos ? parts[i].substr(bar + 1, parts[i].size() - bar - 2) : "([^\\/]+)");
110110

111111
first = false;
112112

113-
this->chunk_positions.push_back(i);
113+
chunk_positions.push_back(i);
114114

115-
this->url_pieces.push_back(parts[i]);
115+
url_pieces.push_back(parts[i]);
116116
}
117117

118118
if(use_regex)
119119
{
120-
this->url_normalized += "$";
121-
regcomp(&(this->re_url_normalized), url_normalized.c_str(),
120+
url_normalized += "$";
121+
regcomp(&re_url_normalized, url_normalized.c_str(),
122122
REG_EXTENDED|REG_ICASE|REG_NOSUB
123123
);
124-
this->reg_compiled = true;
124+
reg_compiled = true;
125125
}
126126
}
127127

@@ -134,52 +134,52 @@ http_endpoint::http_endpoint(const http_endpoint& h):
134134
family_url(h.family_url),
135135
reg_compiled(h.reg_compiled)
136136
{
137-
if(this->reg_compiled)
138-
regcomp(&(this->re_url_normalized), url_normalized.c_str(),
137+
if(reg_compiled)
138+
regcomp(&re_url_normalized, url_normalized.c_str(),
139139
REG_EXTENDED|REG_ICASE|REG_NOSUB
140140
);
141141
}
142142

143143
http_endpoint& http_endpoint::operator =(const http_endpoint& h)
144144
{
145-
this->url_complete = h.url_complete;
146-
this->url_normalized = h.url_normalized;
147-
this->family_url = h.family_url;
148-
this->reg_compiled = h.reg_compiled;
149-
if(this->reg_compiled)
145+
url_complete = h.url_complete;
146+
url_normalized = h.url_normalized;
147+
family_url = h.family_url;
148+
reg_compiled = h.reg_compiled;
149+
if(reg_compiled)
150150
{
151-
regfree(&(this->re_url_normalized));
151+
regfree(&re_url_normalized);
152152

153-
regcomp(&(this->re_url_normalized), url_normalized.c_str(),
153+
regcomp(&re_url_normalized, url_normalized.c_str(),
154154
REG_EXTENDED|REG_ICASE|REG_NOSUB
155155
);
156156
}
157-
this->url_pars = h.url_pars;
158-
this->url_pieces = h.url_pieces;
159-
this->chunk_positions = h.chunk_positions;
157+
url_pars = h.url_pars;
158+
url_pieces = h.url_pieces;
159+
chunk_positions = h.chunk_positions;
160160
return *this;
161161
}
162162

163163
bool http_endpoint::operator <(const http_endpoint& b) const
164164
{
165-
COMPARATOR(this->url_normalized, b.url_normalized, std::toupper);
165+
COMPARATOR(url_normalized, b.url_normalized, std::toupper);
166166
}
167167

168168
bool http_endpoint::match(const http_endpoint& url) const
169169
{
170-
if (!this->reg_compiled) throw std::invalid_argument("Cannot run match. Regex suppressed.");
170+
if (!reg_compiled) throw std::invalid_argument("Cannot run match. Regex suppressed.");
171171

172-
if(!this->family_url || url.url_pieces.size() < this->url_pieces.size())
173-
return regexec(&(this->re_url_normalized), url.url_complete.c_str(), 0, NULL, 0) == 0;
172+
if(!family_url || url.url_pieces.size() < url_pieces.size())
173+
return regexec(&re_url_normalized, url.url_complete.c_str(), 0, NULL, 0) == 0;
174174

175175
string nn = "/";
176176
bool first = true;
177-
for(unsigned int i = 0; i < this->url_pieces.size(); i++)
177+
for(unsigned int i = 0; i < url_pieces.size(); i++)
178178
{
179179
nn += (first ? "" : "/") + url.url_pieces[i];
180180
first = false;
181181
}
182-
return regexec(&(this->re_url_normalized), nn.c_str(), 0, NULL, 0) == 0;
182+
return regexec(&re_url_normalized, nn.c_str(), 0, NULL, 0) == 0;
183183
}
184184

185185
};

src/http_request.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool http_request::check_digest_auth(
7676
const std::string http_request::get_connection_value(const std::string& key, enum MHD_ValueKind kind) const
7777
{
7878
const char* header_c = MHD_lookup_connection_value(
79-
this->underlying_connection,
79+
underlying_connection,
8080
kind,
8181
key.c_str()
8282
);
@@ -103,7 +103,7 @@ const std::map<std::string, std::string, http::header_comparator> http_request::
103103
std::map<std::string, std::string, http::header_comparator> headers;
104104

105105
MHD_get_connection_values(
106-
this->underlying_connection,
106+
underlying_connection,
107107
kind,
108108
&build_request_header,
109109
(void*) &headers
@@ -144,9 +144,9 @@ const std::map<std::string, std::string, http::header_comparator> http_request::
144144

145145
const std::string http_request::get_arg(const std::string& key) const
146146
{
147-
std::map<std::string, std::string>::const_iterator it = this->args.find(key);
147+
std::map<std::string, std::string>::const_iterator it = args.find(key);
148148

149-
if(it != this->args.end())
149+
if(it != args.end())
150150
{
151151
return it->second;
152152
}
@@ -157,14 +157,14 @@ const std::string http_request::get_arg(const std::string& key) const
157157
const std::map<std::string, std::string, http::arg_comparator> http_request::get_args() const
158158
{
159159
std::map<std::string, std::string, http::arg_comparator> arguments;
160-
arguments.insert(this->args.begin(), this->args.end());
160+
arguments.insert(args.begin(), args.end());
161161

162162
arguments_accumulator aa;
163-
aa.unescaper = this->unescaper;
163+
aa.unescaper = unescaper;
164164
aa.arguments = &arguments;
165165

166166
MHD_get_connection_values(
167-
this->underlying_connection,
167+
underlying_connection,
168168
MHD_GET_ARGUMENT_KIND,
169169
&build_request_args,
170170
(void*) &aa
@@ -178,7 +178,7 @@ const std::string http_request::get_querystring() const
178178
std::string querystring = "";
179179

180180
MHD_get_connection_values(
181-
this->underlying_connection,
181+
underlying_connection,
182182
MHD_GET_ARGUMENT_KIND,
183183
&build_request_querystring,
184184
(void*) &querystring

src/http_response.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int http_response::enqueue_response(MHD_Connection* connection, MHD_Response* re
7070

7171
void http_response::shoutCAST()
7272
{
73-
this->response_code |= http::http_utils::shoutcast_response;
73+
response_code |= http::http_utils::shoutcast_response;
7474
}
7575

7676
std::ostream &operator<< (std::ostream &os, const http_response &r)

src/http_utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,26 +517,26 @@ bool ip_representation::operator <(const ip_representation& b) const
517517
{
518518
if (i == 10 || i == 11) continue;
519519

520-
if (CHECK_BIT(this->mask, i) && CHECK_BIT(b.mask, i))
520+
if (CHECK_BIT(mask, i) && CHECK_BIT(b.mask, i))
521521
{
522-
this_score += (16 - i) * this->pieces[i];
522+
this_score += (16 - i) * pieces[i];
523523
b_score += (16 - i) * b.pieces[i];
524524
}
525525
}
526526

527527
if (this_score == b_score &&
528-
((this->pieces[10] == 0x00 || this->pieces[10] == 0xFF) && (b.pieces[10] == 0x00 || b.pieces[10] == 0xFF)) &&
529-
((this->pieces[11] == 0x00 || this->pieces[11] == 0xFF) && (b.pieces[11] == 0x00 || b.pieces[11] == 0xFF))
528+
((pieces[10] == 0x00 || pieces[10] == 0xFF) && (b.pieces[10] == 0x00 || b.pieces[10] == 0xFF)) &&
529+
((pieces[11] == 0x00 || pieces[11] == 0xFF) && (b.pieces[11] == 0x00 || b.pieces[11] == 0xFF))
530530
)
531531
{
532532
return false;
533533
}
534534

535535
for (int i = 10; i < 12; i++)
536536
{
537-
if (CHECK_BIT(this->mask, i) && CHECK_BIT(b.mask, i))
537+
if (CHECK_BIT(mask, i) && CHECK_BIT(b.mask, i))
538538
{
539-
this_score += (16 - i) * this->pieces[i];
539+
this_score += (16 - i) * pieces[i];
540540
b_score += (16 - i) * b.pieces[i];
541541
}
542542
}

src/httpserver/deferred_response.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class deferred_response : public string_response
6262

6363
MHD_Response* get_raw_response()
6464
{
65-
return details::get_raw_response_helper((void*) this, &(this->cb));
65+
return details::get_raw_response_helper((void*) this, &cb);
6666
}
6767

6868
private:

src/httpserver/details/http_endpoint.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ class http_endpoint
8585
**/
8686
const std::string& get_url_complete() const
8787
{
88-
return this->url_complete;
88+
return url_complete;
8989
}
9090

9191
const std::string& get_url_normalized() const
9292
{
93-
return this->url_normalized;
93+
return url_normalized;
9494
}
9595

9696
/**
@@ -99,7 +99,7 @@ class http_endpoint
9999
**/
100100
const std::vector<std::string>& get_url_pars() const
101101
{
102-
return this->url_pars;
102+
return url_pars;
103103
}
104104

105105
/**
@@ -108,7 +108,7 @@ class http_endpoint
108108
**/
109109
const std::vector<std::string>& get_url_pieces() const
110110
{
111-
return this->url_pieces;
111+
return url_pieces;
112112
}
113113

114114
/**
@@ -117,17 +117,17 @@ class http_endpoint
117117
**/
118118
const std::vector<int>& get_chunk_positions() const
119119
{
120-
return this->chunk_positions;
120+
return chunk_positions;
121121
}
122122

123123
const bool is_family_url() const
124124
{
125-
return this->family_url;
125+
return family_url;
126126
}
127127

128128
const bool is_regex_compiled() const
129129
{
130-
return this->reg_compiled;
130+
return reg_compiled;
131131
}
132132

133133
/**

src/httpserver/http_request.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class http_request
7676
**/
7777
const std::string& get_path() const
7878
{
79-
return this->path;
79+
return path;
8080
}
8181

8282
/**
@@ -85,7 +85,7 @@ class http_request
8585
**/
8686
const std::vector<std::string> get_path_pieces() const
8787
{
88-
return http::http_utils::tokenize_url(this->path);
88+
return http::http_utils::tokenize_url(path);
8989
}
9090

9191
/**
@@ -95,7 +95,7 @@ class http_request
9595
**/
9696
const std::string get_path_piece(int index) const
9797
{
98-
std::vector<std::string> post_path = this->get_path_pieces();
98+
std::vector<std::string> post_path = get_path_pieces();
9999
if(((int)(post_path.size())) > index)
100100
return post_path[index];
101101
return EMPTY;
@@ -107,7 +107,7 @@ class http_request
107107
**/
108108
const std::string& get_method() const
109109
{
110-
return this->method;
110+
return method;
111111
}
112112

113113
/**
@@ -167,7 +167,7 @@ class http_request
167167
**/
168168
const std::string& get_content() const
169169
{
170-
return this->content;
170+
return content;
171171
}
172172

173173
/**
@@ -190,7 +190,7 @@ class http_request
190190
**/
191191
const std::string& get_version() const
192192
{
193-
return this->version;
193+
return version;
194194
}
195195

196196
/**
@@ -264,7 +264,7 @@ class http_request
264264
**/
265265
void set_arg(const std::string& key, const std::string& value)
266266
{
267-
this->args[key] = value.substr(0,content_size_limit);
267+
args[key] = value.substr(0,content_size_limit);
268268
}
269269

270270
/**
@@ -275,8 +275,7 @@ class http_request
275275
**/
276276
void set_arg(const char* key, const char* value, size_t size)
277277
{
278-
this->args[key] = std::string(value,
279-
std::min(size, content_size_limit));
278+
args[key] = std::string(value, std::min(size, content_size_limit));
280279
}
281280

282281
/**

0 commit comments

Comments
 (0)