OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OSTREAMS_H_ | 5 #ifndef V8_OSTREAMS_H_ |
6 #define V8_OSTREAMS_H_ | 6 #define V8_OSTREAMS_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <cstdio> | 9 #include <cstdio> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 struct AsReversiblyEscapedUC16 { | 59 struct AsReversiblyEscapedUC16 { |
60 explicit AsReversiblyEscapedUC16(uint16_t v) : value(v) {} | 60 explicit AsReversiblyEscapedUC16(uint16_t v) : value(v) {} |
61 uint16_t value; | 61 uint16_t value; |
62 }; | 62 }; |
63 | 63 |
64 struct AsEscapedUC16ForJSON { | 64 struct AsEscapedUC16ForJSON { |
65 explicit AsEscapedUC16ForJSON(uint16_t v) : value(v) {} | 65 explicit AsEscapedUC16ForJSON(uint16_t v) : value(v) {} |
66 uint16_t value; | 66 uint16_t value; |
67 }; | 67 }; |
68 | 68 |
| 69 struct AsHex { |
| 70 explicit AsHex(uint64_t v, uint8_t min_width = 0) |
| 71 : value(v), min_width(min_width) {} |
| 72 uint64_t value; |
| 73 uint8_t min_width; |
| 74 }; |
69 | 75 |
70 // Writes the given character to the output escaping everything outside of | 76 // Writes the given character to the output escaping everything outside of |
71 // printable/space ASCII range. Additionally escapes '\' making escaping | 77 // printable/space ASCII range. Additionally escapes '\' making escaping |
72 // reversible. | 78 // reversible. |
73 std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c); | 79 std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c); |
74 | 80 |
75 // Same as AsReversiblyEscapedUC16 with additional escaping of \n, \r, " and '. | 81 // Same as AsReversiblyEscapedUC16 with additional escaping of \n, \r, " and '. |
76 std::ostream& operator<<(std::ostream& os, const AsEscapedUC16ForJSON& c); | 82 std::ostream& operator<<(std::ostream& os, const AsEscapedUC16ForJSON& c); |
77 | 83 |
78 // Writes the given character to the output escaping everything outside | 84 // Writes the given character to the output escaping everything outside |
79 // of printable ASCII range. | 85 // of printable ASCII range. |
80 std::ostream& operator<<(std::ostream& os, const AsUC16& c); | 86 std::ostream& operator<<(std::ostream& os, const AsUC16& c); |
81 | 87 |
82 // Writes the given character to the output escaping everything outside | 88 // Writes the given character to the output escaping everything outside |
83 // of printable ASCII range. | 89 // of printable ASCII range. |
84 std::ostream& operator<<(std::ostream& os, const AsUC32& c); | 90 std::ostream& operator<<(std::ostream& os, const AsUC32& c); |
85 | 91 |
| 92 // Writes the given number to the output in hexadecimal notation. |
| 93 std::ostream& operator<<(std::ostream& os, const AsHex& v); |
| 94 |
86 } // namespace internal | 95 } // namespace internal |
87 } // namespace v8 | 96 } // namespace v8 |
88 | 97 |
89 #endif // V8_OSTREAMS_H_ | 98 #endif // V8_OSTREAMS_H_ |
OLD | NEW |