| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 unsigned length_; // does not include terminating 0-character | 180 unsigned length_; // does not include terminating 0-character |
| 181 char* buffer_; | 181 char* buffer_; |
| 182 | 182 |
| 183 bool full() const { return (capacity_ - length_) == 1; } | 183 bool full() const { return (capacity_ - length_) == 1; } |
| 184 int space() const { return capacity_ - length_; } | 184 int space() const { return capacity_ - length_; } |
| 185 | 185 |
| 186 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); | 186 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 | 189 |
| 190 // Utility class to print a list of items to a stream, divided by a separator. |
| 191 class SimpleListPrinter { |
| 192 public: |
| 193 explicit SimpleListPrinter(StringStream* stream, char separator = ',') { |
| 194 separator_ = separator; |
| 195 stream_ = stream; |
| 196 first_ = true; |
| 197 } |
| 198 |
| 199 void Add(const char* str) { |
| 200 if (first_) { |
| 201 first_ = false; |
| 202 } else { |
| 203 stream_->Put(separator_); |
| 204 } |
| 205 stream_->Add(str); |
| 206 } |
| 207 |
| 208 private: |
| 209 bool first_; |
| 210 char separator_; |
| 211 StringStream* stream_; |
| 212 }; |
| 213 |
| 214 |
| 190 } } // namespace v8::internal | 215 } } // namespace v8::internal |
| 191 | 216 |
| 192 #endif // V8_STRING_STREAM_H_ | 217 #endif // V8_STRING_STREAM_H_ |
| OLD | NEW |