Create a new method to return string name or number to DRY code.
This commit is contained in:
parent
0718e45c24
commit
bb63bd5e37
3 changed files with 12 additions and 19 deletions
|
|
@ -190,6 +190,13 @@ inline const TString String(const int i, const int base = 10)
|
|||
|
||||
struct TSourceLoc {
|
||||
void init() { name = nullptr; string = 0; line = 0; column = 0; }
|
||||
// Returns the name if it exists. Otherwise, returns the string number.
|
||||
std::string getStringNameOrNum(bool quoteStringName = true) const
|
||||
{
|
||||
if (name != nullptr)
|
||||
return quoteStringName ? ("\"" + std::string(name) + "\"") : name;
|
||||
return std::to_string(string);
|
||||
}
|
||||
const char* name; // descriptive name for this string
|
||||
int string;
|
||||
int line;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue