summaryrefslogtreecommitdiff
path: root/common/parser.hh
blob: 30cf02d0795919b18091f5724f6e834362ab0ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef __COMMON_PARSER_HH__
#define __COMMON_PARSER_HH__

#include "lines.hh"

namespace rtfl {

namespace tools {

struct CommonLineInfo
{
   char *fileName;
   int lineNo;
   int processId;
   char *completeLine;
};

class Parser: public LinesSink
{
private:
   char **splitEscaped (char *txt);
   void scanSplit (char *txt, int *numParts, char **parts);
   static void unquote (char *txt);
   void freeSplitEscaped (char **parts);

protected:
   char **split (char *txt, int maxNum);
   void freeSplit (char **parts);

   virtual void processCommand (CommonLineInfo *info, char *cmd, char *args)
      = 0;
   virtual void processVCommand (CommonLineInfo *info, const char *module,
                                 int majorVersion, int minorVersion,
                                 const char *cmd, char **args) = 0;

public:
   void setLinesSource (LinesSource *source);
   void processLine (char *line);
   void finish ();
   void timeout (int type);
};

} // namespace common

} // namespace rtfl

#endif // __COMMON_PARSER_HH__