Skip to content

Commit

Permalink
Improved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fedetft committed May 23, 2018
1 parent 50f4faa commit 4a5f540
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/1_stream_known.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions examples/2_stream_unknown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 5 additions & 3 deletions stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class TypePoolStream
//NOTE: We copy the buffer to respect alignment requirements.
//The buffer may not be suitably aligned for the unserialized type
//TODO: support classes without default constructor
//NOTE: we are writing on top of a constructed type without callingits
//NOTE: we are writing on top of a constructed type without calling its
//destructor. However, since it is trivially copyable, we at least aren't
//overwriting pointers to allocated memory.
T t;
Expand Down Expand Up @@ -187,7 +187,7 @@ class InputArchive
public:
/**
* Constructor
* \param os ostream where srialized types will be written
* \param is istream where srialized types will be read
*/
InputArchive(std::istream& is) : is(is) {}

Expand Down Expand Up @@ -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) {}

Expand Down

0 comments on commit 4a5f540

Please sign in to comment.