Implements the <file:> IOR format. More...
#include <FILE_Parser.h>
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) |
Implements the <file:> IOR format.
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_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.
{ return (ACE_OS::strncmp (ior_string, ::file_prefix, sizeof (::file_prefix) - 1) == 0); }
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.
{ // Skip the prefix, we know it is there because this method in only // called if <match_prefix> returns 1. const char *filename = ior + sizeof (::file_prefix)+1; FILE* file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename), ACE_TEXT("r")); if (file == 0) return CORBA::Object::_nil (); ACE_Read_Buffer reader (file, true); char* string = reader.read (); if (string == 0) return CORBA::Object::_nil (); CORBA::Object_ptr object = CORBA::Object::_nil (); try { object = orb->string_to_object (string); reader.alloc ()->free (string); } catch (const ::CORBA::Exception&) { reader.alloc ()->free (string); throw; } return object; }