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

Svcconf.cpp

Go to the documentation of this file.
00001 // $Id: Svcconf.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 
00004 #include "Svcconf.h"
00005 #include "ACEXML/common/FileCharStream.h"
00006 #include "ACEXML/common/StrCharStream.h"
00007 #include "ACEXML/parser/parser/Parser.h"
00008 
00009 #if (ACE_USES_CLASSIC_SVC_CONF == 0)
00010 
00011 extern "C" ACE_Proper_Export_Flag ACE_XML_Svc_Conf *
00012 _ACEXML_create_XML_Svc_Conf_Object (void)
00013 {
00014   ACE_XML_Svc_Conf *retp = 0;
00015 
00016   ACE_NEW_RETURN (retp,
00017                   ACEXML_Svcconf_Parser (),
00018                   0);
00019 
00020   return retp;
00021 }
00022 
00023 ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser ()
00024 {
00025   this->parser_.setContentHandler (&this->svcconf_handler_);
00026   this->parser_.setDTDHandler (&this->svcconf_handler_);
00027   this->parser_.setErrorHandler (&this->svcconf_handler_);
00028   this->parser_.setEntityResolver (&this->svcconf_handler_);
00029 }
00030 
00031 ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser ()
00032 {
00033 
00034 }
00035 
00036 void *
00037 ACEXML_Svcconf_Parser::operator new (size_t s)
00038 {
00039   return ::new char[s];
00040 }
00041 
00042 void
00043 ACEXML_Svcconf_Parser::operator delete (void *p)
00044 {
00045   delete[] (char*)p;
00046 }
00047 
00048 int
00049 ACEXML_Svcconf_Parser::parse_file (const ACE_TCHAR file[])
00050 {
00051   if (file == 0)
00052     ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: No filename specified\n"), -1);
00053 
00054   ACEXML_FileCharStream *fstm = 0;
00055   ACE_NEW_RETURN (fstm,
00056                   ACEXML_FileCharStream (),
00057                   1);
00058 
00059   if (fstm->open (file) != 0)
00060     ACE_ERROR_RETURN ((LM_ERROR,
00061                        ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"),
00062                        file),
00063                       -1);
00064 
00065   this->input_stream_.setCharStream (fstm);
00066 
00067   ACEXML_TRY_NEW_ENV
00068     {
00069       this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
00070       ACEXML_TRY_CHECK;
00071     }
00072   ACEXML_CATCH (ACEXML_SAXException, ex)
00073     {
00074       ex.print ();
00075       return -1;
00076     }
00077   ACEXML_ENDTRY;
00078   return 0;
00079 }
00080 
00081 
00082 int
00083 ACEXML_Svcconf_Parser::parse_string (const ACE_TCHAR str[])
00084 {
00085   if (str == 0)
00086     ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1);
00087 
00088   ACEXML_StrCharStream *stm = 0;
00089   ACE_NEW_RETURN (stm,
00090                   ACEXML_StrCharStream (str),
00091                   -1);
00092 
00093   this->input_stream_.setCharStream (stm);
00094   ACEXML_TRY_NEW_ENV
00095     {
00096       this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
00097       ACEXML_TRY_CHECK;
00098     }
00099   ACEXML_CATCH (ACEXML_SAXException, ex)
00100     {
00101       ex.print ();
00102       return -1;
00103     }
00104   ACEXML_ENDTRY;
00105   return 0;
00106 }
00107 
00108 #else
00109 
00110 #  if defined (_AIX) && \
00111      (defined (__IBMCPP__) && (__IBMCPP__ >= 500) && (__IBMCPP__ < 600))
00112 // This simply shuts up the AIX linker that complains there are no
00113 // csects or exported symbols when building with Visual Age C++ 5.
00114 extern "C" void ace_shut_up_aix_ld (void) {};
00115 #  endif /* AIX && __IBMCPP__ == 500 */
00116 
00117 #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */

Generated on Mon Jun 16 13:23:26 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002