TAO_FILE_Parser Class Reference

Implements the <file:> IOR format. More...

#include <FILE_Parser.h>

Inheritance diagram for TAO_FILE_Parser:

Inheritance graph
[legend]
Collaboration diagram for TAO_FILE_Parser:

Collaboration graph
[legend]
List of all members.

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)

Detailed Description

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.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_FILE_Parser::~TAO_FILE_Parser ( void   )  [virtual]

The destructor.

Definition at line 24 of file FILE_Parser.cpp.

00025 {
00026 }


Member Function Documentation

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 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:29 2010 for TAO by  doxygen 1.4.7