Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1497835
atom.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
1 KB
Referenced Files
None
Subscribers
None
atom.cpp
View Options
/*******************************************************************************
*
* File: atom.cpp
*
* Contents: Implementation of non-static part of atom facilities.
*
* Copyright 2017
*
* Author: David Juhasz (david.juhasz@tuwien.ac.at)
*
* This implementation is based on the atom implementation of CAF.
* TODO: Check license.
*
******************************************************************************/
#include
"rosa/support/atom.hpp"
#include
<cstring>
namespace
rosa
{
std
::
string
to_string
(
const
AtomValue
&
What
)
{
auto
X
=
static_cast
<
atom_t
>
(
What
);
std
::
string
S
;
S
.
reserve
(
MaxAtomLength
+
1
);
// Don't read characters before we found the leading 0xF.
// First four bits set?
bool
ReadChars
=
((
X
&
0xF000000000000000
)
>>
60
)
==
0xF
;
uint64_t
Mask
=
0x0FC0000000000000
;
for
(
int
BitShift
=
54
;
BitShift
>=
0
;
BitShift
-=
6
,
Mask
>>=
6
)
{
if
(
ReadChars
)
{
S
+=
AtomDecodingTable
[(
X
&
Mask
)
>>
BitShift
];
}
else
if
(((
X
&
Mask
)
>>
BitShift
)
==
0xF
)
{
ReadChars
=
true
;
}
}
return
S
;
}
AtomValue
atom_from_string
(
const
std
::
string
&
S
)
{
if
(
S
.
size
()
>
MaxAtomLength
)
{
return
atom
(
""
);
}
char
AtomBuf
[
MaxAtomLength
+
1
];
std
::
memcpy
(
AtomBuf
,
S
.
c_str
(),
S
.
size
());
AtomBuf
[
S
.
size
()]
=
'\0'
;
return
atom
(
AtomBuf
);
}
}
// End namespace rosa
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Mar 1, 10:18 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
283329
Default Alt Text
atom.cpp (1 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment