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 29 matching lines...) Expand all Loading... |
40 //! \brief Returns a string containing the virtual file’s contents. | 40 //! \brief Returns a string containing the virtual file’s contents. |
41 const std::string& string() const { return string_; } | 41 const std::string& string() const { return string_; } |
42 | 42 |
43 //! \brief Resets the virtual file’s contents to be empty, and resets its file | 43 //! \brief Resets the virtual file’s contents to be empty, and resets its file |
44 //! position to `0`. | 44 //! position to `0`. |
45 void Reset(); | 45 void Reset(); |
46 | 46 |
47 // FileWriterInterface: | 47 // FileWriterInterface: |
48 bool Write(const void* data, size_t size) override; | 48 bool Write(const void* data, size_t size) override; |
49 bool WriteIoVec(std::vector<WritableIoVec>* iovecs) override; | 49 bool WriteIoVec(std::vector<WritableIoVec>* iovecs) override; |
50 off_t Seek(off_t offset, int whence) override; | 50 FileOffset Seek(FileOffset offset, int whence) override; |
51 | 51 |
52 private: | 52 private: |
53 //! \brief The virtual file’s contents. | 53 //! \brief The virtual file’s contents. |
54 std::string string_; | 54 std::string string_; |
55 | 55 |
56 //! \brief The file offset of the virtual file. | 56 //! \brief The file offset of the virtual file. |
57 //! | 57 //! |
58 //! \note This is stored in a `size_t` to match the characteristics of | 58 //! \note This is stored in a `size_t` to match the characteristics of |
59 //! #string_, the `std::string` used to store the virtual file’s contents. | 59 //! #string_, the `std::string` used to store the virtual file’s contents. |
60 //! This type will have different characteristics than the `off_t` used to | 60 //! This type will have different characteristics than the `off_t` used to |
61 //! report file offsets. The implementation must take care when converting | 61 //! report file offsets. The implementation must take care when converting |
62 //! between these distinct types. | 62 //! between these distinct types. |
63 base::CheckedNumeric<size_t> offset_; | 63 base::CheckedNumeric<size_t> offset_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(StringFileWriter); | 65 DISALLOW_COPY_AND_ASSIGN(StringFileWriter); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace crashpad | 68 } // namespace crashpad |
69 | 69 |
70 #endif // CRASHPAD_UTIL_FILE_STRING_FILE_WRITER_H_ | 70 #endif // CRASHPAD_UTIL_FILE_STRING_FILE_WRITER_H_ |
OLD | NEW |