Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
print.hh
Go to the documentation of this file.
1#pragma once
9
10#include "nix/util/fmt.hh"
13
14#include <iosfwd>
15
16namespace nix {
17
18class EvalState;
19struct Value;
20
29std::ostream & printLiteralString(std::ostream & o, std::string_view s);
30
31inline std::ostream & printLiteralString(std::ostream & o, const char * s)
32{
33 return printLiteralString(o, std::string_view(s));
34}
35
36inline std::ostream & printLiteralString(std::ostream & o, const std::string & s)
37{
38 return printLiteralString(o, std::string_view(s));
39}
40
42std::ostream & printLiteralBool(std::ostream & o, bool b);
43
49std::ostream & printAttributeName(std::ostream & o, std::string_view s);
50
55bool isReservedKeyword(const std::string_view str);
56
66std::ostream & printIdentifier(std::ostream & o, std::string_view s);
67
68void printValue(
69 EvalState & state,
70 std::ostream & str,
71 Value & v,
72 PrintOptions options = PrintOptions{},
73 NixStringContext * context = nullptr);
74
79class ValuePrinter
80{
81 friend std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer);
82private:
83 EvalState & state;
84 Value & value;
85 PrintOptions options;
86 NixStringContext * context;
87
88public:
89 ValuePrinter(
90 EvalState & state, Value & value, PrintOptions options = PrintOptions{}, NixStringContext * context = nullptr)
91 : state(state)
92 , value(value)
93 , options(options)
94 , context(context)
95 {
96 }
97};
98
99std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer);
100
105template<>
106HintFmt & HintFmt::operator%(const ValuePrinter & value);
107
108} // namespace nix
Definition eval.hh:420
HintFmt(const std::string &literal)
Definition fmt.hh:178
Definition print.hh:80
std::set< NixStringContextElem > NixStringContext
Definition context.hh:103
Options for printing Nix values.
std::ostream & printLiteralString(std::ostream &o, std::string_view s)
Definition print.cc:66
std::ostream & printAttributeName(std::ostream &o, std::string_view s)
Definition print.cc:130
std::ostream & printIdentifier(std::ostream &o, std::string_view s)
Definition print.cc:91
std::ostream & printLiteralBool(std::ostream &o, bool b)
Definition print.cc:71
Definition print-options.hh:39
Definition value.hh:1166