aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value/print.hh
blob: 31c94eb857e196a36eded04eda4f6d4a84e27caf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 & printLiteral(std::ostream & o, std::string_view s);
    inline std::ostream & printLiteral(std::ostream & o, const char * s) {
        return printLiteral(o, std::string_view(s));
    }
    inline std::ostream & printLiteral(std::ostream & o, const std::string & s) {
        return printLiteral(o, std::string_view(s));
    }

    /** Print `true` or `false`. */
    std::ostream & printLiteral(std::ostream & o, bool b);
}