forked from lix-project/lix
printLiteral: Do not overload
This commit is contained in:
parent
9c74df5bb4
commit
1e2dd669bc
|
@ -913,13 +913,13 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
|
||||||
|
|
||||||
case nBool:
|
case nBool:
|
||||||
str << ANSI_CYAN;
|
str << ANSI_CYAN;
|
||||||
printLiteral(str, v.boolean);
|
printLiteralBool(str, v.boolean);
|
||||||
str << ANSI_NORMAL;
|
str << ANSI_NORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nString:
|
case nString:
|
||||||
str << ANSI_WARNING;
|
str << ANSI_WARNING;
|
||||||
printLiteral(str, v.string.s);
|
printLiteralString(str, v.string.s);
|
||||||
str << ANSI_NORMAL;
|
str << ANSI_NORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
|
||||||
if (isVarName(i.first))
|
if (isVarName(i.first))
|
||||||
str << i.first;
|
str << i.first;
|
||||||
else
|
else
|
||||||
printLiteral(str, i.first);
|
printLiteralString(str, i.first);
|
||||||
str << " = ";
|
str << " = ";
|
||||||
if (seen.count(i.second))
|
if (seen.count(i.second))
|
||||||
str << "«repeated»";
|
str << "«repeated»";
|
||||||
|
|
|
@ -105,10 +105,10 @@ void Value::print(const SymbolTable & symbols, std::ostream & str,
|
||||||
str << integer;
|
str << integer;
|
||||||
break;
|
break;
|
||||||
case tBool:
|
case tBool:
|
||||||
printLiteral(str, boolean);
|
printLiteralBool(str, boolean);
|
||||||
break;
|
break;
|
||||||
case tString:
|
case tString:
|
||||||
printLiteral(str, string.s);
|
printLiteralString(str, string.s);
|
||||||
break;
|
break;
|
||||||
case tPath:
|
case tPath:
|
||||||
str << path; // !!! escaping?
|
str << path; // !!! escaping?
|
||||||
|
|
|
@ -74,7 +74,7 @@ std::ostream & operator <<(std::ostream & str, const SymbolStr & symbol)
|
||||||
else {
|
else {
|
||||||
char c = s[0];
|
char c = s[0];
|
||||||
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')) {
|
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')) {
|
||||||
printLiteral(str, s);
|
printLiteralString(str, s);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
for (auto c : s)
|
for (auto c : s)
|
||||||
|
@ -82,7 +82,7 @@ std::ostream & operator <<(std::ostream & str, const SymbolStr & symbol)
|
||||||
(c >= 'A' && c <= 'Z') ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
(c >= '0' && c <= '9') ||
|
(c >= '0' && c <= '9') ||
|
||||||
c == '_' || c == '\'' || c == '-')) {
|
c == '_' || c == '\'' || c == '-')) {
|
||||||
printLiteral(str, s);
|
printLiteralString(str, s);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
str << s;
|
str << s;
|
||||||
|
@ -107,7 +107,7 @@ void ExprFloat::show(const SymbolTable & symbols, std::ostream & str) const
|
||||||
|
|
||||||
void ExprString::show(const SymbolTable & symbols, std::ostream & str) const
|
void ExprString::show(const SymbolTable & symbols, std::ostream & str) const
|
||||||
{
|
{
|
||||||
printLiteral(str, s);
|
printLiteralString(str, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprPath::show(const SymbolTable & symbols, std::ostream & str) const
|
void ExprPath::show(const SymbolTable & symbols, std::ostream & str) const
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::ostream &
|
std::ostream &
|
||||||
printLiteral(std::ostream & str, const std::string_view string)
|
printLiteralString(std::ostream & str, const std::string_view string)
|
||||||
{
|
{
|
||||||
str << "\"";
|
str << "\"";
|
||||||
for (auto i = string.begin(); i != string.end(); ++i) {
|
for (auto i = string.begin(); i != string.end(); ++i) {
|
||||||
|
@ -19,7 +19,7 @@ printLiteral(std::ostream & str, const std::string_view string)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &
|
std::ostream &
|
||||||
printLiteral(std::ostream & str, bool boolean)
|
printLiteralBool(std::ostream & str, bool boolean)
|
||||||
{
|
{
|
||||||
str << (boolean ? "true" : "false");
|
str << (boolean ? "true" : "false");
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -17,14 +17,14 @@ namespace nix {
|
||||||
*
|
*
|
||||||
* @param s The logical string
|
* @param s The logical string
|
||||||
*/
|
*/
|
||||||
std::ostream & printLiteral(std::ostream & o, std::string_view s);
|
std::ostream & printLiteralString(std::ostream & o, std::string_view s);
|
||||||
inline std::ostream & printLiteral(std::ostream & o, const char * s) {
|
inline std::ostream & printLiteralString(std::ostream & o, const char * s) {
|
||||||
return printLiteral(o, std::string_view(s));
|
return printLiteralString(o, std::string_view(s));
|
||||||
}
|
}
|
||||||
inline std::ostream & printLiteral(std::ostream & o, const std::string & s) {
|
inline std::ostream & printLiteralString(std::ostream & o, const std::string & s) {
|
||||||
return printLiteral(o, std::string_view(s));
|
return printLiteralString(o, std::string_view(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print `true` or `false`. */
|
/** Print `true` or `false`. */
|
||||||
std::ostream & printLiteral(std::ostream & o, bool b);
|
std::ostream & printLiteralBool(std::ostream & o, bool b);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue