aGrUM  0.16.0
DSLReader.h
Go to the documentation of this file.
1 
23 #ifndef DSLREADER_H
24 #define DSLREADER_H
25 
26 #include <agrum/BN/IBayesNet.h>
27 #include <agrum/BN/io/BNReader.h>
28 #include <agrum/agrum.h>
29 #include <iostream>
30 #include <string>
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 // including coco-generated PARSER and SCANNER
34 
35 # include <agrum/BN/io/DSL/cocoR/Parser.h>
36 #endif // DOXYGEN_SHOULD_SKIP_THIS
37 
38 namespace gum {
39  /* =========================================================================*/
40  /* === READERS === */
41  /* =========================================================================*/
51  template < typename GUM_SCALAR >
52  class DSLReader : public BNReader< GUM_SCALAR > {
53  public:
63  DSLReader(BayesNet< GUM_SCALAR >* bn, const std::string& filename);
64 
68  ~DSLReader() final;
69 
72  DSL::Scanner& scanner();
73 
75  const std::string& streamName() const;
76 
78  bool trace() const;
79  void trace(bool b);
80 
84  Size proceed() final;
85 
88 
90  Size errors();
92  Size warnings();
93 
95  Idx errLine(Idx i);
97  Idx errCol(Idx i);
99  bool errIsError(Idx i);
101  std::string errMsg(Idx i);
102 
104  void showElegantErrors(std::ostream& o = std::cerr);
105 
107  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
108 
110  void showErrorsAndWarnings(std::ostream& o = std::cerr);
111 
113  void showErrorCounts(std::ostream& o = std::cerr);
115 
116  protected:
119  DSL::Scanner* __scanner;
120  DSL::Parser* __parser;
121 
122  std::string __streamName;
125 
126  // a boolean to throw the ioerror not in the constructor but in the
127  // proceed()
128  bool __ioerror;
129  };
130 
131 
132 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
133  extern template class DSLReader< double >;
134 #endif
135 
136 } /* namespace gum */
137 
138 #include "DSLReader_tpl.h"
139 
140 #endif // DSLREADER_H
Class representing a Bayesian Network.
Definition: BayesNet.h:78
Size errors()
publishing Errors API
DSL::Parser * __parser
Definition: DSLReader.h:120
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
bool errIsError(Idx i)
type of ith error or warning
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Idx errLine(Idx i)
line of ith error or warning
Pure virtual class for reading a BN from a file.
Definition: BNReader.h:55
Pure virtual class for reading a BN from a file.
Definition: DSLReader.h:52
bool __traceScanning
Definition: DSLReader.h:123
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const std::string & streamName() const
name of readen file
std::string errMsg(Idx i)
message of ith error or warning
DSL::Scanner * __scanner
Definition: DSLReader.h:119
bool trace() const
accessor to trace function (just write the number of parser line)
~DSLReader() final
Default destructor.
std::string __streamName
Definition: DSLReader.h:122
void showErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
DSL::Scanner & scanner()
Direct access to DSL scanner (mandatory for listener connection)
bool __parseDone
Definition: DSLReader.h:124
Idx errCol(Idx i)
col of ith error or warning
Size proceed() final
parse.
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings with contents
Size Idx
Type for indexes.
Definition: types.h:53
BayesNet< GUM_SCALAR > * __bn
Definition: DSLReader.h:117
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Size warnings()
of errors
DSLReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename)
Constructor A reader is defined for reading a defined file.
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errorswith contents
A factory class to ease BayesNet construction.
Definition: BayesNet.h:45
BayesNetFactory< GUM_SCALAR > * __factory
Definition: DSLReader.h:118