1 #include "tao/FILE_Parser.h"
3 #if (TAO_HAS_FILE_PARSER == 1)
6 #include "tao/Object.h"
8 #include "ace/Read_Buffer.h"
9 #include "ace/Malloc_Base.h"
10 #include "ace/Log_Msg.h"
11 #include "ace/OS_NS_stdio.h"
12 #include "ace/OS_NS_string.h"
14 static const char file_prefix
[] = "file:";
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 TAO_FILE_Parser::match_prefix (const char *ior_string
) const
21 return (ACE_OS::strncmp (ior_string
,
23 sizeof (::file_prefix
) - 1) == 0);
27 TAO_FILE_Parser::parse_string (const char *ior
, CORBA::ORB_ptr orb
)
29 // Skip the prefix, we know it is there because this method in only
30 // called if <match_prefix> returns 1.
31 const char *filename
=
32 ior
+ sizeof (::file_prefix
)+1;
34 FILE* file
= ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename
),
38 return CORBA::Object::_nil ();
40 ACE_Read_Buffer
reader (file
, true);
42 char* string
= reader
.read ();
44 if (string
== nullptr)
45 return CORBA::Object::_nil ();
47 CORBA::Object_ptr object
= CORBA::Object::_nil ();
50 object
= orb
->string_to_object (string
);
52 reader
.alloc ()->free (string
);
54 catch (const ::CORBA::Exception
&)
56 reader
.alloc ()->free (string
);
64 ACE_STATIC_SVC_DEFINE (TAO_FILE_Parser
,
65 ACE_TEXT ("FILE_Parser"),
67 &ACE_SVC_NAME (TAO_FILE_Parser
),
68 ACE_Service_Type::DELETE_THIS
|
69 ACE_Service_Type::DELETE_OBJ
,
72 ACE_FACTORY_DEFINE (TAO
, TAO_FILE_Parser
)
74 TAO_END_VERSIONED_NAMESPACE_DECL
76 #endif /* TAO_HAS_FILE_PARSER == 1 */