HOPS
HOPS class reference
MHO_VexBlockParser.hh
Go to the documentation of this file.
1 #ifndef MHO_VexBlockParser_HH__
2 #define MHO_VexBlockParser_HH__
3 
4 #include <list>
5 #include <sstream>
6 #include <stack>
7 #include <string>
8 #include <vector>
9 
11 #include "MHO_JSONHeaderWrapper.hh"
12 #include "MHO_Message.hh"
13 #include "MHO_Tokenizer.hh"
14 
15 #include "MHO_VexDefinitions.hh"
16 #include "MHO_VexLine.hh"
17 #include "MHO_VexTokenProcessor.hh"
18 
19 namespace hops
20 {
21 
34 {
35  public:
37  virtual ~MHO_VexBlockParser();
38 
44  void SetFormatDirectory(std::string fdir) { fFormatDirectory = fdir; }
45 
53  mho_json ParseBlockLines(std::string block_name, const std::vector< MHO_VexLine >* block_lines);
54 
55  private:
61  void LoadBlockFormat(std::string block_name);
62 
69  std::string GetBlockFormatFileName(std::string block_name);
70 
76  mho_json ParseBlock();
77 
83  mho_json ParseGlobalBlock();
84 
91  bool IsStartTag(const MHO_VexLine& line);
92 
99  bool IsStopTag(const MHO_VexLine& line);
100 
107  bool IsReferenceTag(const MHO_VexLine& line);
108 
118  bool ProcessStartTag(const MHO_VexLine& line, std::stack< std::string >& path, std::stack< mho_json* >& file_node,
119  std::stack< mho_json >& format_node);
120 
130  bool ProcessStopTag(const MHO_VexLine& line, std::stack< std::string >& path, std::stack< mho_json* >& file_node,
131  std::stack< mho_json >& format_node);
132 
142  bool ProcessLine(const MHO_VexLine& line, std::stack< std::string >& path, mho_json* file_node, mho_json& format_node);
143 
153  bool ProcessReference(const MHO_VexLine& line, std::stack< std::string >& path, mho_json* file_node,
154  mho_json& format_node);
155 
164  mho_json ProcessTokens(const std::string& element_name, mho_json& format, std::vector< std::string >& tokens);
173  mho_json ProcessCompound(const std::string& element_name, mho_json& format, std::vector< std::string >& tokens);
174 
182  bool MatchesType(const std::string& token, const std::string& type_name);
183 
184  bool fBlockFormatLoaded;
185  mho_json fBlockFormat;
186  std::string fBlockName;
187  std::string fFormatDirectory;
188  const std::vector< MHO_VexLine >* fBlockLines;
189  std::size_t fCurrentLineNumber;
190 
191  std::string fStartTag;
192  std::string fStopTag;
193 
194  MHO_Tokenizer fTokenizer;
195  MHO_VexTokenProcessor fTokenProcessor;
196 };
197 
198 } // namespace hops
199 
200 #endif
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
Class MHO_Tokenizer.
Definition: MHO_Tokenizer.hh:24
Class MHO_VexBlockParser.
Definition: MHO_VexBlockParser.hh:34
virtual ~MHO_VexBlockParser()
Definition: MHO_VexBlockParser.cc:19
void SetFormatDirectory(std::string fdir)
Setter for format directory.
Definition: MHO_VexBlockParser.hh:44
mho_json ParseBlockLines(std::string block_name, const std::vector< MHO_VexLine > *block_lines)
Parses block lines and returns a JSON object based on block type.
Definition: MHO_VexBlockParser.cc:56
MHO_VexBlockParser()
Definition: MHO_VexBlockParser.cc:11
Class MHO_VexTokenProcessor.
Definition: MHO_VexTokenProcessor.hh:27
Definition: MHO_ChannelLabeler.hh:17
Class MHO_VexLine.
Definition: MHO_VexLine.hh:21
struct token_struct * tokens
Definition: parse_control_file.c:26