Skip to content

Commit ba4a849

Browse files
committed
[URI] Added some setter functions to the builder.
1 parent 74c752e commit ba4a849

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

boost/network/uri/builder.hpp

+42-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class builder {
2525

2626
}
2727

28-
builder &scheme(const string_type &scheme) {
28+
builder &set_scheme(const string_type &scheme) {
2929
uri_.uri_.append(scheme);
3030
if (opaque_schemes::exists(scheme)) {
3131
uri_.uri_.append(":");
@@ -37,52 +37,70 @@ class builder {
3737
return *this;
3838
}
3939

40-
builder &user_info(const string_type &user_info) {
40+
builder &scheme(const string_type &scheme) {
41+
return set_scheme(scheme);
42+
}
43+
44+
builder &set_user_info(const string_type &user_info) {
4145
uri_.uri_.append(user_info);
4246
uri_.uri_.append("@");
4347
uri_.parse();
4448
return *this;
4549
}
4650

47-
builder &host(const string_type &host) {
51+
builder &user_info(const string_type &user_info) {
52+
return set_user_info(user_info);
53+
}
54+
55+
builder &set_host(const string_type &host) {
4856
uri_.uri_.append(host);
4957
uri_.parse();
5058
return *this;
5159
}
5260

53-
builder &port(const string_type &port) {
61+
builder &host(const string_type &host) {
62+
return set_host(host);
63+
}
64+
65+
builder &set_port(const string_type &port) {
5466
uri_.uri_.append(":");
5567
uri_.uri_.append(port);
5668
uri_.parse();
5769
return *this;
5870
}
5971

72+
builder &port(const string_type &port) {
73+
return set_port(port);
74+
}
75+
6076
builder &port(uint16_t port) {
61-
return this->port(boost::lexical_cast<string_type>(port));
77+
return set_port(boost::lexical_cast<string_type>(port));
6278
}
6379

64-
builder &path(const string_type &path) {
80+
builder &set_path(const string_type &path) {
6581
uri_.uri_.append(path);
6682
uri_.parse();
6783
return *this;
6884
}
6985

86+
builder &path(const string_type &path) {
87+
return set_path(path);
88+
}
89+
7090
builder &encoded_path(const string_type &path) {
7191
string_type encoded_path;
7292
encode(path, std::back_inserter(encoded_path));
73-
uri_.uri_.append(encoded_path);
74-
uri_.parse();
75-
return *this;
93+
return set_path(encoded_path);
7694
}
7795

78-
builder &query(const string_type &query) {
96+
builder &set_query(const string_type &query) {
7997
uri_.uri_.append("?");
8098
uri_.uri_.append(query);
8199
uri_.parse();
82100
return *this;
83101
}
84102

85-
builder &query(const string_type &key, const string_type &value) {
103+
builder &set_query(const string_type &key, const string_type &value) {
86104
if (!uri_.query_range())
87105
{
88106
uri_.uri_.append("?");
@@ -98,13 +116,25 @@ class builder {
98116
return *this;
99117
}
100118

101-
builder &fragment(const string_type &fragment) {
119+
builder &query(const string_type &query) {
120+
return set_query(query);
121+
}
122+
123+
builder &query(const string_type &key, const string_type &value) {
124+
return set_query(key, value);
125+
}
126+
127+
builder &set_fragment(const string_type &fragment) {
102128
uri_.uri_.append("#");
103129
uri_.uri_.append(fragment);
104130
uri_.parse();
105131
return *this;
106132
}
107133

134+
builder &fragment(const string_type &fragment) {
135+
return set_fragment(fragment);
136+
}
137+
108138
private:
109139

110140
uri &uri_;

0 commit comments

Comments
 (0)