Version: 8.3.0
YACS::YACSLoader Class Reference

#include <parsers.hxx>

Inheritance diagram for YACS::YACSLoader:
Collaboration diagram for YACS::YACSLoader:

Public Member Functions

 YACSLoader ()
 
virtual ~YACSLoader ()
 
virtual YACS::ENGINE::Procload (const char *filename)
 
void registerProcCataLoader ()
 

Protected Attributes

std::map< std::string, parser * > _defaultParsersMap
 

Detailed Description

Definition at line 35 of file parsers.hxx.

Constructor & Destructor Documentation

YACS::YACSLoader::YACSLoader ( )

Definition at line 51 of file parsers.cxx.

References _defaultParsersMap, and YACS::ENGINE::getRuntime().

Referenced by main().

52 {
53  _defaultParsersMap.clear();
55 }
YACS::YACSLoader::~YACSLoader ( )
virtual

Definition at line 146 of file parsers.cxx.

147 {
148 }

Member Function Documentation

ENGINE::Proc * YACS::YACSLoader::load ( const char *  filename)
virtual

Reimplemented in YACS::HMI::YACSGuiLoader.

Definition at line 63 of file parsers.cxx.

References _defaultParsersMap, YACS::parser::_file, YACS::parser::_stackParser, YACS::parser::cdata_block(), YACS::parser::characters(), YACS::parser::comment(), currentProc, DEBTRACE, YACS::parser::end_document(), YACS::parser::end_element(), YACS::parser::error(), YACS::ENGINE::Logger::fatal(), YACS::parser::fatal_error(), YACS::ENGINE::Proc::getLogger(), YACS::parser::init(), YACS::parser::main_parser, YACS::roottypeParser::rootParser, saxContext, YACS::roottypeParser::setDefaultMap(), YACS::parser::SetUserDataAndPush(), YACS::parser::start_document(), YACS::parser::start_element(), YACS::parser::warning(), and YACS::Exception::what().

Referenced by driverTest(), YACS::HMI::YACSGuiLoader::load(), YACS::ENGINE::ProcCataLoader::loadCata(), and main().

64 {
65  DEBTRACE("YACSLoader::load: " << file);
68  xmlSAXHandler baseHandler =
69  {
70  0, // internal_subset,
71  0, // isStandalone
72  0, // hasInternalSubset
73  0, // hasExternalSubset
74  0, // resolveEntity
75  0, // getEntity
76  0, // entityDecl
77  0, // notationDecl
78  0, // attributeDecl
79  0, // elementDecl
80  0, // unparsedEntityDecl
81  0, // setDocumentLocator
82  parser::start_document, // startDocument
83  parser::end_document, // endDocument
84  parser::start_element, // startElement
85  parser::end_element, // endElement
86  0, // reference
87  parser::characters, // characters
88  0, // ignorableWhitespace
89  0, // processingInstruction
90  parser::comment, // comment
91  parser::warning, // warning
92  parser::error, // error
93  parser::fatal_error, // fatalError
94  0, // getParameterEntity
95  parser::cdata_block, // cdataBlock
96  0 // externalSubset
97  };
98 
99  FILE* fin=fopen(file,"r");
100  if (! fin)
101  {
102  std::cerr << "Couldn't open schema file" << std::endl;
103  throw std::invalid_argument("Couldn't open schema file");
104  }
105 
106  saxContext = xmlCreateFileParserCtxt(file);
107 
108  if (!saxContext)
109  {
110  std::cerr << "Couldn't allocate memory for parser" << std::endl;
111  throw Exception("Couldn't allocate memory for parser");
112  }
113  saxContext->sax = &baseHandler;
115  if ( !_defaultParsersMap.empty() )
117  else
119 
120  parser::main_parser._file = file;
121  currentProc = 0;
122 
123  try
124  {
125  if ( xmlParseDocument(saxContext) == -1 )
126  {
127  if(!currentProc)
128  throw Exception("Basic error during parsing.");
129  YACS::ENGINE::Logger* logger = currentProc->getLogger("parser");
130  logger->fatal( saxContext->lastError.message, file, saxContext->input->line );
131  }
132  saxContext = 0;
133  return currentProc;
134  }
135  catch(Exception& e)
136  {
137  if(!currentProc)
138  throw e;
139  YACS::ENGINE::Logger* logger = currentProc->getLogger("parser");
140  logger->fatal(e.what(), file, saxContext->input->line);
141  saxContext = 0;
142  return currentProc;
143  }
144 }
void YACS::YACSLoader::registerProcCataLoader ( )

Definition at line 57 of file parsers.cxx.

References YACS::ENGINE::Runtime::setCatalogLoaderFactory().

58 {
60  theRuntime->setCatalogLoaderFactory("proc",factory);
61 }

Member Data Documentation

std::map<std::string,parser*> YACS::YACSLoader::_defaultParsersMap
protected

The documentation for this class was generated from the following files: