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
32c8b501
Commit
32c8b501
authored
Jan 01, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atom tweaks
parent
129e05ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
cppa/atom.hpp
cppa/atom.hpp
+2
-2
src/atom.cpp
src/atom.cpp
+16
-6
unit_testing/test__atom.cpp
unit_testing/test__atom.cpp
+2
-0
No files found.
cppa/atom.hpp
View file @
32c8b501
...
...
@@ -42,11 +42,11 @@ enum class atom_value : std::uint64_t { dirty_little_hack = 37337 };
std
::
string
to_string
(
atom_value
const
&
a
);
template
<
size_t
Size
>
constexpr
atom_value
atom
(
c
onst
char
(
&
str
)
[
Size
])
constexpr
atom_value
atom
(
c
har
const
(
&
str
)
[
Size
])
{
// last character is the NULL terminator
static_assert
(
Size
<=
11
,
"only 10 characters are allowed"
);
return
static_cast
<
atom_value
>
(
detail
::
atom_val
(
str
,
0
));
return
static_cast
<
atom_value
>
(
detail
::
atom_val
(
str
,
0
xF
));
}
}
// namespace cppa
...
...
src/atom.cpp
View file @
32c8b501
...
...
@@ -32,17 +32,27 @@
namespace
cppa
{
std
::
string
to_string
(
const
atom_value
&
a
)
std
::
string
to_string
(
atom_value
const
&
what
)
{
auto
x
=
static_cast
<
std
::
uint64_t
>
(
what
);
std
::
string
result
;
result
.
reserve
(
11
);
for
(
auto
x
=
static_cast
<
std
::
uint64_t
>
(
a
);
x
!=
0
;
x
>>=
6
)
// don't read characters before we found the leading 0xF
// first four bits set?
bool
read_chars
=
((
x
&
0xF000000000000000
)
>>
60
)
==
0xF
;
std
::
uint64_t
mask
=
0x0FC0000000000000
;
for
(
int
bitshift
=
54
;
bitshift
>=
0
;
bitshift
-=
6
,
mask
>>=
6
)
{
// decode 6 bit characters to ASCII
result
+=
detail
::
decoding_table
[
static_cast
<
size_t
>
(
x
&
0x3F
)];
if
(
read_chars
)
{
result
+=
detail
::
decoding_table
[(
x
&
mask
)
>>
bitshift
];
}
else
if
(((
x
&
mask
)
>>
bitshift
)
==
0xF
)
{
read_chars
=
true
;
}
}
// result is reversed, since we read from right-to-left
return
std
::
string
(
result
.
rbegin
(),
result
.
rend
());
return
std
::
move
(
result
);
}
}
// namespace cppa
unit_testing/test__atom.cpp
View file @
32c8b501
...
...
@@ -33,7 +33,9 @@ size_t test__atom()
CPPA_TEST
(
test__atom
);
CPPA_CHECK_NOT_EQUAL
(
atom
(
"zzz"
),
atom
(
"000 "
));
CPPA_CHECK_EQUAL
(
atom
(
" "
),
atom
(
"@!?"
));
CPPA_CHECK_NOT_EQUAL
(
atom
(
"abc"
),
atom
(
" abc"
));
CPPA_CHECK_EQUAL
(
to_string
(
s_foo
),
"FooBar"
);
cout
<<
to_string
(
s_foo
)
<<
endl
;
self
<<
make_tuple
(
atom
(
"foo"
),
static_cast
<
std
::
uint32_t
>
(
42
))
<<
make_tuple
(
atom
(
":Attach"
),
atom
(
":Baz"
),
"cstring"
)
<<
make_tuple
(
atom
(
"b"
),
atom
(
"a"
),
atom
(
"c"
),
23.
f
)
...
...
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