Common printing functions for the Nix language. More...
Go to the source code of this file.
Classes | |
class | nix::ValuePrinter |
Functions | |
std::ostream & | nix::printLiteralString (std::ostream &str, const std::string_view string) |
std::ostream & | nix::printLiteralString (std::ostream &o, const char *s) |
std::ostream & | nix::printLiteralString (std::ostream &o, const std::string &s) |
std::ostream & | nix::printLiteralBool (std::ostream &str, bool boolean) |
std::ostream & | nix::printAttributeName (std::ostream &str, std::string_view name) |
bool | nix::isReservedKeyword (const std::string_view str) |
std::ostream & | nix::printIdentifier (std::ostream &str, std::string_view s) |
void | nix::printValue (EvalState &state, std::ostream &output, Value &v, PrintOptions options) |
std::ostream & | nix::operator<< (std::ostream &output, const ValuePrinter &printer) |
Common printing functions for the Nix language.
While most types come with their own methods for printing, they share some functions that are placed here.
bool nix::isReservedKeyword | ( | const std::string_view | str | ) |
Returns ‘true’ is a string is a reserved keyword which requires quotation when printing attribute set field names.
std::ostream & nix::operator<< | ( | std::ostream & | output, |
const ValuePrinter & | printer ) |
Print true
or false
. Print a string as an attribute name in the Nix expression language syntax.
Prints a quoted string if necessary. Returns ‘true’ is a string is a reserved keyword which requires quotation when printing attribute set field names. Print a string as an identifier in the Nix expression language syntax.
FIXME: "identifier" is ambiguous. Identifiers do not have a single textual representation. They can be used in variable references, let bindings, left-hand sides or attribute names in a select expression, or something else entirely, like JSON. Use one of the print*
functions instead. A partially-applied form of printValue
which can be formatted using <<
without allocating an intermediate string.
std::ostream & nix::printAttributeName | ( | std::ostream & | o, |
std::string_view | s ) |
Print a string as an attribute name in the Nix expression language syntax.
Prints a quoted string if necessary.
std::ostream & nix::printIdentifier | ( | std::ostream & | o, |
std::string_view | s ) |
Print a string as an identifier in the Nix expression language syntax.
FIXME: "identifier" is ambiguous. Identifiers do not have a single textual representation. They can be used in variable references, let bindings, left-hand sides or attribute names in a select expression, or something else entirely, like JSON. Use one of the print*
functions instead.
std::ostream & nix::printLiteralBool | ( | std::ostream & | o, |
bool | b ) |
Print true
or false
.
std::ostream & nix::printLiteralString | ( | std::ostream & | o, |
std::string_view | s ) |
Print a string as a Nix string literal.
Quotes and fairly minimal escaping are added.
o | The output stream to print to |
s | The logical string |