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 int match_prefix (const char *ior_string) const
virtual CORBA::Object_ptr parse_string (const char *ior, CORBA::ORB_ptr orb) throw (CORBA::SystemException)

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 interepret the file as an IOR (that can be in any valid format).

Definition at line 38 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 25 of file FILE_Parser.cpp.

00026 {
00027 }


Member Function Documentation

int TAO_FILE_Parser::match_prefix const char *  ior_string  )  const [virtual]
 

Return 1 if ior_string starts with a prefix known to this IOR parser

Implements TAO_IOR_Parser.

Definition at line 31 of file FILE_Parser.cpp.

References file_prefix, and ACE_OS::strncmp().

00032 {
00033   return (ACE_OS::strncmp (ior_string,
00034                            ::file_prefix,
00035                            sizeof (::file_prefix) - 1) == 0);
00036 }

CORBA::Object_ptr TAO_FILE_Parser::parse_string const char *  ior,
CORBA::ORB_ptr  orb
throw (CORBA::SystemException) [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 39 of file FILE_Parser.cpp.

References CORBA::Object::_nil(), ACE_CATCHANY, ACE_CHECK_RETURN, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_RE_THROW, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRY, ACE_TRY_CHECK, ACE_Read_Buffer::alloc(), ACE_OS::fopen(), ACE_Allocator::free(), CORBA::Object_ptr, CORBA::ORB_ptr, and ACE_Read_Buffer::read().

00043 {
00044   // Skip the prefix, we know it is there because this method in only
00045   // called if <match_prefix> returns 1.
00046   const char *filename =
00047     ior + sizeof (::file_prefix)+1;
00048 
00049   FILE* file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename),
00050                               ACE_TEXT("r"));
00051 
00052   if (file == 0)
00053     return CORBA::Object::_nil ();
00054 
00055   ACE_Read_Buffer reader (file, 1);
00056 
00057   char* string = reader.read ();
00058 
00059   if (string == 0)
00060     return CORBA::Object::_nil ();
00061 
00062   CORBA::Object_ptr object = CORBA::Object::_nil ();
00063   ACE_TRY
00064     {
00065       object = orb->string_to_object (string ACE_ENV_ARG_PARAMETER);
00066       ACE_TRY_CHECK;
00067 
00068       reader.alloc ()->free (string);
00069     }
00070   ACE_CATCHANY
00071     {
00072       reader.alloc ()->free (string);
00073       ACE_RE_THROW;
00074     }
00075   ACE_ENDTRY;
00076   ACE_CHECK_RETURN (CORBA::Object::_nil ());
00077 
00078   return object;
00079 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:13:49 2006 for TAO by doxygen 1.3.6