Public Member Functions

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_FILE_Parser::~TAO_FILE_Parser ( void   )  [virtual]

The destructor.

Definition at line 24 of file FILE_Parser.cpp.

{
}


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.

{
  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;
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines