2023-04-09 20:42:20 +00:00
|
|
|
#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
|
|
|
|
*/
|
2023-04-16 10:56:31 +00:00
|
|
|
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));
|
2023-04-09 20:42:20 +00:00
|
|
|
}
|
2023-04-16 10:56:31 +00:00
|
|
|
inline std::ostream & printLiteralString(std::ostream & o, const std::string & s) {
|
|
|
|
return printLiteralString(o, std::string_view(s));
|
2023-04-09 20:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Print `true` or `false`. */
|
2023-04-16 10:56:31 +00:00
|
|
|
std::ostream & printLiteralBool(std::ostream & o, bool b);
|
2023-04-09 20:42:20 +00:00
|
|
|
}
|