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 41 of file FileLineInfo.h.

Member Function Documentation

◆ addInfo() [1/3]

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 35 of file FileLineInfo.C.

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

36 {
37  FileLineInfo f(file, line);
38  if (f.isValid())
39  _map[key0] = f;
40 }
std::map< std::string, FileLineInfo > _map
Definition: FileLineInfo.h:112
Holds file and line information.
Definition: FileLineInfo.h:19

◆ addInfo() [2/3]

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 43 of file FileLineInfo.C.

47 {
48  addInfo(makeKey(key0, key1), file, line);
49 }
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
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Definition: FileLineInfo.C:35

◆ addInfo() [3/3]

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 52 of file FileLineInfo.C.

57 {
58  addInfo(makeKey(key0, key1, key2), file, line);
59 }
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
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
Definition: FileLineInfo.C:35

◆ getInfo() [1/3]

FileLineInfo FileLineInfoMap::getInfo ( const std::string &  key0) const

Get file/line info for a key.

Parameters
key0Key
Returns
FileLineInfo

Definition at line 76 of file FileLineInfo.C.

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

77 {
78  auto it = _map.find(key0);
79  if (it == _map.end())
80  return FileLineInfo();
81  return it->second;
82 }
std::map< std::string, FileLineInfo > _map
Definition: FileLineInfo.h:112
Holds file and line information.
Definition: FileLineInfo.h:19

◆ getInfo() [2/3]

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 85 of file FileLineInfo.C.

86 {
87  return getInfo(makeKey(key0, key1));
88 }
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
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Definition: FileLineInfo.C:76

◆ getInfo() [3/3]

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 91 of file FileLineInfo.C.

94 {
95  return getInfo(makeKey(key0, key1, key2));
96 }
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
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Definition: FileLineInfo.C:76

◆ makeKey() [1/2]

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 62 of file FileLineInfo.C.

Referenced by addInfo(), and getInfo().

63 {
64  return key0 + "%" + key1;
65 }

◆ makeKey() [2/2]

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 68 of file FileLineInfo.C.

71 {
72  return key0 + "%" + key1 + "%" + key2;
73 }

Member Data Documentation

◆ _map

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

Definition at line 112 of file FileLineInfo.h.

Referenced by addInfo(), and getInfo().


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