#include <FILE_Parser.h>
Inheritance diagram for TAO_FILE_Parser:
Public Member Functions | |
virtual | ~TAO_FILE_Parser (void) |
The destructor. | |
virtual bool | match_prefix (const char *ior_string) const |
virtual CORBA::Object_ptr | parse_string (const char *ior, CORBA::ORB_ptr orb) |
This class implements the <file:> IOR format. It is dynamically loaded by the ORB and used to open a file, read its contents and then interprete the file as an IOR (that can be in any valid format).
Definition at line 40 of file FILE_Parser.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_FILE_Parser::~TAO_FILE_Parser | ( | void | ) | [virtual] |
bool TAO_FILE_Parser::match_prefix | ( | const char * | ior_string | ) | const [virtual] |
Return true if ior_string starts with a prefix known to this IOR parser
Implements TAO_IOR_Parser.
Definition at line 30 of file FILE_Parser.cpp.
References file_prefix, and ACE_OS::strncmp().
00031 { 00032 return (ACE_OS::strncmp (ior_string, 00033 ::file_prefix, 00034 sizeof (::file_prefix) - 1) == 0); 00035 }
CORBA::Object_ptr TAO_FILE_Parser::parse_string | ( | const char * | ior, | |
CORBA::ORB_ptr | orb | |||
) | [virtual] |
Parse the ior argument and return an object reference. The call may raise the standard system exceptions (NO_MEMORY, INV_OBJREF, etc.)
Implements TAO_IOR_Parser.
Definition at line 38 of file FILE_Parser.cpp.
References CORBA::Object::_nil(), ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_Read_Buffer::alloc(), file_prefix, ACE_OS::fopen(), ACE_Allocator::free(), ACE_Read_Buffer::read(), and CORBA::ORB::string_to_object().
00039 { 00040 // Skip the prefix, we know it is there because this method in only 00041 // called if <match_prefix> returns 1. 00042 const char *filename = 00043 ior + sizeof (::file_prefix)+1; 00044 00045 FILE* file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename), 00046 ACE_TEXT("r")); 00047 00048 if (file == 0) 00049 return CORBA::Object::_nil (); 00050 00051 ACE_Read_Buffer reader (file, true); 00052 00053 char* string = reader.read (); 00054 00055 if (string == 0) 00056 return CORBA::Object::_nil (); 00057 00058 CORBA::Object_ptr object = CORBA::Object::_nil (); 00059 try 00060 { 00061 object = orb->string_to_object (string); 00062 00063 reader.alloc ()->free (string); 00064 } 00065 catch (const ::CORBA::Exception&) 00066 { 00067 reader.alloc ()->free (string); 00068 throw; 00069 } 00070 00071 return object; 00072 }