Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Reyhaneh Karimipour
xtrace-cpp
Commits
ddc71966
Commit
ddc71966
authored
May 21, 2019
by
DEPRECATED (Jonathan Mace) (Use @JonathanMace instead)
Browse files
Add some convenience string serialization methods:
parent
befbc2f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
ddc71966
build
include/baggage.h
View file @
ddc71966
...
...
@@ -5,6 +5,7 @@
#include
<cstdint>
#include
<cstddef>
#include
<vector>
#include
<string>
/*
...
...
@@ -44,9 +45,11 @@ struct Baggage {
static
Baggage
merge
(
Baggage
&
a
,
Baggage
&
b
);
// Serialize this baggage, as defined in the Brown Tracing Plane (length-prefix each atom in order)
std
::
string
str
();
std
::
vector
<
uint8_t
>
serialize
();
// Deserialize a serialized baggage instance, as defined in the Brown Tracing Plane
static
Baggage
deserialize
(
std
::
string
bytes
);
static
Baggage
deserialize
(
std
::
vector
<
uint8_t
>
bytes
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Baggage
&
baggage
);
...
...
src/atomlayer.cpp
View file @
ddc71966
...
...
@@ -4,6 +4,7 @@
#include
<cstdint>
#include
<cstddef>
#include
<vector>
#include
<string>
std
::
vector
<
uint8_t
>
encodeVarint
(
uint64_t
x
)
{
std
::
vector
<
uint8_t
>
s
;
...
...
@@ -98,6 +99,16 @@ std::vector<uint8_t> Baggage::serialize() {
return
bytes
;
}
std
::
string
Baggage
::
str
()
{
std
::
vector
<
uint8_t
>
bytes
=
this
->
serialize
();
return
std
::
string
(
bytes
.
begin
(),
bytes
.
end
());
}
Baggage
Baggage
::
deserialize
(
std
::
string
bytes
)
{
std
::
vector
<
uint8_t
>
bytev
(
bytes
.
begin
(),
bytes
.
end
());
return
Baggage
::
deserialize
(
bytev
);
}
Baggage
Baggage
::
deserialize
(
std
::
vector
<
uint8_t
>
bytes
)
{
Baggage
baggage
;
unsigned
n
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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