1 // Copyright (c) 2013 The Chromium 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.
5 #ifndef TOOLS_GN_OUTPUT_STREAM_H_
6 #define TOOLS_GN_OUTPUT_STREAM_H_
13 OutputStream
& WriteBuffer(const char* buf
, size_t len
);
14 OutputStream
& WriteInt(int i
);
17 // This template expansion prevents having to look for nulls.
18 template<size_t size
> OutputStream
& Write(const char (&buf
)[size
]) {
19 return WriteBuffer(buf
, size
);
22 // Write a literal string.
23 OutputStream
& Write(const std::string
& str
) {
24 return WriteBuffer(str
.c_str(), str
.size());
27 // Quotes if necessary, and does necessary escaping. If more than one
28 // input is provided, the results will be concatenated together (useful
29 // for constructing paths without a temporary buffer).
30 OutputStream
& WritePath(const std::string
& s
);
31 OutputStream
& WritePath(const std::string
& s0
,
32 const std::string
& s1
);
33 OutputStream
& WritePath(const std::string
& s0
,
34 const std::string
& s1
,
35 const std::string
& s2
);
37 OutputStream
& EndLine() {
38 return WriteBuffer("\n", 1);
42 #endif // TOOLS_GN_OUTPUT_STREAM_H_