Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
886441df
Commit
886441df
authored
Jun 02, 2016
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3870 from martinus/master
Added helpers to access objects while creating the flatbuffer.
parents
e02ceca5
b3c35750
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
flatbuffers.h
include/flatbuffers/flatbuffers.h
+11
-0
No files found.
include/flatbuffers/flatbuffers.h
View file @
886441df
...
@@ -1151,6 +1151,17 @@ template<typename T> const T *GetRoot(const void *buf) {
...
@@ -1151,6 +1151,17 @@ template<typename T> const T *GetRoot(const void *buf) {
return
GetMutableRoot
<
T
>
(
const_cast
<
void
*>
(
buf
));
return
GetMutableRoot
<
T
>
(
const_cast
<
void
*>
(
buf
));
}
}
/// Helpers to get a typed pointer to objects that are currently beeing built.
/// @warning Creating new objects will lead to reallocations and invalidates the pointer!
template
<
typename
T
>
T
*
GetMutableTemporaryPointer
(
FlatBufferBuilder
&
fbb
,
Offset
<
T
>
offset
)
{
return
reinterpret_cast
<
T
*>
(
fbb
.
GetCurrentBufferPointer
()
+
fbb
.
GetSize
()
-
offset
.
o
);
}
template
<
typename
T
>
const
T
*
GetTemporaryPointer
(
FlatBufferBuilder
&
fbb
,
Offset
<
T
>
offset
)
{
return
GetMutableTemporaryPointer
<
T
>
(
fbb
,
offset
);
}
// Helper to see if the identifier in a buffer has the expected value.
// Helper to see if the identifier in a buffer has the expected value.
inline
bool
BufferHasIdentifier
(
const
void
*
buf
,
const
char
*
identifier
)
{
inline
bool
BufferHasIdentifier
(
const
void
*
buf
,
const
char
*
identifier
)
{
return
strncmp
(
reinterpret_cast
<
const
char
*>
(
buf
)
+
sizeof
(
uoffset_t
),
return
strncmp
(
reinterpret_cast
<
const
char
*>
(
buf
)
+
sizeof
(
uoffset_t
),
...
...
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