bmv2
Designing your own switch target with bmv2
Loading...
Searching...
No Matches
source_info.h
Go to the documentation of this file.
1/* Copyright 2017 Cisco Systems, Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/*
17 * Andy Fingerhut (jafinger@cisco.com)
18 *
19 */
20
21#ifndef BM_BM_SIM_SOURCE_INFO_H_
22#define BM_BM_SIM_SOURCE_INFO_H_
23
27
28#include <string>
29
30namespace bm {
31
32class SourceInfo {
33 public:
34 SourceInfo(std::string filename, unsigned int line, unsigned int column,
35 std::string source_fragment)
36 : filename(filename), line(line), column(column),
37 source_fragment(source_fragment) {
38 init_to_string();
39 }
40
41 std::string get_filename() const { return filename; }
42 unsigned int get_line() const { return line; }
43 unsigned int get_column() const { return column; }
44 std::string get_source_fragment() const { return source_fragment; }
45 std::string to_string() const { return string_representation; }
46
47 private:
48 std::string filename;
49 unsigned int line;
50 unsigned int column;
51 std::string source_fragment;
52 std::string string_representation;
53
54 void init_to_string();
55};
56
57} // namespace bm
58
59#endif // BM_BM_SIM_SOURCE_INFO_H_