00001 #include "tao/PortableServer/PortableServer_WFunctions.h"
00002
00003 ACE_RCSID (PortableServer,
00004 PortableServer_WFunctions,
00005 "$Id: PortableServer_WFunctions.cpp 71473 2006-03-10 07:19:20Z jtc $")
00006
00007 #include "ace/OS_NS_string.h"
00008
00009 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00010
00011 namespace PortableServer
00012 {
00013 PortableServer::ObjectId *
00014 wstring_to_ObjectId (const CORBA::WChar *string)
00015 {
00016
00017
00018
00019
00020
00021 u_int string_length = ACE_OS::wslen (string);
00022
00023 CORBA::ULong buffer_size = string_length * sizeof (CORBA::WChar);
00024
00025
00026 CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size);
00027
00028
00029 ACE_OS::memcpy (buffer, string, buffer_size);
00030
00031
00032 PortableServer::ObjectId *id = 0;
00033 ACE_NEW_RETURN (id,
00034 PortableServer::ObjectId (buffer_size,
00035 buffer_size,
00036 buffer,
00037 1),
00038 0);
00039
00040 return id;
00041 }
00042
00043 CORBA::WChar *
00044 ObjectId_to_wstring (const PortableServer::ObjectId &id)
00045 {
00046
00047 CORBA::ULong string_length =
00048 id.length () / sizeof (CORBA::WChar);
00049
00050
00051
00052 if (id.length () % sizeof (CORBA::WChar))
00053 string_length++;
00054
00055
00056 CORBA::WChar* string = CORBA::wstring_alloc (string_length);
00057
00058
00059 ACE_OS::memcpy (string,
00060 id.get_buffer (),
00061 id.length ());
00062
00063
00064 string[string_length] = '\0';
00065
00066
00067 return string;
00068 }
00069 }
00070
00071 TAO_END_VERSIONED_NAMESPACE_DECL