safe-cast serialization
-
memcpy
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
memcpy Thought about this one but that would require us to cast to void*. He's saying we cannot use c-style casts too.
-
memcpy Thought about this one but that would require us to cast to void*. He's saying we cannot use c-style casts too.
Ah, yes, he wants the
MagicalSerialization()
function.Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Is there a way in C++ to serialize objects into a char buffer without using reinterpret_cast or c-style casting (and backwards on the other end)? I also don't want to use C++ streams. I don't care how difficult it is. Thanks
No casts, C++ streams not necessary[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Ah, yes, he wants the
MagicalSerialization()
function.Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
Joe Woodbury wrote:
Ah, yes, he wants the MagicalSerialization() function.
That's exactly the point. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
No casts, C++ streams not necessary[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.
-
IMHO your requirements are not wise (why do you want to avoid cast?). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]c-style cast is dangerous and hard to find in code. reinterpret_cast is not portable and just as dangerous as c-style. i want a typed way to serialize/deserialize.
-
Joe Woodbury wrote:
Ah, yes, he wants the MagicalSerialization() function.
That's exactly the point. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]If the answer is "It's impossible" that's fine. That's why I'm asking, because I don't know if a solution exists that satisfies my parameters.
-
Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.
Member 2603772 wrote:
I'll take a look at the Boost serialization code to see how it is written
You can try :-) It's not the simplest of code! Boost code can often be difficult to follow...but it is usually good quality in terms of defect escape.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
c-style cast is dangerous and hard to find in code. reinterpret_cast is not portable and just as dangerous as c-style. i want a typed way to serialize/deserialize.
Member 2603772 wrote:
c-style cast is dangerous and hard to find in code.
I don't think so. In your case, moreover, the cast is well scoped. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.
Member 2603772 wrote:
Boost serialization code to see how it is written.
Possibly you'll find a cast, somewhere. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]