C or C++ Generic Serialization and Deserialization DLL

This is a discussion on C or C++ Generic Serialization and Deserialization DLL within the Windows Programming forums, part of the Platform Specific Boards category; I'm normally a VB .Net programmer but have run into some serialization issues with the .Net Compact Framework. Background: I'm ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    11

    Question C or C++ Generic Serialization and Deserialization DLL

    I'm normally a VB.Net programmer but have run into some serialization issues with the .Net Compact Framework.

    Background: I'm putting together a scanner app to connect to a server app and need to serialize data between them in order to send it across the network. Unfortunately, because I'm only building the communication protocol I don't know what object may be passed and need to serialize and de-serialize the object passed between the two.

    Question: I'm able to "understand" C and C++ but am by no means a good programmer in these realms. Is there source code that someone had done in the past that I can compile on my own? I would prefer the source code rather than compiled in order to validate what it as actually doing so that (1) it can be used by my employer and (2) I can learn. I'd also prefer to only use the standard library and not any other open source items.

    I appreciate any and all help anyone can provide.

    Summery: Could anyone give me platform independent source code in C or C++ using only standard libraries that will generically serialize and deserialize any object that is passed to it?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    How are you sending/receiving the data (as in what API)?
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by Sebastiani View Post
    How are you sending/receiving the data (as in what API)?
    I'm not using an API but the .Net frameworks System.Net.Sockets.Socket class on both the Client and Server end.

    I would need this to only convert the objects into the byte arrays to send through the "Send" or "BeginSend" function.


    Also, I forgot to mention, I know about the XML serialization in .Net CF, but I'm having more trouble with it than just converting to a binary byte array; hence why I'm here.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Well if you want to use VB, you can probably just use System.Runtime.Serialization, no?
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by Sebastiani View Post
    Well if you want to use VB, you can probably just use System.Runtime.Serialization, no?
    That's exactly what I was thinking, but the binary serialization was eliminating from the Compact Framework because they thought it was "too big." Also, according to the .Net CF team blog, they tell us to create our own binary serializers if we don't like the XML serializers. But, I have to know the object types to create the serializers.

    At this time I can't find the pages that list this things but I saw them yesterday.

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Tanner65 View Post
    That's exactly what I was thinking, but the binary serialization was eliminating from the Compact Framework because they thought it was "too big."
    Then it sounds like the Compact Framework isn't working out too well for this application. Maybe the folks in charge need to rethink their platform choices.

    (Not to be an ass about it. But if there's a technology that's pre-existing that solves the problem why aren't you able to use it?)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by brewbuck View Post
    Then it sounds like the Compact Framework isn't working out too well for this application. Maybe the folks in charge need to rethink their platform choices.

    (Not to be an ass about it. But if there's a technology that's pre-existing that solves the problem why aren't you able to use it?)
    The framework choice is mine but also a consideration for my co-worker who will be there long after I will. He knows VB and has to be able to maintain it. If I can say "This DLL handles only the serialization" and give him the reasons why, then he'd be ok with using it.

    I'm between a rock and hard place with headaches for the past two days.


    Which technology are you recommending? The concern of my boss and co-worker is that we need to be able to see what it's doing and (for the most part) understand what's going on since the traffic is confidential information for within our building only.

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Quote Originally Posted by Tanner65 View Post
    That's exactly what I was thinking, but the binary serialization was eliminating from the Compact Framework because they thought it was "too big." Also, according to the .Net CF team blog, they tell us to create our own binary serializers if we don't like the XML serializers. But, I have to know the object types to create the serializers.

    At this time I can't find the pages that list this things but I saw them yesterday.
    I agree with Brewbuck. It sounds like the CF isn't the right tool for the job here.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    >> Which technology are you recommending? The concern of my boss and co-worker is that we need to be able to see what it's doing and (for the most part) understand what's going on since the traffic is confidential information for within our building only.

    Personally, I would recommend Mono. It works on both Windows and Linux, and supports a large number of languages (including VB).
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  10. #10
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by Sebastiani View Post
    >> Which technology are you recommending? The concern of my boss and co-worker is that we need to be able to see what it's doing and (for the most part) understand what's going on since the traffic is confidential information for within our building only.

    Personally, I would recommend Mono. It works on both Windows and Linux, and supports a large number of languages (including VB).
    Well I'm hoping to just get a serializer and deserializer and not have to redo my work thus far or learn a new language.

  11. #11
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Tanner65 View Post
    Which technology are you recommending? The concern of my boss and co-worker is that we need to be able to see what it's doing and (for the most part) understand what's going on since the traffic is confidential information for within our building only.
    Well, you said that .NET serialization is the first thing you thought of, but it's not available in the CF. So it already seems like you're comfortable with it.

    The confidentiality of the information doesn't seem to have any bearing on the choice of serialization scheme. Seriously, the framework is not "spying" on you. If you are concerned about the data passing over the network, then encrypt the data. The security of an overall design shouldn't depend on any particular data protocol.

    Although I do understand the pressures when working with people with sometimes unreasonable demands and/or conceptions. Especially when security is concerned.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  12. #12
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by brewbuck View Post
    Well, you said that .NET serialization is the first thing you thought of, but it's not available in the CF. So it already seems like you're comfortable with it.

    The confidentiality of the information doesn't seem to have any bearing on the choice of serialization scheme. Seriously, the framework is not "spying" on you. If you are concerned about the data passing over the network, then encrypt the data. The security of an overall design shouldn't depend on any particular data protocol.

    Although I do understand the pressures when working with people with sometimes unreasonable demands and/or conceptions. Especially when security is concerned.
    Well, I'm not necessarily comfortable, just know how to get data to and from it.

    The spying worry comes from using closed dll's and the possibility of them being malicious and not being able to control their usage.

  13. #13
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Quote Originally Posted by Tanner65 View Post
    Well I'm hoping to just get a serializer and deserializer and not have to redo my work thus far or learn a new language.
    You wouldn't have to redo anything. Mono has a VB compiler.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  14. #14
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    Quote Originally Posted by Sebastiani View Post
    You wouldn't have to redo anything. Mono has a VB compiler.
    Well, I'm going to look into MONO and at the most write a serializer so that I don't have to explain more than I really need.

    I'll get back to you with my findings.

    Thanks guys!

  15. #15
    Registered User
    Join Date
    Jul 2009
    Posts
    11
    I appreciate the assistance with the MONO thing.

    I'm only going to have the MONO installed at home and not at work (sill security). I can write the MONO code in C# and essentially copy and paste it at home to compile, correct?

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Serialization
    By SevenThunders in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2008, 03:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21