Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Trivial serialization for C++ - tscpp
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Third Party
Trivial serialization for C++ - tscpp
Commits
4a5f5407
Commit
4a5f5407
authored
May 23, 2018
by
Federico
Browse files
Options
Downloads
Patches
Plain Diff
Improved comments
parent
50f4faa1
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/1_stream_known.cpp
+2
-2
2 additions, 2 deletions
examples/1_stream_known.cpp
examples/2_stream_unknown.cpp
+2
-2
2 additions, 2 deletions
examples/2_stream_unknown.cpp
stream.cpp
+2
-1
2 additions, 1 deletion
stream.cpp
stream.h
+5
-3
5 additions, 3 deletions
stream.h
with
11 additions
and
8 deletions
examples/1_stream_known.cpp
+
2
−
2
View file @
4a5f5407
...
...
@@ -10,13 +10,13 @@ using namespace tscpp;
int
main
()
{
//Serialize to
buffer
//Serialize to
stream
Point3d
p1
(
1
,
2
,
3
);
stringstream
ss
;
OutputArchive
oa
(
ss
);
oa
<<
p1
;
//Unserialize from
buffer
//Unserialize from
stream
Point3d
p2
;
InputArchive
ia
(
ss
);
ia
>>
p2
;
...
...
This diff is collapsed.
Click to expand it.
examples/2_stream_unknown.cpp
+
2
−
2
View file @
4a5f5407
...
...
@@ -34,13 +34,13 @@ int main()
assert
(
t
==
md
);
});
//Serialize to
buffer
//Serialize to
stream
stringstream
ss
;
OutputArchive
oa
(
ss
);
oa
<<
p2d
<<
p3d
<<
md
;
//Unserialize from
buffer
//Unserialize from
stream
UnknownInputArchive
ia
(
ss
,
tp
);
ia
.
unserialize
();
ia
.
unserialize
();
...
...
This diff is collapsed.
Click to expand it.
stream.cpp
+
2
−
1
View file @
4a5f5407
...
...
@@ -38,7 +38,8 @@ namespace tscpp {
void
TypePoolStream
::
unserializeUnknownImpl
(
const
string
&
name
,
istream
&
is
,
streampos
pos
)
const
{
auto
it
=
types
.
find
(
name
);
if
(
it
==
types
.
end
())
{
if
(
it
==
types
.
end
())
{
is
.
seekg
(
pos
);
throw
TscppException
(
"unknown type"
,
name
);
}
...
...
This diff is collapsed.
Click to expand it.
stream.h
+
5
−
3
View file @
4a5f5407
...
...
@@ -187,7 +187,7 @@ class InputArchive
public:
/**
* Constructor
* \param
o
s
o
stream where srialized types will be
written
* \param
i
s
i
stream where srialized types will be
read
*/
InputArchive
(
std
::
istream
&
is
)
:
is
(
is
)
{}
...
...
@@ -235,7 +235,9 @@ class UnknownInputArchive
public:
/**
* Constructor
* \param os ostream where srialized types will be written
* \param is istream where srialized types will be read
* \param tp TypePool containing the registered types and callbacks that
* will be called as types are unserialized
*/
UnknownInputArchive
(
std
::
istream
&
is
,
const
TypePoolStream
&
tp
)
:
is
(
is
),
tp
(
tp
)
{}
...
...
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