All Classes Namespaces Files Functions Enumerations Enumerator Friends Macros Pages
ParserUtils.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef MANIFOLD_RNDF_PARSERUTILS_HH_
19 #define MANIFOLD_RNDF_PARSERUTILS_HH_
20 
21 #include <iosfwd>
22 #include <string>
23 
24 #include "manifold/Helpers.hh"
25 #include "manifold/rndf/Lane.hh"
26 
27 namespace manifold
28 {
29  namespace rndf
30  {
31 
32  // Forward declarations.
33  class Checkpoint;
34  class Exit;
35  class UniqueId;
36 
40  static const std::string kRgxString = "[^[:space:]\\*\\\\]{1,128}";
41 
44  static const std::string kPositiveData =
45  "[1-9]|"
46  "[1-9][[:d:]]|"
47  "[1-9][[:d:]][[:d:]]|"
48  "[1-9][[:d:]][[:d:]][[:d:]]|"
49  "[1-2][[:d:]][[:d:]][[:d:]][[:d:]]|"
50  "3[0-1][[:d:]][[:d:]][[:d:]]|"
51  "32[0-6][[:d:]][[:d:]]|327[0-5][[:d:]]|3276[0-8]";
52 
55  static const std::string kRgxPositive = "(" + kPositiveData + ")";
56 
59  static const std::string kRgxNonNegative = "(0|" + kPositiveData + ")";
60 
62  static const std::string kRgxDouble = "(-?[0-9]*\\.?[0-9]+)";
63 
66  static const std::string kRgxUniqueId = kRgxPositive + "\\." +
67  kRgxNonNegative + "\\." + kRgxPositive;
68 
71  static const std::string kRgxComment = "\\/\\*[^\\*\\/]*\\*\\/";
72 
83  bool nextRealLine(std::ifstream &_rndfFile,
84  std::string &_line,
85  int &_lineNumber);
86 
101  bool parseString(std::ifstream &_rndfFile,
102  const std::string &_delimiter,
103  std::string &_value,
104  int &_lineNumber);
105 
117  bool parseDelimiter(std::ifstream &_rndfFile,
118  const std::string &_delimiter,
119  int &_lineNumber);
120 
134  bool parsePositive(std::ifstream &_rndfFile,
135  const std::string &_delimiter,
136  int &_value,
137  int &_lineNumber);
138 
152  bool parseNonNegative(std::ifstream &_rndfFile,
153  const std::string &_delimiter,
154  int &_value,
155  int &_lineNumber);
156 
168  bool parseNonNegative(const std::string &_input,
169  const std::string &_delimiter,
170  int &_value);
171 
184  bool parseBoundary(const std::string &_input,
185  Marking &_boundary);
186 
202  bool parseCheckpoint(const std::string &_input,
203  const int _segmentId,
204  const int _laneId,
205  Checkpoint &_checkpoint);
206 
220  bool parseStop(const std::string &_input,
221  const int _segmentId,
222  const int _laneId,
223  UniqueId &_stop);
224 
242  bool parseExit(const std::string &_input,
243  const int _segmentId,
244  const int _laneId,
245  Exit &_exit);
246  }
247 }
248 #endif
#define MANIFOLD_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:55
Marking
Definition: Lane.hh:39