Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HighBlueParsers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
HighBlueParsers
Commits
094425ff
Commit
094425ff
authored
7 months ago
by
Philémon Prévot
Browse files
Options
Downloads
Patches
Plain Diff
Add macro methods for bytes to int convertion
parent
10621fc3
No related branches found
No related tags found
1 merge request
!2
HighBlueParser dev branch merged to empty main branch
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Macros.h
+28
-0
28 additions, 0 deletions
src/Macros.h
with
28 additions
and
0 deletions
src/Macros.h
0 → 100644
+
28
−
0
View file @
094425ff
#include
<cstdint>
// For standard integer types like uint8_t, uint16_t, etc.
inline
uint16_t
BUILD_UINT16
(
uint8_t
loByte
,
uint8_t
hiByte
)
{
return
static_cast
<
uint16_t
>
((
loByte
&
0x00FF
)
+
((
hiByte
&
0x00FF
)
<<
8
));
}
inline
int16_t
BUILD_INT16
(
uint8_t
hiByte
,
uint8_t
loByte
)
{
return
static_cast
<
int16_t
>
((
loByte
&
0x00FF
)
+
((
hiByte
&
0x00FF
)
<<
8
));
}
inline
uint32_t
BUILD_UINT32
(
uint8_t
Byte0
,
uint8_t
Byte1
,
uint8_t
Byte2
,
uint8_t
Byte3
)
{
return
static_cast
<
uint32_t
>
(
static_cast
<
uint32_t
>
(
Byte0
&
0x00FF
)
+
(
static_cast
<
uint32_t
>
(
Byte1
&
0x00FF
)
<<
8
)
+
(
static_cast
<
uint32_t
>
(
Byte2
&
0x00FF
)
<<
16
)
+
(
static_cast
<
uint32_t
>
(
Byte3
&
0x00FF
)
<<
24
));
}
inline
uint64_t
BUILD_UINT64
(
uint8_t
Byte0
,
uint8_t
Byte1
,
uint8_t
Byte2
,
uint8_t
Byte3
,
uint8_t
Byte4
,
uint8_t
Byte5
,
uint8_t
Byte6
,
uint8_t
Byte7
)
{
return
static_cast
<
uint64_t
>
(
static_cast
<
uint64_t
>
(
Byte0
&
0x00FF
)
+
(
static_cast
<
uint64_t
>
(
Byte1
&
0x00FF
)
<<
8
)
+
(
static_cast
<
uint64_t
>
(
Byte2
&
0x00FF
)
<<
16
)
+
(
static_cast
<
uint64_t
>
(
Byte3
&
0x00FF
)
<<
24
)
+
(
static_cast
<
uint64_t
>
(
Byte4
&
0x00FF
)
<<
32
)
+
(
static_cast
<
uint64_t
>
(
Byte5
&
0x00FF
)
<<
40
)
+
(
static_cast
<
uint64_t
>
(
Byte6
&
0x00FF
)
<<
48
)
+
(
static_cast
<
uint64_t
>
(
Byte7
&
0x00FF
)
<<
56
));
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment