Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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 Methods

 TAO_FILE_Parser (void)
 Constructor. More...

virtual ~TAO_FILE_Parser (void)
 The destructor. More...

virtual int match_prefix (const char *ior_string) const
 Return 1 if <ior_string> starts with a prefix known to this IOR parser. More...

virtual CORBA::Object_ptr parse_string (const char *ior, CORBA::ORB_ptr orb ACE_ENV_ARG_DECL_NOT_USED) 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 34 of file FILE_Parser.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_FILE_Parser::TAO_FILE_Parser void   
 

Constructor.

Definition at line 4 of file FILE_Parser.i.

00005 {
00006 }

TAO_FILE_Parser::~TAO_FILE_Parser void    [virtual]
 

The destructor.

Definition at line 19 of file FILE_Parser.cpp.

00020 {
00021 }


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 26 of file FILE_Parser.cpp.

References file_prefix, and ACE_OS_String::strncmp.

00027 {
00028   return (ACE_OS::strncmp (ior_string,
00029                            ::file_prefix,
00030                            sizeof (::file_prefix) - 1) == 0);
00031 }

CORBA::Object_ptr TAO_FILE_Parser::parse_string const char *    ior,
CORBA::ORB_ptr orb    ACE_ENV_ARG_DECL_NOT_USED
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 34 of file FILE_Parser.cpp.

References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_ENDTRY, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, ACE_LIB_TEXT, ACE_RE_THROW, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRY, ACE_TRY_CHECK, ACE_Read_Buffer::alloc, ACE_OS::fopen, ACE_Allocator::free, and ACE_Read_Buffer::read.

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


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:15:02 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002