Loading ...
Sorry, an error occurred while loading the content.
 

output_binary_int

Expand Messages
  • Joel Reymont
    Folks, What type of endianness does output_binary_int function use? The platform-specific one? Also, are there libraries for serialization compatible with
    Message 1 of 5 , Jul 30, 2006
      Folks,

      What type of endianness does output_binary_int function use? The
      platform-specific one?

      Also, are there libraries for serialization compatible with C/C++?

      Thanks, Joel

      --
      http://wagerlabs.com/
    • Joshua Smith
      From the Ocaml documentation found at http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html val output_binary_int : out_channel - a
      Message 2 of 5 , Jul 30, 2006
        From the Ocaml documentation found at
        http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html

        <blockquote>
        val output_binary_int : out_channel -> 'a -> unit
        Write one integer in binary format (4 bytes, big-endian) on the given
        output channel. The given integer is taken modulo 2^32. The only
        reliable way to read it back is through the input_binary_int function.
        The format is compatible across all machines for a given version of
        Objective Caml.
        </blockquote>

        As for serialization, you could roll-your-own serialization format
        that would be compatible with any language you wanted. However, the
        native Marshal serialization doesn't have foreign-function interfaces
        or libraries to access the format from C/C++ (though there may be
        third party libraries that do this). If you were clever and had the
        time, you could probably write something to do this using C-callbacks
        and some such, but that would not be a very high performance solution.


        HTH.

        -jbs
      • Richard Jones
        ... It s defined as big endian, ie. network byte order. Note that on a 64 bit machine the integer is truncated to 32 bits before being output. On a 32 bit
        Message 3 of 5 , Jul 31, 2006
          On Sun, Jul 30, 2006 at 03:25:36PM +0100, Joel Reymont wrote:
          > What type of endianness does output_binary_int function use? The
          > platform-specific one?

          It's defined as big endian, ie. network byte order. Note that on a 64
          bit machine the integer is truncated to 32 bits before being output.
          On a 32 bit machine of course integers can only be 31 bits.

          > Also, are there libraries for serialization compatible with C/C++?

          Yes, several.

          * Use SunRPC / XDR - http://www.ocaml-programming.de/programming/rpc.html
          * Or XMLRPC - http://raevnos.pennmush.org/code/ocaml-xml-rpc/
          * Or COM (on Windows) - http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=343
          * Use XML (eg. something like PXP - http://www.ocaml-programming.de/programming/pxp.html).
          * Use CSV - http://merjis.com/developers/csv
          * Use something like YAML.
          * Write your own :-)

          Rich.

          --
          Richard Jones, CTO Merjis Ltd.
          Merjis - web marketing and technology - http://merjis.com
          Team Notepad - intranets and extranets for business - http://team-notepad.com
        • Joel Reymont
          ... Thanks Rich! Is there some OCaml library to work with YAML then? -- http://wagerlabs.com/
          Message 4 of 5 , Jul 31, 2006
            On Jul 31, 2006, at 2:28 PM, Richard Jones wrote:

            > * Use something like YAML.

            Thanks Rich! Is there some OCaml library to work with YAML then?

            --
            http://wagerlabs.com/
          • Richard Jones
            ... There was a lot of talk about it, but I m not sure whether anyone got around to making a good implementation. Anyway, a Google search for ocaml yaml
            Message 5 of 5 , Jul 31, 2006
              On Mon, Jul 31, 2006 at 03:59:46PM +0100, Joel Reymont wrote:
              > On Jul 31, 2006, at 2:28 PM, Richard Jones wrote:
              > > * Use something like YAML.
              > Thanks Rich! Is there some OCaml library to work with YAML then?

              There was a lot of talk about it, but I'm not sure whether anyone got
              around to making a good implementation. Anyway, a Google search for
              "ocaml yaml" came up with:

              http://whytheluckystiff.net/syck/

              The page title mentions OCaml, but there's not much in the body to
              indicate that OCaml is supported.

              There was discussion on one of the OCaml mailing lists about it too,
              but I can't find that right now ...

              Rich.

              --
              Richard Jones, CTO Merjis Ltd.
              Merjis - web marketing and technology - http://merjis.com
              Team Notepad - intranets and extranets for business - http://team-notepad.com
            Your message has been successfully submitted and would be delivered to recipients shortly.