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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ |
16 #define CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ |
17 | 17 |
18 #include <dbghelp.h> | 18 #include <dbghelp.h> |
19 | 19 |
20 #include <string> | 20 #include <string> |
| 21 #include <vector> |
21 | 22 |
22 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
23 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
24 #include "minidump/minidump_extensions.h" | 25 #include "minidump/minidump_extensions.h" |
| 26 #include "minidump/minidump_rva_list_writer.h" |
25 #include "minidump/minidump_writable.h" | 27 #include "minidump/minidump_writable.h" |
26 | 28 |
27 namespace crashpad { | 29 namespace crashpad { |
28 namespace internal { | 30 namespace internal { |
29 | 31 |
30 //! \cond | 32 //! \cond |
31 | 33 |
32 struct MinidumpStringWriterUTF16Traits { | 34 struct MinidumpStringWriterUTF16Traits { |
33 using StringType = string16; | 35 using StringType = string16; |
34 using MinidumpStringType = MINIDUMP_STRING; | 36 using MinidumpStringType = MINIDUMP_STRING; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 119 |
118 //! \brief Retrieves the string to be written. | 120 //! \brief Retrieves the string to be written. |
119 //! | 121 //! |
120 //! \note Valid in any state. | 122 //! \note Valid in any state. |
121 const std::string& UTF8() const { return string(); } | 123 const std::string& UTF8() const { return string(); } |
122 | 124 |
123 private: | 125 private: |
124 DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter); | 126 DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter); |
125 }; | 127 }; |
126 | 128 |
| 129 //! \cond |
| 130 |
| 131 struct MinidumpStringListWriterUTF16Traits { |
| 132 using MinidumpStringWriterType = MinidumpUTF16StringWriter; |
| 133 }; |
| 134 |
| 135 struct MinidumpStringListWriterUTF8Traits { |
| 136 using MinidumpStringWriterType = MinidumpUTF8StringWriter; |
| 137 }; |
| 138 |
| 139 //! \endcond |
| 140 |
| 141 //! \brief The writer for a MinidumpRVAList object in a minidump file, |
| 142 //! containing a list of \a Traits::MinidumpStringWriterType objects. |
| 143 template <typename Traits> |
| 144 class MinidumpStringListWriter : public MinidumpRVAListWriter { |
| 145 public: |
| 146 using MinidumpStringWriterType = typename Traits::MinidumpStringWriterType; |
| 147 |
| 148 MinidumpStringListWriter(); |
| 149 ~MinidumpStringListWriter() override; |
| 150 |
| 151 //! \brief Adds a new \a Traits::MinidumpStringWriterType for each element in |
| 152 //! \a vector to the MinidumpRVAList. |
| 153 //! |
| 154 //! \param[in] vector The vector to use as source data. Each string in the |
| 155 //! vector is treated as a UTF-8 string, and a new string writer will be |
| 156 //! created for each one and made a child of the MinidumpStringListWriter. |
| 157 //! |
| 158 //! \note Valid in #kStateMutable. No mutator methods may be called before |
| 159 //! this method, and it is not normally necessary to call any mutator |
| 160 //! methods after this method. |
| 161 void InitializeFromVector(const std::vector<std::string>& vector); |
| 162 |
| 163 //! \brief Creates a new \a Traits::MinidumpStringWriterType object and adds |
| 164 //! it to the MinidumpRVAList. |
| 165 //! |
| 166 //! This object creates a new string writer with string value \a string_utf8, |
| 167 //! takes ownership of it, and becomes its parent in the overall tree of |
| 168 //! internal::MinidumpWritable objects. |
| 169 //! |
| 170 //! \note Valid in #kStateMutable. |
| 171 void AddStringUTF8(const std::string& string_utf8); |
| 172 |
| 173 //! \brief Determines whether the object is useful. |
| 174 //! |
| 175 //! A useful object is one that carries data that makes a meaningful |
| 176 //! contribution to a minidump file. An object carrying entries would be |
| 177 //! considered useful. |
| 178 //! |
| 179 //! \return `true` if the object is useful, `false` otherwise. |
| 180 bool IsUseful() const; |
| 181 |
| 182 private: |
| 183 DISALLOW_COPY_AND_ASSIGN(MinidumpStringListWriter); |
| 184 }; |
| 185 |
| 186 using MinidumpUTF16StringListWriter = |
| 187 MinidumpStringListWriter<MinidumpStringListWriterUTF16Traits>; |
| 188 using MinidumpUTF8StringListWriter = |
| 189 MinidumpStringListWriter<MinidumpStringListWriterUTF8Traits>; |
| 190 |
127 } // namespace internal | 191 } // namespace internal |
128 } // namespace crashpad | 192 } // namespace crashpad |
129 | 193 |
130 #endif // CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ | 194 #endif // CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_ |
OLD | NEW |