OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 MemoryMappedExternalResource(const char* filename, | 272 MemoryMappedExternalResource(const char* filename, |
273 bool remove_file_on_cleanup); | 273 bool remove_file_on_cleanup); |
274 virtual ~MemoryMappedExternalResource(); | 274 virtual ~MemoryMappedExternalResource(); |
275 | 275 |
276 virtual const char* data() const { return data_; } | 276 virtual const char* data() const { return data_; } |
277 virtual size_t length() const { return length_; } | 277 virtual size_t length() const { return length_; } |
278 | 278 |
279 bool exists() const { return file_ != NULL; } | 279 bool exists() const { return file_ != NULL; } |
280 bool is_empty() const { return length_ == 0; } | 280 bool is_empty() const { return length_ == 0; } |
281 | 281 |
282 bool EnsureIsAscii(bool abort_if_failed) const; | |
283 bool EnsureIsAscii() const { return EnsureIsAscii(true); } | |
284 bool IsAscii() const { return EnsureIsAscii(false); } | |
285 | |
286 private: | 282 private: |
287 void Init(const char* filename); | 283 void Init(const char* filename); |
288 | 284 |
289 char* filename_; | 285 char* filename_; |
290 OS::MemoryMappedFile* file_; | 286 OS::MemoryMappedFile* file_; |
291 | 287 |
292 const char* data_; | 288 const char* data_; |
293 size_t length_; | 289 size_t length_; |
294 bool remove_file_on_cleanup_; | 290 bool remove_file_on_cleanup_; |
295 }; | 291 }; |
296 | 292 |
297 class StringBuilder : public SimpleStringBuilder { | 293 class StringBuilder : public SimpleStringBuilder { |
298 public: | 294 public: |
299 explicit StringBuilder(int size) : SimpleStringBuilder(size) { } | 295 explicit StringBuilder(int size) : SimpleStringBuilder(size) { } |
300 StringBuilder(char* buffer, int size) : SimpleStringBuilder(buffer, size) { } | 296 StringBuilder(char* buffer, int size) : SimpleStringBuilder(buffer, size) { } |
301 | 297 |
302 // Add formatted contents to the builder just like printf(). | 298 // Add formatted contents to the builder just like printf(). |
303 void AddFormatted(const char* format, ...); | 299 void AddFormatted(const char* format, ...); |
304 | 300 |
305 // Add formatted contents like printf based on a va_list. | 301 // Add formatted contents like printf based on a va_list. |
306 void AddFormattedList(const char* format, va_list list); | 302 void AddFormattedList(const char* format, va_list list); |
307 private: | 303 private: |
308 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 304 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
309 }; | 305 }; |
310 | 306 |
311 } } // namespace v8::internal | 307 } } // namespace v8::internal |
312 | 308 |
313 #endif // V8_V8UTILS_H_ | 309 #endif // V8_V8UTILS_H_ |
OLD | NEW |