[omniORB] Non-NULL terminated strings

Duncan Grisby duncan at grisby.org
Sat Apr 19 20:59:37 BST 2008


On Thursday 17 April, David wrote:

> How would I represent a non-NULL terminated string in the best way? In the
> C++ codebase I'm working with, those kinds of strings are represented with a
> char * and a length field, put together in a struct. Unfortunately, omniidl
> seems to map the string type to a char *, and not a C++ string. This means
> that the IDL string datatype cannot be used for strings containing NULLs.

That is the standard C++ mapping of CORBA strings. It's not omniidl's
decision. The CORBA core standard says that CORBA strings may not
contain nulls, so it's not just a language mapping issue.

> The spontaneous workaround was to do this in IDL:
> 
> typedef sequence<char> StringData;
> 
> Will this be incredibly inefficient?

It will certainly be pretty inefficient, because the code set conversion
framework will look at each character individually to see if it needs
conversion. You would probably be better off with a sequence<octet>,
which is just sent uninterpreted and is thus the fastest way of sending
data from one side to the other.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list