[xsd-users] Bug in ACE CDR deserialization

Boris Kolpackov boris at codesynthesis.com
Wed Jul 25 11:22:29 EDT 2007


Hi James,

James Frullo <jamesfrullo at gmail.com> writes:

> Hi Boris.  Actually, the function ACE::strdelete() does exist; it's not
> something I just made up.

I stand corrected. It is strange I couldn't find it in the ACE source
code earlier today.


> Calling ACE::strdelete() in line like that is certainly ugly.  That's why I
> suggested adding a special auto ptr class for ACE strings, like this:

Actually, this is not necessary: auto_array allows you to provide
a custom deallocator object. I've made the necessary changes in
ace-cdr-stream-extraction.hxx. The relevant part is attached at
the end of this email. Pleas let me know if it does not fix your
problem.


> By the way, this is a great feature to be able to do binary serialization.
> This makes the tool much more useful.

Thanks, I am glad you find it useful. BTW, we have implemented support
for serializing to XDR for the next release. The also works with 2.3.1.
Let me know if you would like to try it.

thanks,
-boris

      // Extraction of std::basic_string.
      //

      namespace bits
      {
        template<typename C>
        struct ace_str_deallocator
        {
          void
          deallocate (C* s)
          {
            ACE::strdelete (s);
          }
        };
      }

      inline istream<ACE_InputCDR>&
      operator>> (istream<ACE_InputCDR>& s, std::basic_string<char>& x)
      {
        typedef bits::ace_str_deallocator<char> deallocator;

        deallocator d;
        char* r;

        if (!s.impl ().read_string (r))
          throw ace_cdr_stream_extraction ();

        auto_array<char, deallocator> ar (r, d);

        x = r;

        return s;
      }

      inline istream<ACE_InputCDR>&
      operator>> (istream<ACE_InputCDR>& s, std::basic_string<wchar_t>& x)
      {
        typedef bits::ace_str_deallocator<wchar_t> deallocator;

        deallocator d;
        wchar_t* r;

        if (!s.impl ().read_wstring (r))
          throw ace_cdr_stream_extraction ();

        auto_array<wchar_t, deallocator> ar (r, d);

        x = r;

        return s;
      }




More information about the xsd-users mailing list