1 #include "tao/PortableServer/PortableServer_WFunctions.h"
3 #include "ace/OS_NS_string.h"
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
7 namespace PortableServer
9 PortableServer::ObjectId
*
10 wstring_to_ObjectId (const CORBA::WChar
*string
)
14 // We DO NOT include the zero terminator, as this is simply an
15 // artifact of the way strings are stored in C.
17 u_int string_length
= ACE_OS::wslen (string
);
19 CORBA::ULong buffer_size
= string_length
* sizeof (CORBA::WChar
);
21 // Create the buffer for the Id
22 CORBA::Octet
*buffer
= PortableServer::ObjectId::allocbuf (buffer_size
);
25 ACE_OS::memcpy (buffer
, string
, buffer_size
);
28 PortableServer::ObjectId
*id
= 0;
30 PortableServer::ObjectId (buffer_size
,
40 ObjectId_to_wstring (const PortableServer::ObjectId
&id
)
42 // Compute resulting wide string's length.
43 CORBA::ULong string_length
=
44 id
.length () / sizeof (CORBA::WChar
);
46 // Allocate an extra slot if the id's length is not "aligned" on a
48 if (id
.length () % sizeof (CORBA::WChar
))
51 // Create space - note that this method adds + 1 for the '\0'.
52 CORBA::WChar
* string
= CORBA::wstring_alloc (string_length
);
55 ACE_OS::memcpy (string
,
59 // Null terminate the string
60 string
[string_length
] = '\0';
67 TAO_END_VERSIONED_NAMESPACE_DECL