| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
| 24 #include "minidump/minidump_extensions.h" | 24 #include "minidump/minidump_extensions.h" |
| 25 #include "minidump/minidump_writable.h" | 25 #include "minidump/minidump_writable.h" |
| 26 | 26 |
| 27 namespace crashpad { | 27 namespace crashpad { |
| 28 namespace internal { | 28 namespace internal { |
| 29 | 29 |
| 30 //! \cond | 30 //! \cond |
| 31 | 31 |
| 32 struct MinidumpStringWriterUTF16Traits { | 32 struct MinidumpStringWriterUTF16Traits { |
| 33 typedef string16 StringType; | 33 using StringType = string16; |
| 34 typedef MINIDUMP_STRING MinidumpStringType; | 34 using MinidumpStringType = MINIDUMP_STRING; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 struct MinidumpStringWriterUTF8Traits { | 37 struct MinidumpStringWriterUTF8Traits { |
| 38 typedef std::string StringType; | 38 using StringType = std::string; |
| 39 typedef MinidumpUTF8String MinidumpStringType; | 39 using MinidumpStringType = MinidumpUTF8String; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 //! \endcond | 42 //! \endcond |
| 43 | 43 |
| 44 //! \brief Writes a variable-length string to a minidump file in accordance with | 44 //! \brief Writes a variable-length string to a minidump file in accordance with |
| 45 //! the string type’s characteristics. | 45 //! the string type’s characteristics. |
| 46 //! | 46 //! |
| 47 //! MinidumpStringWriter objects should not be instantiated directly. To write | 47 //! MinidumpStringWriter objects should not be instantiated directly. To write |
| 48 //! strings to minidump file, use the MinidumpUTF16StringWriter and | 48 //! strings to minidump file, use the MinidumpUTF16StringWriter and |
| 49 //! MinidumpUTF8StringWriter subclasses instead. | 49 //! MinidumpUTF8StringWriter subclasses instead. |
| 50 template <typename Traits> | 50 template <typename Traits> |
| 51 class MinidumpStringWriter : public MinidumpWritable { | 51 class MinidumpStringWriter : public MinidumpWritable { |
| 52 public: | 52 public: |
| 53 MinidumpStringWriter(); | 53 MinidumpStringWriter(); |
| 54 ~MinidumpStringWriter() override; | 54 ~MinidumpStringWriter() override; |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 typedef typename Traits::MinidumpStringType MinidumpStringType; | 57 using MinidumpStringType = typename Traits::MinidumpStringType; |
| 58 typedef typename Traits::StringType StringType; | 58 using StringType = typename Traits::StringType; |
| 59 | 59 |
| 60 bool Freeze() override; | 60 bool Freeze() override; |
| 61 size_t SizeOfObject() override; | 61 size_t SizeOfObject() override; |
| 62 bool WriteObject(FileWriterInterface* file_writer) override; | 62 bool WriteObject(FileWriterInterface* file_writer) override; |
| 63 | 63 |
| 64 //! \brief Sets the string to be written. | 64 //! \brief Sets the string to be written. |
| 65 //! | 65 //! |
| 66 //! \note Valid in #kStateMutable. | 66 //! \note Valid in #kStateMutable. |
| 67 void set_string(const StringType& string) { string_.assign(string); } | 67 void set_string(const StringType& string) { string_.assign(string); } |
| 68 | 68 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const std::string& UTF8() const { return string(); } | 121 const std::string& UTF8() const { return string(); } |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter); | 124 DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace internal | 127 } // namespace internal |
| 128 } // namespace crashpad | 128 } // namespace crashpad |
| 129 | 129 |
| 130 #endif // CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ | 130 #endif // CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ |
| OLD | NEW |