1 #include "image_io/base/string_ref_data_source.h" 2 3 #include <string> 4 5 namespace photos_editing_formats { 6 namespace image_io { 7 8 namespace { 9 10 /// @param str The string from which to create a DataSegment. 11 /// @return A DataSegment the byte pointer of which is taken from the str. CreateDataSegment(const std::string & str)12std::shared_ptr<DataSegment> CreateDataSegment(const std::string &str) { 13 Byte *bytes = reinterpret_cast<Byte *>(const_cast<char *>(str.c_str())); 14 return DataSegment::Create(DataRange(0, str.length()), bytes, 15 DataSegment::BufferDispositionPolicy::kDontDelete); 16 } 17 18 } // namespace 19 StringRefDataSource(const std::string & string_ref)20StringRefDataSource::StringRefDataSource(const std::string &string_ref) 21 : DataSegmentDataSource(CreateDataSegment(string_ref)), 22 string_ref_(string_ref) {} 23 24 } // namespace image_io 25 } // namespace photos_editing_formats 26