LineParser.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018 New Eagle
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of New Eagle nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _NEW_EAGLE_LINEPARSER_H
36 #define _NEW_EAGLE_LINEPARSER_H
37 
38 #include <ros/ros.h>
39 
40 #include <string>
41 #include <exception>
42 #include <ctype.h>
43 
44 namespace NewEagle
45 {
46  class LineParserExceptionBase: public std::exception
47  {
48  };
49 
51  {
52  virtual const char* what() const throw()
53  {
54  return "Unexpected end of line.";
55  }
56  };
57 
59  {
60  virtual const char* what() const throw()
61  {
62  return "Nothing found in search space.";
63  }
64  };
65 
67  {
68  virtual const char* what() const throw()
69  {
70  return "Invalid character(s) search space.";
71  }
72  };
73 
75  {
78  READ_E = 2,
79  READ_SIGN = 3,
81  };
82 
83  class LineParser
84  {
85  public:
86  LineParser(const std::string &line);
87  ~LineParser();
88 
89  int32_t GetPosition();
90  std::string ReadCIdentifier();
91  std::string ReadCIdentifier(std::string fieldName);
92  uint32_t ReadUInt();
93  uint32_t ReadUInt(std::string fieldName);
94  void SeekSeparator(char separator);
95  char ReadNextChar(std::string fieldName);
96  int32_t ReadInt();
97  double ReadDouble();
98  double ReadDouble(std::string fieldName);
99  std::string ReadQuotedString();
100  uint32_t PeekUInt();
101 
102  private:
103  int32_t _position;
104  std::string _line;
105 
106  void SkipWhitespace();
107  bool AtEOL();
108  char ReadNextChar();
109  };
110 }
111 
112 #endif // _NEW_EAGLE_LINEPARSER_H
virtual const char * what() const
Definition: LineParser.h:68
Definition: Dbc.h:45
ReadDoubleState
Definition: LineParser.h:74
std::string _line
Definition: LineParser.h:104
virtual const char * what() const
Definition: LineParser.h:52
virtual const char * what() const
Definition: LineParser.h:60


dbc
Author(s): Ryan Borchert
autogenerated on Fri Mar 20 2020 03:31:33