1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 16:51:15 +02:00

libexpr/value/print.* -> libexpr/print.*

Generalizes the file to sensibly allow printing any part of the
language syntax.
This commit is contained in:
Robert Hensing 2023-04-16 13:10:45 +02:00
parent 1e2dd669bc
commit 28a5cdde02
5 changed files with 4 additions and 4 deletions

30
src/libexpr/print.hh Normal file
View file

@ -0,0 +1,30 @@
#pragma once
/**
* @file
* @brief 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.
*/
#include <iostream>
namespace nix {
/**
* Print a string as a Nix string literal.
*
* Quotes and fairly minimal escaping are added.
*
* @param s The logical string
*/
std::ostream & printLiteralString(std::ostream & o, std::string_view s);
inline std::ostream & printLiteralString(std::ostream & o, const char * s) {
return printLiteralString(o, std::string_view(s));
}
inline std::ostream & printLiteralString(std::ostream & o, const std::string & s) {
return printLiteralString(o, std::string_view(s));
}
/** Print `true` or `false`. */
std::ostream & printLiteralBool(std::ostream & o, bool b);
}