www.mooseframework.org
FileLineInfo.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include <string>
13 #include <map>
14 
19 {
20 public:
21  FileLineInfo();
22  FileLineInfo(const std::string & f, int l);
26  bool isValid() const;
27  int line() const;
28  std::string file() const;
29 
30 protected:
31  int _line;
32  std::string _file;
33 };
34 
41 {
42 public:
49  void addInfo(const std::string & key0, const std::string & file, int line);
50 
58  void
59  addInfo(const std::string & key0, const std::string & key1, const std::string & file, int line);
60 
69  void addInfo(const std::string & key0,
70  const std::string & key1,
71  const std::string & key2,
72  const std::string & file,
73  int line);
74 
80  FileLineInfo getInfo(const std::string & key0) const;
81 
88  FileLineInfo getInfo(const std::string & key0, const std::string & key1) const;
89 
98  getInfo(const std::string & key0, const std::string & key1, const std::string & key2) const;
99 
100 protected:
104  std::string makeKey(const std::string & key0, const std::string & key1) const;
105 
109  std::string
110  makeKey(const std::string & key0, const std::string & key1, const std::string & key2) const;
111  std::map<std::string, FileLineInfo> _map;
112 };
std::map< std::string, FileLineInfo > _map
Definition: FileLineInfo.h:111
std::string makeKey(const std::string &key0, const std::string &key1) const
Makes a unique key for the map given two strings.
Definition: FileLineInfo.C:62
int line() const
Definition: FileLineInfo.C:23
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Definition: FileLineInfo.C:76
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Definition: FileLineInfo.C:35
std::string _file
Definition: FileLineInfo.h:32
Holds file and line information.
Definition: FileLineInfo.h:18
std::string file() const
Definition: FileLineInfo.C:29
bool isValid() const
Definition: FileLineInfo.C:17
A mapping between a series of keys to a FileLineInfo.
Definition: FileLineInfo.h:40