aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
Commit message (Collapse)AuthorAgeFilesLines
* Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
| | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Refactor: Removed begin/end_ptr functions.Karl-Johan Alm2016-12-091-32/+4
|
* Add serialization for unique_ptr and shared_ptrPieter Wuille2016-11-191-0/+59
|
* Add optimized CSizeComputer serializersPieter Wuille2016-11-071-0/+35
| | | | | | | | | To get the advantages of faster GetSerializeSize() implementations back that were removed in "Make GetSerializeSize a wrapper on top of CSizeComputer", reintroduce them in the few places in the form of a specialized Serialize() implementation. This actually gets us in a better state than before, as these even get used when they're invoked indirectly in the serialization of another object.
* Make CSerAction's ForRead() constexprPieter Wuille2016-11-071-2/+2
| | | | | | | | The CSerAction's ForRead() method does not depend on any runtime data, so guarantee that requests to it can be optimized out by making it constexpr. Suggested by Cory Fields.
* Avoid -Wshadow errorsPieter Wuille2016-11-071-3/+3
| | | | Suggested by Pavel Janik.
* Get rid of nType and nVersionPieter Wuille2016-11-071-130/+126
| | | | | | | | | | | Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
* Make GetSerializeSize a wrapper on top of CSizeComputerPieter Wuille2016-11-071-126/+12
| | | | | | | | | | | Given that in default GetSerializeSize implementations created by ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid of the specialized GetSerializeSize methods everywhere, and just use CSizeComputer. This removes a lot of code which isn't actually used anywhere. For CCompactSize and CVarInt this actually removes a more efficient size computing algorithm, which is brought back in a later commit.
* Make nType and nVersion private and sometimes constPieter Wuille2016-11-071-2/+2
| | | | | Make the various stream implementations' nType and nVersion private and const (except in CDataStream where we really need a setter).
* Make streams' read and write return voidPieter Wuille2016-11-071-2/+1
| | | | | | | | The stream implementations had two cascading layers (the upper one with operator<< and operator>>, and a lower one with read and write). The lower layer's functions are never cascaded (nor should they, as they should only be used from the higher layer), so make them return void instead.
* serialization: teach serializers variadicsCory Fields2016-11-031-0/+49
| | | | Also add a variadic CDataStream ctor for ease-of-use.
* serialize: Deprecate `begin_ptr` / `end_ptr`Wladimir J. van der Laan2016-10-021-11/+10
| | | | | | | Implement `begin_ptr` and `end_ptr` in terms of C++11 code, and add a comment that they are deprecated. Follow-up to developer notes update in 654a21162252294b7dbd6c982fec88008af7335e.
* Trivial: Fix two VarInt examples in serialize.hChristian Barcenas2016-08-221-2/+2
|
* Add COMPACTSIZE wrapper similar to VARINT for serializationMatt Corallo2016-06-191-0/+23
|
* Bump copyright headers to 2015MarcoFalke2015-12-131-1/+1
|
* Prevector typePieter Wuille2015-11-131-38/+119
|
* fix header include groupsPhilip Kaufmann2015-05-141-2/+2
|
* src/serialize.h: base serialization level endianness neutralityWladimir J. van der Laan2015-03-061-76/+125
| | | | Serialization type-safety and endianness compatibility.
* Remove whitespaces before double colon in errors and logsPavel Janík2015-01-311-1/+1
|
* Added "Core" to copyright headerssandakersmann2014-12-191-1/+1
| | | | | Github-Pull: #5494 Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
* Update serialize comments to be doxygen compatibleMichael Ford2014-10-311-78/+100
|
* boost: split stream classes out of serialize.hCory Fields2014-10-221-553/+0
| | | | serialization now has no dependencies.
* CAutoFile: Explicit Get() and remove unused methodsWladimir J. van der Laan2014-10-221-6/+13
| | | | Also add documentation to some methods.
* Add IsNull() to class CAutoFile and remove operator !Ruben Dario Ponticeli2014-10-201-1/+1
|
* boost: drop dependency on tuple in serializationCory Fields2014-10-151-77/+0
| | | | | There's only one user of this form of serialization, so it can be easily dropped. It could be re-added if desired when we switch to c++11.
* boost: drop dependency on is_fundamental in serializationCory Fields2014-10-151-19/+19
| | | | | | | | There's only one case where a vector containing a fundamental type is serialized all-at-once, unsigned char. Anything else would lead to strange results. Use a dummy argument to overload in that case.
* CAutoFile: make file privatePhilip Kaufmann2014-10-021-3/+4
|
* CBufferedFile: add explicit close functionPhilip Kaufmann2014-10-021-6/+18
| | | | | - also use identical close function for CAutoFile (avoids setting file to NULL under wrong conditions)
* CBufferedFile: convert into a non-refcounted RAII wrapperPhilip Kaufmann2014-10-021-9/+21
| | | | | | | | | | - it now takes over the passed file descriptor and closes it in the destructor - this fixes a leak in LoadExternalBlockFile(), where an exception could cause the file to not getting closed - disallow copies (like recently added for CAutoFile) - make nType and nVersion private
* LLu is standard, but not portable. use ULLsinetek2014-09-281-1/+1
|
* autofile: Disallow by-value copies of CAutoFileCory Fields2014-09-261-1/+5
| | | | | | One might assume that CAutoFile would be ref-counted so that a copied object would delay closing the underlying file until all copies have gone out of scope. Since that's not the case with CAutoFile, explicitly disable copying.
* Fixing improper input syntax and failing bounds checkENikS2014-09-211-1/+1
|
* header include cleanupPhilip Kaufmann2014-09-141-1/+1
| | | | - ensures alphabetical ordering for includes etc. in source file headers
* Rename IMPLEMENT_SERIALIZE to ADD_SERIALIZE_METHODSPieter Wuille2014-09-021-3/+3
|
* Merge pull request #4737Pieter Wuille2014-09-011-61/+36
|\ | | | | | | | | | | | | 31e9a83 Use CSizeComputer to avoid counting sizes in SerializationOp (Pieter Wuille) 84881f8 rework overhauled serialization methods to non-static (Kamil Domanski) 5d96b4a remove fields of ser_streamplaceholder (Kamil Domanski) 3d796f8 overhaul serialization code (Kamil Domanski)
| * Use CSizeComputer to avoid counting sizes in SerializationOpPieter Wuille2014-08-311-28/+23
| |
| * rework overhauled serialization methods to non-staticKamil Domanski2014-08-311-7/+7
| | | | | | | | | | | | | | Thanks to Pieter Wuille for most of the work on this commit. I did not fixup the overhaul commit, because a rebase conflicted with "remove fields of ser_streamplaceholder". I prefer not to risk making a mistake while resolving it.
| * remove fields of ser_streamplaceholderKamil Domanski2014-08-311-9/+1
| | | | | | | | | | | | | | The nType and nVersion fields of stream objects are never accessed from outside the class (or perhaps from the inside too, I haven't checked). Thus no need to have them in a placeholder, whose only purpose is to fill the "Stream" template parameter in serialization implementation.
| * overhaul serialization codeKamil Domanski2014-08-311-40/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation of each class' serialization/deserialization is no longer passed within a macro. The implementation now lies within a template of form: template <typename T, typename Stream, typename Operation> inline static size_t SerializationOp(T thisPtr, Stream& s, Operation ser_action, int nType, int nVersion) { size_t nSerSize = 0; /* CODE */ return nSerSize; } In cases when codepath should depend on whether or not we are just deserializing (old fGetSize, fWrite, fRead flags) an additional clause can be used: bool fRead = boost::is_same<Operation, CSerActionUnserialize>(); The IMPLEMENT_SERIALIZE macro will now be a freestanding clause added within class' body (similiar to Qt's Q_OBJECT) to implement GetSerializeSize, Serialize and Unserialize. These are now wrappers around the "SerializationOp" template.
* | add missing header end commentsPhilip Kaufmann2014-08-281-1/+1
|/ | | | | | - ensures a consistent usage in header files - also add a blank line after the copyright header where missing - also remove orphan new-lines at the end of some files
* Merge pull request #4618Pieter Wuille2014-08-241-57/+6
|\ | | | | | | eb0b56b Simplify serialize.h's exception handling (Pieter Wuille)
| * Simplify serialize.h's exception handlingPieter Wuille2014-08-091-57/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the 'state' and 'exceptmask' from serialize.h's stream implementations, as well as related methods. As exceptmask always included 'failbit', and setstate was always called with bits = failbit, all it did was immediately raise an exception. Get rid of those variables, and replace the setstate with direct exception throwing (which also removes some dead code). As a result, good() is never reached after a failure (there are only 2 calls, one of which is in tests), and can just be replaced by !eof(). fail(), clear(n) and exceptions() are just never called. Delete them.
* | replace int with size_t in stream methodsKamil Domanski2014-08-181-6/+4
| | | | | | | | | | Thus the read(...) and write(...) methods of all stream classes now have identical parameter lists. This will bring these classes one step closer to a common interface.
* | Add a way to limit deserialized string lengthsPieter Wuille2014-08-091-2/+37
|/ | | | and use it for most strings being serialized.
* Break up CAddrMan's IMPLEMENT_SERIALIZEPieter Wuille2014-07-161-0/+29
|
* Avoid undefined behavior using CFlatData in CScript serializationWladimir J. van der Laan2014-06-231-0/+34
| | | | | | | | | | | | | | | `&vch[vch.size()]` and even `&vch[0]` on vectors can cause assertion errors with VC in debug mode. This is the problem mentioned in #4239. The deeper problem with this is that we rely on undefined behavior. - Add `begin_ptr` and `end_ptr` functions that get the beginning and end pointer of vector in a reliable way that copes with empty vectors and doesn't reference outside the vector (see https://stackoverflow.com/questions/1339470/how-to-get-the-address-of-the-stdvector-buffer-start-most-elegantly/1339767#1339767). - Add a convenience constructor to CFlatData that wraps a vector. I added `begin_ptr` and `end_ptr` as separate functions as I imagine they will be useful in more places.
* remove an assignment which is never used.Yoichi Hirai2014-03-281-3/+0
|
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-77/+76
| | | | | | | | | Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
* Merge pull request #3173 from gavinandresen/fuzzmessagesGavin Andresen2013-10-301-2/+2
|\ | | | | -fuzzmessagestest=N : randomly corrupt 1-of-N sent messages
| * Bug fix: CDataStream::GetAndClear() when nReadPos > 0Gavin Andresen2013-10-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Changed CDataStream::GetAndClear() to use the most obvious get get and clear instead of a tricky swap(). Added a unit test for CDataStream insert/erase/GetAndClear. Note: GetAndClear() is not performance critical, it is used only by the send-a-message-to-the-network code. Bug was not noticed before now because the send-a-message code never erased from the stream.