2 #include "tao/PortableServer/PortableServer_Functions.h"
3 #include "ace/OS_NS_string.h"
6 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 namespace PortableServer
10 PortableServer::ObjectId
*
11 string_to_ObjectId (const char *string
)
13 // Passing in a nil pointer is illegal so throw an exception to
17 throw ::CORBA::BAD_PARAM ();
22 // We DO NOT include the zero terminator, as this is simply an
23 // artifact of the way strings are stored in C.
25 CORBA::ULong buffer_size
= static_cast <CORBA::ULong
>
26 (std::strlen (string
));
28 // Create the buffer for the Id
29 CORBA::Octet
*buffer
= PortableServer::ObjectId::allocbuf (buffer_size
);
32 ACE_OS::memcpy (buffer
, string
, buffer_size
);
34 // Create and return a new ID
35 PortableServer::ObjectId
*id
= 0;
37 PortableServer::ObjectId (buffer_size
,
47 ObjectId_to_string (const PortableServer::ObjectId
&id
)
50 char * string
= CORBA::string_alloc (id
.length ());
53 ACE_OS::memcpy (string
, id
.get_buffer (), id
.length ());
55 // Null terminate the string
56 string
[id
.length ()] = '\0';
64 TAO_END_VERSIONED_NAMESPACE_DECL