meteo-vm2  2.0.11
parser.h
Go to the documentation of this file.
1 /*
2  * parser - Parse VM2 files
3  *
4  * Copyright (C) 2012,2013 Arpae-SIMC <simc-urp@arpae.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Author: Emanuele Di Giacomo <edigiacomo@arpae.it>
21  */
22 #ifndef METEO_VM2_PARSER_H
23 #define METEO_VM2_PARSER_H
30 #include <string>
31 #include <vector>
32 #include <istream>
33 #include <ostream>
34 #include <stdexcept>
35 
36 #include <meteo-vm2/value.h>
37 
38 namespace meteo {
39 namespace vm2 {
40 
41 
45 class ParserException : public std::runtime_error {
46 public:
47  ParserException(int lineno, const std::string& msg);
48 };
49 
50 
54 struct Parser {
56  static std::string regexp_str;
58  std::istream& in;
60  int lineno;
61 
63  Parser(std::istream& in);
64  virtual ~Parser();
65 
67  bool next(Value& value);
68 
70  bool next(Value& value, std::string& raw);
71 
73  static void serialize(std::ostream& out, const Value& value);
74 };
75 
76 }
77 }
78 
79 #endif /* METEO_VM2_PARSER_H */
int lineno
Number of the last line parsed.
Definition: parser.h:60
std::istream & in
Input stream.
Definition: parser.h:58
static void serialize(std::ostream &out, const Value &value)
Serialize a value.
Definition: parser.cc:151
bool next(Value &value)
Read the next VM2 value.
Definition: parser.cc:91
static std::string regexp_str
Pattern of a VM2 value.
Definition: parser.h:56
Parser(std::istream &in)
Create a stdin parser.
Definition: parser.cc:88
Value class.