Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
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
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-incubator
Commits
879f9139
Commit
879f9139
authored
Sep 08, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use string_view for the constexpr strings
parent
e7328314
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
libcaf_net/src/ip.cpp
libcaf_net/src/ip.cpp
+9
-9
No files found.
libcaf_net/src/ip.cpp
View file @
879f9139
...
@@ -58,10 +58,10 @@ namespace ip {
...
@@ -58,10 +58,10 @@ namespace ip {
namespace
{
namespace
{
// Dummy port to resolve empty string with getaddrinfo.
// Dummy port to resolve empty string with getaddrinfo.
constexpr
auto
dummy_port
=
"42"
;
constexpr
string_view
dummy_port
=
"42"
;
constexpr
auto
v4_any_addr
=
"0.0.0.0"
;
constexpr
string_view
v4_any_addr
=
"0.0.0.0"
;
constexpr
auto
v6_any_addr
=
"::"
;
constexpr
string_view
v6_any_addr
=
"::"
;
constexpr
auto
localhost
=
"localhost"
;
constexpr
string_view
localhost
=
"localhost"
;
void
*
fetch_in_addr
(
int
family
,
sockaddr
*
addr
)
{
void
*
fetch_in_addr
(
int
family
,
sockaddr
*
addr
)
{
if
(
family
==
AF_INET
)
if
(
family
==
AF_INET
)
...
@@ -115,7 +115,7 @@ std::vector<ip_address> resolve(string_view host) {
...
@@ -115,7 +115,7 @@ std::vector<ip_address> resolve(string_view host) {
addrinfo
*
tmp
=
nullptr
;
addrinfo
*
tmp
=
nullptr
;
std
::
string
host_str
{
host
.
begin
(),
host
.
end
()};
std
::
string
host_str
{
host
.
begin
(),
host
.
end
()};
if
(
getaddrinfo
(
host
.
empty
()
?
nullptr
:
host_str
.
c_str
(),
if
(
getaddrinfo
(
host
.
empty
()
?
nullptr
:
host_str
.
c_str
(),
host
.
empty
()
?
dummy_port
:
nullptr
,
&
hint
,
&
tmp
)
host
.
empty
()
?
dummy_port
.
data
()
:
nullptr
,
&
hint
,
&
tmp
)
!=
0
)
!=
0
)
return
{};
return
{};
std
::
unique_ptr
<
addrinfo
,
decltype
(
freeaddrinfo
)
*>
addrs
{
tmp
,
freeaddrinfo
};
std
::
unique_ptr
<
addrinfo
,
decltype
(
freeaddrinfo
)
*>
addrs
{
tmp
,
freeaddrinfo
};
...
@@ -151,9 +151,9 @@ std::string hostname() {
...
@@ -151,9 +151,9 @@ std::string hostname() {
std
::
vector
<
ip_address
>
local_addresses
(
string_view
host
)
{
std
::
vector
<
ip_address
>
local_addresses
(
string_view
host
)
{
using
adapters_ptr
=
std
::
unique_ptr
<
IP_ADAPTER_ADDRESSES
,
void
(
*
)(
void
*
)
>
;
using
adapters_ptr
=
std
::
unique_ptr
<
IP_ADAPTER_ADDRESSES
,
void
(
*
)(
void
*
)
>
;
using
wbuf_ptr
=
std
::
unique_ptr
<
IP_ADAPTER_ADDRESSES
,
void
(
*
)(
void
*
)
>
;
using
wbuf_ptr
=
std
::
unique_ptr
<
IP_ADAPTER_ADDRESSES
,
void
(
*
)(
void
*
)
>
;
if
(
!
host
.
empty
()
&&
host
.
compare
(
v4_any_addr
)
==
0
)
if
(
host
==
v4_any_addr
)
return
{
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)}};
return
{
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)}};
if
(
!
host
.
empty
()
&&
host
.
compare
(
v6_any_addr
)
==
0
)
if
(
host
==
v6_any_addr
)
return
{
ip_address
{}};
return
{
ip_address
{}};
ULONG
len
=
0
;
ULONG
len
=
0
;
auto
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_PREFIX
,
nullptr
,
auto
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_PREFIX
,
nullptr
,
...
@@ -214,9 +214,9 @@ std::vector<ip_address> local_addresses(string_view host) {
...
@@ -214,9 +214,9 @@ std::vector<ip_address> local_addresses(string_view host) {
#else // CAF_WINDOWS
#else // CAF_WINDOWS
std
::
vector
<
ip_address
>
local_addresses
(
string_view
host
)
{
std
::
vector
<
ip_address
>
local_addresses
(
string_view
host
)
{
if
(
!
host
.
empty
()
&&
host
.
compare
(
v4_any_addr
)
==
0
)
if
(
host
==
v4_any_addr
)
return
{
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)}};
return
{
ip_address
{
make_ipv4_address
(
0
,
0
,
0
,
0
)}};
if
(
!
host
.
empty
()
&&
host
.
compare
(
v6_any_addr
)
==
0
)
if
(
host
==
v6_any_addr
)
return
{
ip_address
{}};
return
{
ip_address
{}};
ifaddrs
*
tmp
=
nullptr
;
ifaddrs
*
tmp
=
nullptr
;
if
(
getifaddrs
(
&
tmp
)
!=
0
)
if
(
getifaddrs
(
&
tmp
)
!=
0
)
...
...
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