Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. safe-cast serialization

safe-cast serialization

Scheduled Pinned Locked Moved C / C++ / MFC
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Joe Woodbury

    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

    G Offline
    G Offline
    grassrootkit
    wrote on last edited by
    #4

    memcpy Thought about this one but that would require us to cast to void*. He's saying we cannot use c-style casts too.

    J 1 Reply Last reply
    0
    • G grassrootkit

      memcpy Thought about this one but that would require us to cast to void*. He's saying we cannot use c-style casts too.

      J Offline
      J Offline
      Joe Woodbury
      wrote on last edited by
      #5

      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

      C 1 Reply Last reply
      0
      • U User 2601640

        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

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #6

        No casts, C++ streams not necessary[^]

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        U 1 Reply Last reply
        0
        • J Joe Woodbury

          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

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #7

          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]

          U 1 Reply Last reply
          0
          • S Stuart Dootson

            No casts, C++ streams not necessary[^]

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            U Offline
            U Offline
            User 2601640
            wrote on last edited by
            #8

            Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.

            S C 2 Replies Last reply
            0
            • C CPallini

              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]

              U Offline
              U Offline
              User 2601640
              wrote on last edited by
              #9

              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.

              C 1 Reply Last reply
              0
              • C CPallini

                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]

                U Offline
                U Offline
                User 2601640
                wrote on last edited by
                #10

                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.

                1 Reply Last reply
                0
                • U User 2601640

                  Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #11

                  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

                  1 Reply Last reply
                  0
                  • U User 2601640

                    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.

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #12

                    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]

                    1 Reply Last reply
                    0
                    • U User 2601640

                      Thanks for the info. I'll take a look at the Boost serialization code to see how it is written.

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #13

                      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]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups