Version: 9.12.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

◆ YACSLoader()

YACS::YACSLoader::YACSLoader ( )

Definition at line 51 of file parsers.cxx.

52 {
53  _defaultParsersMap.clear();
55 }
std::map< std::string, parser * > _defaultParsersMap
Definition: parsers.hxx:44
YACSLIBENGINE_EXPORT Runtime * getRuntime()
Definition: Runtime.cxx:61
YACS::ENGINE::Runtime * theRuntime
Definition: parsers.cxx:40

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

Referenced by main().

◆ ~YACSLoader()

YACS::YACSLoader::~YACSLoader ( )
virtual

Definition at line 146 of file parsers.cxx.

147 {
148 }

Member Function Documentation

◆ load()

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

Reimplemented in YACS::HMI::YACSGuiLoader.

Definition at line 63 of file parsers.cxx.

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 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:32
Class for logging error messages.
Definition: Logger.hxx:38
virtual void fatal(const std::string &message, const char *filename, int line)
Definition: Logger.cxx:55
virtual Logger * getLogger(const std::string &name)
Definition: Proc.cxx:431
YACS::ENGINE::Proc * currentProc
Definition: parserBase.cxx:30
_xmlParserCtxt * saxContext
Definition: parserBase.cxx:31
static void XMLCALL start_element(void *data, const xmlChar *name, const xmlChar **p)
Definition: parserBase.cxx:237
static void XMLCALL warning(void *data, const char *fmt,...)
Definition: parserBase.cxx:284
virtual void init()
Definition: parserBase.cxx:86
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
static std::stack< parser * > _stackParser
Definition: parserBase.hxx:42
static void XMLCALL fatal_error(void *data, const char *fmt,...)
Definition: parserBase.cxx:322
static void XMLCALL end_document(void *data)
Definition: parserBase.cxx:231
static void XMLCALL comment(void *data, const xmlChar *value)
Definition: parserBase.cxx:268
static parser main_parser
Definition: parserBase.hxx:41
static void XMLCALL error(void *data, const char *fmt,...)
Definition: parserBase.cxx:303
static void XMLCALL cdata_block(void *data, const xmlChar *value, int len)
Definition: parserBase.cxx:275
static void XMLCALL end_element(void *data, const xmlChar *name)
Definition: parserBase.cxx:247
std::string _file
Definition: parserBase.hxx:96
static void XMLCALL start_document(void *data)
Definition: parserBase.cxx:225
static void XMLCALL characters(void *data, const xmlChar *ch, int len)
Definition: parserBase.cxx:259
void setDefaultMap(std::map< std::string, parser * > *)
Definition: rootParser.cxx:61
static roottypeParser rootParser
Definition: rootParser.hxx:32

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 YACS::HMI::YACSGuiLoader::load(), and YACS::ENGINE::ProcCataLoader::loadCata().

◆ registerProcCataLoader()

void YACS::YACSLoader::registerProcCataLoader ( )

Definition at line 57 of file parsers.cxx.

58 {
60  theRuntime->setCatalogLoaderFactory("proc",factory);
61 }
virtual void setCatalogLoaderFactory(const std::string &name, CatalogLoader *factory)
Add a catalog loader factory to the map _catalogLoaderFactoryMap under the name name.
Definition: Runtime.cxx:305

References YACS::ENGINE::Runtime::setCatalogLoaderFactory(), and theRuntime.

Member Data Documentation

◆ _defaultParsersMap

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

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