Someone can give me a good hint about how to perform serialization without using extra libraries other than the standard ones ?
3 Answers
Your options are: don't serialize, or, write your own serializer code. Its not built into the language or standard libraries.
Also, you might want to look at some similar questions:
Serialize Strings, ints and floats to character arrays for networking WITHOUT LIBRARIES
-
yep, but how to start to do that ? what are the foundation ? – Frank Sep 24 '12 at 21:49
-
Take a look at the link I posted. There are many approaches, you will have to expand your question to include the scope (what to serialize?) etc. – syplex Sep 24 '12 at 21:54
You can use something called binary serialisation using streams ,as demonstrated in

- 1,849
- 2
- 16
- 31
I would question whether you have a good reason for not using libraries. There is a lot of data that shows that the code you write yourself is most likely to blow up in your face down the line and the reason for that is because its the code with the least testing behind it.
If you do have a good reason and you still need to serialize, then you have to write your own. Basically, you're looking at overloading the usual ostream and istream operators so that they support the types you need.
Again, you run the risk of Re-inventing the square wheel. Keep in mind that the best libraries (like boost) are themselves written using standard C++ and the licensing requirements on bost do not require you to release your source or any such thing. In other words, your IP is safe even after you use them.

- 43,122
- 10
- 80
- 104
-
the boost libraries are third part libraries and i do not own them, also it's not trivial to build those libraries, especially for mobile environments; having an equivalent piece of code using only std libraries can be a much simpler solution. They also adopt a strange and complex building system for both the library itself ( b2 ) and the projects ( bjam ). – Frank Sep 24 '12 at 23:09
-
That depends on the compiler you're using. Try and build it. If it doesn't work, I'd say use the design of the serialization library (and even the source) as reference. It will make you question what you need and why you need it. This is always a good thing and would help you avoid a lot of unnecessary bugs in the future. – Carl Sep 24 '12 at 23:34