last day (14 days later) » 

3:47 PM
0
A: how to use boost::serialize::make_binary_object against a map

seheStd output doesn't support random binary output. You'd probably use hex of base64 encoding. Here's a simplistic approach writing out hex bytes: #include <sstream> #include <iostream> #include <iomanip> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #in...

 
sorry for my understanding issues as i am really new to this, can you please explain me why are u not using make_binary_object here, I would want all the maps data to be a part of binary object and i would also like to desiralize and see if data is correct
Also , assume that the same serialization fuction works for both binary and xml format too, can i use the same serialize function for both xml file and bianry file too ?
 
Yes. You have to name the values (make_nvp e.g.) for XML though
 
Well, my requirement is to create binary object and xml too , any good approach for doing it ?
And why is it that you have not considered make_binary_object function? Is that same as make_nvp ?
 
@LearningCpp I'm not using make_binary_object because I saw no need (do you have large binary objects? I don't see them). Deserialization is a separate task, what code did you write to do it? I answered the question as it was. Your edits changed/expanded it so much, it should probably be a new question (Pro tip: make your question complete before posting)
You keep mentioning your requirements as if we are going to do the work. They're your requirements. You can ask about specific steps you get stuck with.
 
Yes, the code is a minimal part of it , the xml file that gets created is 2MB actually
Nope , my intent is to just understand a good approach for both xml and binary
 
3:47 PM
You're on the right track as far as I can tell.
 
Hi Sehe
Iam sorry taht u misunderstood
that*
And i understood that i have to deserialize and then i will be able to see whether i have the right binary archived data , but all my confusion was why not make_binary_object as the data may get really huge
 
 
3 hours later…
6:54 PM
@LearningCpp "but all my confusion was why not make_binary_object as the data may get really huge" - that's like saying "Yeah, thanks for showing me how to bake an apple pie, but all my confusion was why not use motor oil because it is very slippery".
I'd suggest reading the documentation for make_binary_object. After that, you can explain me why you think it should be used, and how it would help (or even work). Perhaps you'll see why the question is not relevant, and otherwise I can respond to your arguments why you think it is relevant.
For now, my response is going to be like with baking an applie pie: "Motor oil is not a food ingredient. You can't eat it."
 
7:14 PM
Hehe
iam still working on how to print the binary output . Almost there
Thanks sehe for ur efforts.
The doc is just a one liner which talks about large amount of data like pixel or binary
as I said the data Iam trying to create have is a deeply nested hash and Iam trying to create an xml and a binary file too
Boss , u r best , great knowledge on stuff , I may need tips from you to start
 
8:00 PM
@LearningCpp Do you have large binary-only data (like pixels, or anything else POD and contiguous? because that's what is "already binary")?
@LearningCpp So, the data you have is anything but a large block of raw data (it's a deeple nested hash etc.). Don't bother with make_binary_object. For the same reason you don't use make_array. It isn't that :)
Here's a (not so) random search for posts using binary_[io]archive. stackoverflow.com/… I'm sure you can find examples of what you're doing
 
8:44 PM
Hi sehe
i have just finished serialising and deserialising and created a post , please suggest if something is wrong
I am really grateful to you for your help in understand and coliru has been a great suggestion which saved a lot of time for me
0
Q: serialize and deserialise using boost binary_iarchive from sstream

LearningCppFinally , After lot of struggle i found a way to serialise and deserialize the std::map<int,map<int,structute values> and iam able to print the values. Would you please clarify the doubts i have pertaining to the code below Is void serialize(archive & ar, const unsigned int version) fun...

 
9:26 PM
@sehe yes understood it now , after ur explanation . Make binary object is only for already binary data like pixels etc. And what if we make it binary using stream flags , it still is not worth effort ? Somehow in the latest code I posted i could not used that func and it was just throwing bad_alloc . And I finally removed it and used ar & x
 
9:48 PM
You can do better! "And what if we make it binary" - what if?
who's we?
make _what_ binary?
How does changing stream flags make a hashmap a binary blob?
When you're programming, nothing happens unless you make it.
 

last day (14 days later) »