| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_TRACING_TRACED_VALUE_H_ | 5 #ifndef V8_TRACING_TRACED_VALUE_H_ |
| 6 #define V8_TRACING_TRACED_VALUE_H_ | 6 #define V8_TRACING_TRACED_VALUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 static std::unique_ptr<TracedValue> Create(); | 23 static std::unique_ptr<TracedValue> Create(); |
| 24 | 24 |
| 25 void EndDictionary(); | 25 void EndDictionary(); |
| 26 void EndArray(); | 26 void EndArray(); |
| 27 | 27 |
| 28 // These methods assume that |name| is a long lived "quoted" string. | 28 // These methods assume that |name| is a long lived "quoted" string. |
| 29 void SetInteger(const char* name, int value); | 29 void SetInteger(const char* name, int value); |
| 30 void SetDouble(const char* name, double value); | 30 void SetDouble(const char* name, double value); |
| 31 void SetBoolean(const char* name, bool value); | 31 void SetBoolean(const char* name, bool value); |
| 32 void SetString(const char* name, const std::string& value); | 32 void SetString(const char* name, const char* value); |
| 33 void SetString(const char* name, const std::string& value) { |
| 34 SetString(name, value.c_str()); |
| 35 } |
| 33 void BeginDictionary(const char* name); | 36 void BeginDictionary(const char* name); |
| 34 void BeginArray(const char* name); | 37 void BeginArray(const char* name); |
| 35 | 38 |
| 36 void AppendInteger(int); | 39 void AppendInteger(int); |
| 37 void AppendDouble(double); | 40 void AppendDouble(double); |
| 38 void AppendBoolean(bool); | 41 void AppendBoolean(bool); |
| 39 void AppendString(const std::string&); | 42 void AppendString(const char*); |
| 43 void AppendString(const std::string& value) { AppendString(value.c_str()); } |
| 40 void BeginArray(); | 44 void BeginArray(); |
| 41 void BeginDictionary(); | 45 void BeginDictionary(); |
| 42 | 46 |
| 43 // ConvertableToTraceFormat implementation. | 47 // ConvertableToTraceFormat implementation. |
| 44 void AppendAsTraceFormat(std::string* out) const override; | 48 void AppendAsTraceFormat(std::string* out) const override; |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 TracedValue(); | 51 TracedValue(); |
| 48 | 52 |
| 49 void WriteComma(); | 53 void WriteComma(); |
| 50 void WriteName(const char* name); | 54 void WriteName(const char* name); |
| 51 | 55 |
| 52 #ifdef DEBUG | 56 #ifdef DEBUG |
| 53 // In debug builds checks the pairings of {Begin,End}{Dictionary,Array} | 57 // In debug builds checks the pairings of {Begin,End}{Dictionary,Array} |
| 54 std::vector<bool> nesting_stack_; | 58 std::vector<bool> nesting_stack_; |
| 55 #endif | 59 #endif |
| 56 | 60 |
| 57 std::string data_; | 61 std::string data_; |
| 58 bool first_item_; | 62 bool first_item_; |
| 59 | 63 |
| 60 DISALLOW_COPY_AND_ASSIGN(TracedValue); | 64 DISALLOW_COPY_AND_ASSIGN(TracedValue); |
| 61 }; | 65 }; |
| 62 | 66 |
| 63 } // namespace tracing | 67 } // namespace tracing |
| 64 } // namespace v8 | 68 } // namespace v8 |
| 65 | 69 |
| 66 #endif // V8_TRACING_TRACED_VALUE_H_ | 70 #endif // V8_TRACING_TRACED_VALUE_H_ |
| OLD | NEW |