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
1be020b4
Commit
1be020b4
authored
Jul 05, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recognize string_view in stringification_inspector
parent
dae40f2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+10
-6
libcaf_core/src/stringification_inspector.cpp
libcaf_core/src/stringification_inspector.cpp
+8
-11
No files found.
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
1be020b4
...
@@ -25,8 +25,9 @@
...
@@ -25,8 +25,9 @@
#include <vector>
#include <vector>
#include "caf/atom.hpp"
#include "caf/atom.hpp"
#include "caf/none.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/none.hpp"
#include "caf/string_view.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/meta/omittable.hpp"
#include "caf/meta/omittable.hpp"
...
@@ -73,18 +74,20 @@ public:
...
@@ -73,18 +74,20 @@ public:
void
consume
(
atom_value
&
x
);
void
consume
(
atom_value
&
x
);
void
consume
(
const
char
*
c
str
);
void
consume
(
string_view
str
);
inline
void
consume
(
bool
&
x
)
{
inline
void
consume
(
bool
&
x
)
{
result_
+=
x
?
"true"
:
"false"
;
result_
+=
x
?
"true"
:
"false"
;
}
}
inline
void
consume
(
char
*
cstr
)
{
inline
void
consume
(
const
char
*
cstr
)
{
consume
(
const_cast
<
const
char
*>
(
cstr
));
string_view
tmp
{
cstr
,
strlen
(
cstr
)};
consume
(
tmp
);
}
}
inline
void
consume
(
std
::
string
&
str
)
{
inline
void
consume
(
char
*
cstr
)
{
consume
(
str
.
c_str
());
string_view
tmp
{
cstr
,
strlen
(
cstr
)};
consume
(
tmp
);
}
}
template
<
class
T
>
template
<
class
T
>
...
@@ -132,6 +135,7 @@ public:
...
@@ -132,6 +135,7 @@ public:
template
<
class
T
>
template
<
class
T
>
enable_if_t
<
is_iterable
<
T
>::
value
enable_if_t
<
is_iterable
<
T
>::
value
&&
!
is_inspectable
<
stringification_inspector
,
T
>::
value
&&
!
is_inspectable
<
stringification_inspector
,
T
>::
value
&&
!
std
::
is_convertible
<
T
,
string_view
>::
value
&&
!
has_to_string
<
T
>::
value
>
&&
!
has_to_string
<
T
>::
value
>
consume
(
T
&
xs
)
{
consume
(
T
&
xs
)
{
result_
+=
'['
;
result_
+=
'['
;
...
...
libcaf_core/src/stringification_inspector.cpp
View file @
1be020b4
...
@@ -39,20 +39,20 @@ void stringification_inspector::consume(atom_value& x) {
...
@@ -39,20 +39,20 @@ void stringification_inspector::consume(atom_value& x) {
result_
+=
'\''
;
result_
+=
'\''
;
}
}
void
stringification_inspector
::
consume
(
const
char
*
c
str
)
{
void
stringification_inspector
::
consume
(
string_view
str
)
{
if
(
cstr
==
nullptr
||
*
cstr
==
'\0'
)
{
if
(
str
.
empty
()
)
{
result_
+=
R"("")"
;
result_
+=
R"("")"
;
return
;
return
;
}
}
if
(
*
cstr
==
'"'
)
{
if
(
str
[
0
]
==
'"'
)
{
//
assume an already escaped string
//
Assume an already escaped string.
result_
+=
cstr
;
result_
.
insert
(
result_
.
end
(),
str
.
begin
(),
str
.
end
())
;
return
;
return
;
}
}
// Escape string.
result_
+=
'"'
;
result_
+=
'"'
;
char
c
;
for
(
char
c
:
str
)
{
for
(;;)
{
switch
(
c
)
{
switch
(
c
=
*
cstr
++
)
{
default:
default:
result_
+=
c
;
result_
+=
c
;
break
;
break
;
...
@@ -62,11 +62,8 @@ void stringification_inspector::consume(const char* cstr) {
...
@@ -62,11 +62,8 @@ void stringification_inspector::consume(const char* cstr) {
case
'"'
:
case
'"'
:
result_
+=
R"(\")"
;
result_
+=
R"(\")"
;
break
;
break
;
case
'\0'
:
goto
end_of_string
;
}
}
}
}
end_of_string:
result_
+=
'"'
;
result_
+=
'"'
;
}
}
...
...
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