diff --git a/examples/1_stream_known.cpp b/examples/1_stream_known.cpp index 886142fc32f7b208081c709d53009ee8a5fddd15..73a6039acd3388221166281da4037a7a146c016d 100644 --- a/examples/1_stream_known.cpp +++ b/examples/1_stream_known.cpp @@ -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; diff --git a/examples/2_stream_unknown.cpp b/examples/2_stream_unknown.cpp index 83fb8f63e2a9bcb8498863a05ec5bbc89fef2ff9..2606dd2a0fe6daf22802f9deba14d480ddc9cade 100644 --- a/examples/2_stream_unknown.cpp +++ b/examples/2_stream_unknown.cpp @@ -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(); diff --git a/stream.cpp b/stream.cpp index 039caf0c534248defcf45c32eeae562c3a8cd548..f9df3f4066c1cf59eaea880653ad5c51cf6770a2 100644 --- a/stream.cpp +++ b/stream.cpp @@ -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); } diff --git a/stream.h b/stream.h index a46d100f6c932781a148b0864d3364a97233a0a1..0db7b3fd4d98cc86323d1dcf7cdf7e17975c9b1f 100644 --- a/stream.h +++ b/stream.h @@ -115,7 +115,7 @@ public: //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; @@ -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) {} @@ -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) {}