Public Member Functions | Protected Attributes

ACEXML_Svcconf_Parser Class Reference

#include <Svcconf.h>

Inheritance diagram for ACEXML_Svcconf_Parser:
Inheritance graph
[legend]
Collaboration diagram for ACEXML_Svcconf_Parser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACEXML_Svcconf_Parser ()
virtual ~ACEXML_Svcconf_Parser ()
virtual int parse_file (const ACE_TCHAR file[])
virtual int parse_string (const ACE_TCHAR str[])

Protected Attributes

ACEXML_Parser parser_
ACEXML_Svcconf_Handler svcconf_handler_
ACEXML_InputSource input_stream_

Detailed Description

Definition at line 24 of file Svcconf.h.


Constructor & Destructor Documentation

ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser (  ) 

Definition at line 23 of file Svcconf.cpp.

{
  this->parser_.setContentHandler (&this->svcconf_handler_);
  this->parser_.setDTDHandler (&this->svcconf_handler_);
  this->parser_.setErrorHandler (&this->svcconf_handler_);
  this->parser_.setEntityResolver (&this->svcconf_handler_);
  ACEXML_TRY_NEW_ENV
    {
      this->parser_.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"),
                                0
                                ACEXML_ENV_ARG_PARAMETER);
      ACEXML_TRY_CHECK;
    }
  ACEXML_CATCH (ACEXML_SAXException, ex)
    {
      ex.print ();              // Can't do much except printing the error.
      return;
    }
  ACEXML_ENDTRY;
}

ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser (  )  [virtual]

Definition at line 44 of file Svcconf.cpp.

{

}


Member Function Documentation

int ACEXML_Svcconf_Parser::parse_file ( const ACE_TCHAR  file[]  )  [virtual]

Implements ACE_XML_Svc_Conf.

Definition at line 51 of file Svcconf.cpp.

{
  if (file == 0)
    ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: No filename specified\n"), -1);

  ACEXML_FileCharStream *fstm = 0;
  ACE_NEW_RETURN (fstm,
                  ACEXML_FileCharStream (),
                  1);

  if (fstm->open (file) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"),
                       file),
                      -1);

  this->input_stream_.setCharStream (fstm);

  ACEXML_TRY_NEW_ENV
    {
      this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
      ACEXML_TRY_CHECK;
    }
  ACEXML_CATCH (ACEXML_SAXException, ex)
    {
      ex.print ();
      return -1;
    }
  ACEXML_ENDTRY;
  return 0;
}

int ACEXML_Svcconf_Parser::parse_string ( const ACE_TCHAR  str[]  )  [virtual]

Implements ACE_XML_Svc_Conf.

Definition at line 85 of file Svcconf.cpp.

{
  if (str == 0)
    ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1);

  ACEXML_StrCharStream *stm = 0;
  ACE_NEW_RETURN (stm, ACEXML_StrCharStream, -1);
  if (stm->open (str, ACE_TEXT ("Svcconf")) < 0)
    ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Unable to create "
                       "input stream.\n"), -1);

  this->input_stream_.setCharStream (stm);
  ACEXML_TRY_NEW_ENV
    {
      this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
      ACEXML_TRY_CHECK;
    }
  ACEXML_CATCH (ACEXML_SAXException, ex)
    {
      // If there was a problem parsing the stream, set the errno
      // to EINVAL to indicate to upper levels that the stream was
      // invalid.
      ACE_OS::last_error (EINVAL);
      ex.print ();
      return -1;
    }
  ACEXML_ENDTRY;
  return 0;
}


Member Data Documentation

Definition at line 38 of file Svcconf.h.

Definition at line 36 of file Svcconf.h.

Definition at line 37 of file Svcconf.h.


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