| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef TOOLS_GN_OUTPUT_STREAM_H_ | |
| 6 #define TOOLS_GN_OUTPUT_STREAM_H_ | |
| 7 | |
| 8 class OutputStream { | |
| 9 public: | |
| 10 | |
| 11 | |
| 12 | |
| 13 OutputStream& WriteBuffer(const char* buf, size_t len); | |
| 14 OutputStream& WriteInt(int i); | |
| 15 | |
| 16 // Write a literal. | |
| 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); | |
| 20 } | |
| 21 | |
| 22 // Write a literal string. | |
| 23 OutputStream& Write(const std::string& str) { | |
| 24 return WriteBuffer(str.c_str(), str.size()); | |
| 25 } | |
| 26 | |
| 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); | |
| 36 | |
| 37 OutputStream& EndLine() { | |
| 38 return WriteBuffer("\n", 1); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 #endif // TOOLS_GN_OUTPUT_STREAM_H_ | |
| OLD | NEW |