blob: 3b43435e4f96f79832895e842a29765b0b6e2fb0 [file] [log] [blame]
François Degros899487c2019-07-12 11:57:52 +10001// Copyright 2019 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "cros-disks/quote.h"
6
7#include <iomanip>
8
9namespace cros_disks {
10
François Degrosca450862021-01-14 14:40:02 +110011static const char kRedacted[] = "(redacted)";
12
François Degros899487c2019-07-12 11:57:52 +100013std::ostream& operator<<(std::ostream& out, Quoter<const char*> quoter) {
14 const char* const s = quoter.ref;
François Degrosca450862021-01-14 14:40:02 +110015 if (!s)
16 return out << "(null)";
17
18 if (quoter.redacted)
19 return out << kRedacted;
20
21 return out << std::quoted(s, '\'');
François Degros899487c2019-07-12 11:57:52 +100022}
23
24std::ostream& operator<<(std::ostream& out, Quoter<std::string> quoter) {
François Degrosca450862021-01-14 14:40:02 +110025 if (quoter.redacted)
26 return out << kRedacted;
27
François Degros899487c2019-07-12 11:57:52 +100028 return out << std::quoted(quoter.ref, '\'');
29}
30
31std::ostream& operator<<(std::ostream& out, Quoter<base::FilePath> quoter) {
François Degrosca450862021-01-14 14:40:02 +110032 if (quoter.redacted)
33 return out << kRedacted;
34
François Degros899487c2019-07-12 11:57:52 +100035 return out << std::quoted(quoter.ref.value(), '\'');
36}
37
38} // namespace cros_disks