locked
Binary serialization?

    Question

  • I tried using boost serialization, but it needs to be ported to VC++ 11 apparently, because it crashes on construction of boost::archive::binary_oarchive. Is there a binary serialization provided by WinRT?
    Wednesday, April 25, 2012 6:40 PM

Answers

All replies

  • Hello,

    I think you need to write the serialization function by yourself.

    I found the serialization function written in the cppsampleutils.h in this sample codes
    http://code.msdn.microsoft.com/windowsapps/Splash-screen-sample-89c1dc78/sourcecode?fileId=44014&pathId=879797783

    I hope it can help you.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Monday, May 07, 2012 2:26 AM
    Thursday, April 26, 2012 6:18 AM
  • Hey jesse,

    the above link is not found. please provide this functionality if u have used ever in past. I am desperate about this functionality.

    Thursday, August 30, 2012 8:09 AM
  • Hi,

    Please follow this sample code

    Splash screen sample

    http://code.msdn.microsoft.com/windowsapps/Splash-screen-sample-89c1dc78

    suspensionmanager class

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, August 30, 2012 8:31 AM
  • Boost serialization is currently working on the latest version of Visual C++. If you don't mind using boost, I recommend it.

    Software Engineer, Brainium Studios LLC

    Thursday, August 30, 2012 5:21 PM
  • Thanks, But now i am able to save my canvas in C#.

    namespace CanvasSerializer
    {
        public class PointerDetail
        {
            
            public PointerDetail()
            {
                 
            }
            public double X { get; set; }
            public double Y { get; set; }
           
        }
    
        public class SingleMovePointerCollection
        {
            public SingleMovePointerCollection()
            { 
            }
            
            public List<PointerDetail> SingleMove
            {
                get;
                set;
            }
            public DateTime TimeStamp
            {
                get;
                set;
            }
            public double StrokeThickness { get; set; }
            public Color SelectedColor { get; set; }
            
            
    
        
           
        }
    
        public class AllMovePointerCollection
        {
            public List<SingleMovePointerCollection> AllMove
            {
                get;
                set;
            }
    
            public void Sort()
            {
              this.AllMove.OrderBy(x => x.TimeStamp).ToList();
            }
            public AllMovePointerCollection()
            {
                
            }
    
    
        }
    
    
        
    }

    => Pointer pressed->pointermoved-> pointer released one transition is called one move i.e collection of pointer details .

    => 

    AllMovePointerCollection is the list of all above moves, this way you can have all drawn line in a form of a object that can be serialized and saved.

    => Time stamp is for sequencing of actions(i.e. red line is made on blue line)

    still i am doing it for image on canvas as i m done with complete code will upload as sample.


    Thursday, September 20, 2012 7:53 AM
  • Hi,

    I'd like to serialize binary data from a C++ WinRT component to a file, and Boost serialization looks attractive. The aim is to allow the user to save project data to an arbitrary  file location using a StorageFile obtained via a file picker operation in the (C#) application which uses the WinRT component.

    It's not clear to me how to make the connection between the StorageFile and the stream archive required by the Boost serialization, i.e. is it possible to serialize directly into the StorageFile using Boost serialization?  If not, the only way I can think to do it at the moment is to serialize to a stream in memory, and then use some other technique to get the byte stream into the file.

    If anyone has any experience of these sort of practicalities, I would be very interested to hear of them.

    Friday, December 28, 2012 12:49 PM
  • RobertHF, I'm not sure if it'll work for you, based on the restriction of file access stuff, but you can still use the C library's fopen and related functions. If not that... I would try this:

    1. Use boost to serialize the data to memory (stringstream probably wont work right if you want to use a binary serializer, try this: http://boost.2283326.n4.nabble.com/in-memory-stream-binary-archive-serialization-td2578880.html)
    2. Make a class that implements IBuffer (and, as required, IBufferByteAccess) that returns the pointer to the memory stream's buffer
    3. Open the file using StorageFile.OpenAsync, get an IOutputStream from the IRandomAccessStream it returns
    4. Use IOutputStream.WriteAsync, passing in your IBuffer.

    Also, you should have posted a new question.


    Software Engineer, Brainium Studios LLC


    Friday, December 28, 2012 10:15 PM
  • Thanks brentAtBrainium,

    Sorry about not posting a new question, but since the only posts relating to Boost serialization were yours, I wanted you to get the alert.

    I've been looking around at in-memory serialization and I had seen the link you mention.

    In terms of getting the data into a file, there appears to be a rather simple way illustrated in Scenario 4 in the FilePicker sample, where it uses Windows.Storage.FileIO.WriteTextAsync() to write text to an arbitrary file specified via a file picker. There's also a Windows.Storage.FileIO.WriteBytesAsync() function, and it looks like that would be ideal. If you have any comments relating to that, please let me know.

    Saturday, December 29, 2012 12:16 PM