7
7
#include < cstdint>
8
8
#include < cstdlib>
9
9
#include < string>
10
+ #include < utility>
10
11
11
12
#include " opentelemetry/version.h"
12
13
@@ -34,7 +35,7 @@ class UrlParser
34
35
std::string query_;
35
36
bool success_;
36
37
37
- UrlParser (std::string url) : url_(url), success_(true )
38
+ UrlParser (std::string url) : url_(std::move( url) ), success_(true )
38
39
{
39
40
if (url_.length () == 0 )
40
41
{
@@ -50,15 +51,16 @@ class UrlParser
50
51
}
51
52
else
52
53
{
53
- scheme_ = std::string (url_.begin () + cpos, url_.begin () + pos);
54
+ scheme_ = std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
55
+ url_.begin () + static_cast <std::string::difference_type>(pos));
54
56
cpos = pos + 3 ;
55
57
}
56
58
57
59
// credentials
58
- size_t pos1 = url_.find_first_of (" @" , cpos);
59
- size_t pos2 = url_.find_first_of (" /" , cpos);
60
+ size_t pos1 = url_.find_first_of (' @' , cpos);
60
61
if (pos1 != std::string::npos)
61
62
{
63
+ size_t pos2 = url_.find_first_of (' /' , cpos);
62
64
// TODO - handle credentials
63
65
if (pos2 == std::string::npos || pos1 < pos2)
64
66
{
@@ -80,7 +82,8 @@ class UrlParser
80
82
{
81
83
// port present
82
84
is_port = true ;
83
- host_ = std::string (url_.begin () + cpos, url_.begin () + pos);
85
+ host_ = std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
86
+ url_.begin () + static_cast <std::string::difference_type>(pos));
84
87
cpos = pos + 1 ;
85
88
}
86
89
pos = url_.find_first_of (" /?" , cpos);
@@ -97,7 +100,9 @@ class UrlParser
97
100
}
98
101
else
99
102
{
100
- host_ = std::string (url_.begin () + cpos, url_.begin () + url_.length ());
103
+ host_ =
104
+ std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
105
+ url_.begin () + static_cast <std::string::difference_type>(url_.length ()));
101
106
}
102
107
return ;
103
108
}
@@ -109,7 +114,8 @@ class UrlParser
109
114
}
110
115
else
111
116
{
112
- host_ = std::string (url_.begin () + cpos, url_.begin () + pos);
117
+ host_ = std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
118
+ url_.begin () + static_cast <std::string::difference_type>(pos));
113
119
}
114
120
cpos = pos;
115
121
@@ -118,21 +124,27 @@ class UrlParser
118
124
pos = url_.find (' ?' , cpos);
119
125
if (pos == std::string::npos)
120
126
{
121
- path_ = std::string (url_.begin () + cpos, url_.begin () + url_.length ());
127
+ path_ =
128
+ std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
129
+ url_.begin () + static_cast <std::string::difference_type>(url_.length ()));
122
130
query_ = " " ;
123
131
}
124
132
else
125
133
{
126
- path_ = std::string (url_.begin () + cpos, url_.begin () + pos);
127
- cpos = pos + 1 ;
128
- query_ = std::string (url_.begin () + cpos, url_.begin () + url_.length ());
134
+ path_ = std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
135
+ url_.begin () + static_cast <std::string::difference_type>(pos));
136
+ cpos = pos + 1 ;
137
+ query_ =
138
+ std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
139
+ url_.begin () + static_cast <std::string::difference_type>(url_.length ()));
129
140
}
130
141
return ;
131
142
}
132
143
path_ = std::string (" /" );
133
144
if (url_[cpos] == ' ?' )
134
145
{
135
- query_ = std::string (url_.begin () + cpos, url_.begin () + url_.length ());
146
+ query_ = std::string (url_.begin () + static_cast <std::string::difference_type>(cpos),
147
+ url_.begin () + static_cast <std::string::difference_type>(url_.length ()));
136
148
}
137
149
}
138
150
@@ -209,7 +221,7 @@ class UrlDecoder
209
221
hex[1 ] = encoded[++pos];
210
222
211
223
char *endptr;
212
- long value = strtol (hex, &endptr, 16 );
224
+ int value = static_cast < int >( std:: strtol (hex, &endptr, 16 ) );
213
225
214
226
// Invalid input: no valid hex characters after '%'
215
227
if (endptr != &hex[2 ])
0 commit comments