• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef IMAGE_IO_BASE_STRING_REF_DATA_SOURCE_H_  // NOLINT
2 #define IMAGE_IO_BASE_STRING_REF_DATA_SOURCE_H_  // NOLINT
3 
4 #include <string>
5 
6 #include "image_io/base/data_segment_data_source.h"
7 
8 namespace photos_editing_formats {
9 namespace image_io {
10 
11 /// A DataSource that reads bytes from a string held by ref. The underlying
12 /// string must have a lifetime that exceeds the lifetime of this data source,
13 /// and the string contents must not change while the data source is referencing
14 /// it.
15 class StringRefDataSource : public DataSegmentDataSource {
16  public:
17   /// Constructs a StringRefDataSource using the given string.
18   /// @param string_refg The string to read from.
19   explicit StringRefDataSource(const std::string& string_ref);
20 
21   /// Returns the string being used as the data source.
GetStringRef()22   const std::string& GetStringRef() const { return string_ref_; }
23 
24  private:
25   /// The string to read from.
26   const std::string& string_ref_;
27 };
28 
29 }  // namespace image_io
30 }  // namespace photos_editing_formats
31 
32 #endif  // IMAGE_IO_BASE_STRING_REF_DATA_SOURCE_H_  // NOLINT
33