PortableServer_Functions.cpp

Go to the documentation of this file.
00001 #include "tao/PortableServer/PortableServer_Functions.h"
00002 
00003 ACE_RCSID (PortableServer,
00004            PortableServer_Functions,
00005            "$Id: PortableServer_Functions.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   string_to_ObjectId (const char *string)
00015   {
00016     // Size of string
00017     //
00018     // We DO NOT include the zero terminator, as this is simply an
00019     // artifact of the way strings are stored in C.
00020     //
00021     CORBA::ULong buffer_size = static_cast <CORBA::ULong>
00022                                            (ACE_OS::strlen (string));
00023 
00024     // Create the buffer for the Id
00025     CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size);
00026 
00027     // Copy the contents
00028     ACE_OS::memcpy (buffer, string, buffer_size);
00029 
00030     // Create and return a new ID
00031     PortableServer::ObjectId *id = 0;
00032     ACE_NEW_RETURN (id,
00033                     PortableServer::ObjectId (buffer_size,
00034                                               buffer_size,
00035                                               buffer,
00036                                               1),
00037                     0);
00038 
00039     return id;
00040   }
00041 
00042   char *
00043   ObjectId_to_string (const PortableServer::ObjectId &id)
00044   {
00045     // Create space
00046     char * string = CORBA::string_alloc (id.length ());
00047 
00048     // Copy the data
00049     ACE_OS::memcpy (string, id.get_buffer (), id.length ());
00050 
00051     // Null terminate the string
00052     string[id.length ()] = '\0';
00053 
00054     // Return string
00055     return string;
00056   }
00057 }
00058 
00059 
00060 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7