www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FileLineInfoMap Class Reference

A mapping between a series of keys to a FileLineInfo. More...

#include <FileLineInfo.h>

Public Member Functions

void addInfo (const std::string &key0, const std::string &file, int line)
 Associate a key with file/line info. More...
 
void addInfo (const std::string &key0, const std::string &key1, const std::string &file, int line)
 Associate a key with file/line info. More...
 
void addInfo (const std::string &key0, const std::string &key1, const std::string &key2, const std::string &file, int line)
 Associate a key with file/line info. More...
 
FileLineInfo getInfo (const std::string &key0) const
 Get file/line info for a key. More...
 
FileLineInfo getInfo (const std::string &key0, const std::string &key1) const
 Get file/line info for a pair of keys. More...
 
FileLineInfo getInfo (const std::string &key0, const std::string &key1, const std::string &key2) const
 Get file/line info for a pair of keys. More...
 

Protected Member Functions

std::string makeKey (const std::string &key0, const std::string &key1) const
 Makes a unique key for the map given two strings. More...
 
std::string makeKey (const std::string &key0, const std::string &key1, const std::string &key2) const
 Makes a unique key given three strings. More...
 

Protected Attributes

std::map< std::string, FileLineInfo_map
 

Detailed Description

A mapping between a series of keys to a FileLineInfo.

This is intended to replace having a std::pair or a std::tuple as a key to a map holding the FileLineInfo.

Definition at line 46 of file FileLineInfo.h.

Member Function Documentation

void FileLineInfoMap::addInfo ( const std::string &  key0,
const std::string &  file,
int  line 
)

Associate a key with file/line info.

Parameters
key0Key
filefile
lineline number

Definition at line 40 of file FileLineInfo.C.

Referenced by ActionFactory::reg(), Factory::reg(), and Syntax::registerActionSyntax().

41 {
42  FileLineInfo f(file, line);
43  if (f.isValid())
44  _map[key0] = f;
45 }
std::map< std::string, FileLineInfo > _map
Definition: FileLineInfo.h:117
Holds file and line information.
Definition: FileLineInfo.h:24
void FileLineInfoMap::addInfo ( const std::string &  key0,
const std::string &  key1,
const std::string &  file,
int  line 
)

Associate a key with file/line info.

Parameters
key0Key
key1Key
filefile
lineline number

Definition at line 48 of file FileLineInfo.C.

52 {
53  addInfo(makeKey(key0, key1), file, line);
54 }
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:67
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Definition: FileLineInfo.C:40
void FileLineInfoMap::addInfo ( const std::string &  key0,
const std::string &  key1,
const std::string &  key2,
const std::string &  file,
int  line 
)

Associate a key with file/line info.

Parameters
key0Key
key1Key
key2Key
filefile
lineline number

Definition at line 57 of file FileLineInfo.C.

62 {
63  addInfo(makeKey(key0, key1, key2), file, line);
64 }
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:67
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Definition: FileLineInfo.C:40
FileLineInfo FileLineInfoMap::getInfo ( const std::string &  key0) const

Get file/line info for a key.

Parameters
key0Key
Returns
FileLineInfo

Definition at line 81 of file FileLineInfo.C.

Referenced by ActionFactory::getLineInfo(), Syntax::getLineInfo(), and Factory::getLineInfo().

82 {
83  auto it = _map.find(key0);
84  if (it == _map.end())
85  return FileLineInfo();
86  return it->second;
87 }
std::map< std::string, FileLineInfo > _map
Definition: FileLineInfo.h:117
Holds file and line information.
Definition: FileLineInfo.h:24
FileLineInfo FileLineInfoMap::getInfo ( const std::string &  key0,
const std::string &  key1 
) const

Get file/line info for a pair of keys.

Parameters
key0Key
key1Key
Returns
FileLineInfo

Definition at line 90 of file FileLineInfo.C.

91 {
92  return getInfo(makeKey(key0, key1));
93 }
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:67
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Definition: FileLineInfo.C:81
FileLineInfo FileLineInfoMap::getInfo ( const std::string &  key0,
const std::string &  key1,
const std::string &  key2 
) const

Get file/line info for a pair of keys.

Parameters
key0Key
key1Key
key2Key
Returns
FileLineInfo

Definition at line 96 of file FileLineInfo.C.

99 {
100  return getInfo(makeKey(key0, key1, key2));
101 }
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:67
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Definition: FileLineInfo.C:81
std::string FileLineInfoMap::makeKey ( const std::string &  key0,
const std::string &  key1 
) const
protected

Makes a unique key for the map given two strings.

Definition at line 67 of file FileLineInfo.C.

68 {
69  return key0 + "%" + key1;
70 }
std::string FileLineInfoMap::makeKey ( const std::string &  key0,
const std::string &  key1,
const std::string &  key2 
) const
protected

Makes a unique key given three strings.

Definition at line 73 of file FileLineInfo.C.

76 {
77  return key0 + "%" + key1 + "%" + key2;
78 }

Member Data Documentation

std::map<std::string, FileLineInfo> FileLineInfoMap::_map
protected

Definition at line 117 of file FileLineInfo.h.


The documentation for this class was generated from the following files: