Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
61f3da06
Commit
61f3da06
authored
Aug 21, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename append_uri, add type safe handling of host
parent
d91ff8e8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
23 deletions
+32
-23
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-1
libcaf_core/caf/detail/append_percent_encoded.hpp
libcaf_core/caf/detail/append_percent_encoded.hpp
+3
-2
libcaf_core/src/append_percent_encoded.cpp
libcaf_core/src/append_percent_encoded.cpp
+3
-3
libcaf_core/src/uri.cpp
libcaf_core/src/uri.cpp
+18
-10
libcaf_core/src/uri_impl.cpp
libcaf_core/src/uri_impl.cpp
+7
-7
No files found.
libcaf_core/CMakeLists.txt
View file @
61f3da06
...
...
@@ -26,7 +26,7 @@ set(LIBCAF_CORE_SRCS
src/actor_system.cpp
src/actor_system_config.cpp
src/append_hex.cpp
src/append_
uri
.cpp
src/append_
percent_encoded
.cpp
src/atom.cpp
src/attachable.cpp
src/behavior.cpp
...
...
libcaf_core/caf/detail/append_
uri
.hpp
→
libcaf_core/caf/detail/append_
percent_encoded
.hpp
View file @
61f3da06
...
...
@@ -19,13 +19,14 @@
#pragma once
#include "caf/detail/append_hex.hpp"
#include "caf/fwd.hpp"
namespace
caf
{
namespace
detail
{
// Escapes all reserved characters according to RFC 3986 in `x` and
// adds the encoded string to `str`.
void
append_
uri
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
=
false
);
void
append_
percent_encoded
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
=
false
);
}
// namespac
vec
detail
}
// namespac
e
detail
}
// namespace caf
libcaf_core/src/append_
uri
.cpp
→
libcaf_core/src/append_
percent_encoded
.cpp
View file @
61f3da06
...
...
@@ -16,7 +16,7 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/detail/append_
uri
.hpp"
#include "caf/detail/append_
percent_encoded
.hpp"
#include "caf/config.hpp"
#include "caf/detail/append_hex.hpp"
...
...
@@ -25,7 +25,7 @@
namespace
caf
{
namespace
detail
{
void
append_
uri
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
)
{
void
append_
percent_encoded
(
std
::
string
&
str
,
string_view
x
,
bool
is_path
)
{
for
(
auto
ch
:
x
)
switch
(
ch
)
{
case
'/'
:
...
...
@@ -61,5 +61,5 @@ void append_uri(std::string& str, string_view x, bool is_path) {
}
}
}
// namespac
vec
detail
}
// namespac
e
detail
}
// namespace caf
libcaf_core/src/uri.cpp
View file @
61f3da06
...
...
@@ -19,8 +19,9 @@
#include "caf/uri.hpp"
#include "caf/deserializer.hpp"
#include "caf/detail/append_
uri
.hpp"
#include "caf/detail/append_
percent_encoded
.hpp"
#include "caf/detail/fnv_hash.hpp"
#include "caf/detail/overload.hpp"
#include "caf/detail/parser/read_uri.hpp"
#include "caf/detail/uri_impl.hpp"
#include "caf/error.hpp"
...
...
@@ -105,17 +106,24 @@ std::string to_string(const uri& x) {
std
::
string
to_string
(
const
uri
::
authority_type
&
x
)
{
std
::
string
str
;
if
(
!
x
.
userinfo
.
empty
())
{
detail
::
append_
uri
(
str
,
x
.
userinfo
);
detail
::
append_
percent_encoded
(
str
,
x
.
userinfo
);
str
+=
'@'
;
}
auto
addr
=
get_if
<
ip_address
>
(
&
x
.
host
);
if
(
addr
==
nullptr
)
{
detail
::
append_uri
(
str
,
get
<
std
::
string
>
(
x
.
host
));
auto
f
=
caf
::
detail
::
make_overload
(
[
&
](
const
ip_address
&
addr
)
{
if
(
addr
.
embeds_v4
())
{
str
+=
to_string
(
addr
);
}
else
{
str
+=
'['
;
str
+=
to_string
(
*
addr
);
str
+=
to_string
(
addr
);
str
+=
']'
;
}
},
[
&
](
const
std
::
string
&
host
)
{
detail
::
append_percent_encoded
(
str
,
host
);
}
);
visit
(
f
,
x
.
host
);
if
(
x
.
port
!=
0
)
{
str
+=
':'
;
str
+=
std
::
to_string
(
x
.
port
);
...
...
libcaf_core/src/uri_impl.cpp
View file @
61f3da06
...
...
@@ -18,7 +18,7 @@
#include "caf/detail/uri_impl.hpp"
#include "caf/detail/append_
uri
.hpp"
#include "caf/detail/append_
percent_encoded
.hpp"
#include "caf/detail/parser/read_uri.hpp"
#include "caf/error.hpp"
#include "caf/ip_address.hpp"
...
...
@@ -40,26 +40,26 @@ uri_impl uri_impl::default_instance;
// -- modifiers ----------------------------------------------------------------
void
uri_impl
::
assemble_str
()
{
append_
uri
(
str
,
scheme
);
append_
percent_encoded
(
str
,
scheme
);
str
+=
':'
;
if
(
authority
.
empty
())
{
CAF_ASSERT
(
!
path
.
empty
());
append_
uri
(
str
,
path
,
true
);
append_
percent_encoded
(
str
,
path
,
true
);
}
else
{
str
+=
"//"
;
str
+=
to_string
(
authority
);
if
(
!
path
.
empty
())
{
str
+=
'/'
;
append_
uri
(
str
,
path
,
true
);
append_
percent_encoded
(
str
,
path
,
true
);
}
}
if
(
!
query
.
empty
())
{
str
+=
'?'
;
auto
i
=
query
.
begin
();
auto
add_kvp
=
[
&
](
decltype
(
*
i
)
kvp
)
{
append_
uri
(
str
,
kvp
.
first
);
append_
percent_encoded
(
str
,
kvp
.
first
);
str
+=
'='
;
append_
uri
(
str
,
kvp
.
second
);
append_
percent_encoded
(
str
,
kvp
.
second
);
};
add_kvp
(
*
i
);
for
(
++
i
;
i
!=
query
.
end
();
++
i
)
{
...
...
@@ -69,7 +69,7 @@ void uri_impl::assemble_str() {
}
if
(
!
fragment
.
empty
())
{
str
+=
'#'
;
append_
uri
(
str
,
fragment
);
append_
percent_encoded
(
str
,
fragment
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment