summaryrefslogtreecommitdiff
path: root/includes/image_io/base/ostream_data_destination.h
blob: d0cf04c8a65f93fee66f1e66d193fa999ca663dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef IMAGE_IO_BASE_OSTREAM_DATA_DESTINATION_H_  // NOLINT
#define IMAGE_IO_BASE_OSTREAM_DATA_DESTINATION_H_  // NOLINT

#include <memory>
#include <utility>

#include "image_io/base/ostream_ref_data_destination.h"

namespace photos_editing_formats {
namespace image_io {

/// A DataDestination that writes its output to an ostream.
class OStreamDataDestination : public OStreamRefDataDestination {
 public:
  /// Constructs an OStreamDataDestination using the given ostream.
  /// @param ostream_ptr The ostream to which data is written.
  /// @param message_handler An option message handler for writing messages.
  OStreamDataDestination(std::unique_ptr<std::ostream> ostream_ptr,
                         MessageHandler* message_handler)
      : OStreamRefDataDestination(*ostream_ptr, message_handler),
        ostream_(std::move(ostream_ptr)) {}

 private:
  /// The ostream that is owned by this data destination.
  std::unique_ptr<std::ostream> ostream_;
};

}  // namespace image_io
}  // namespace photos_editing_formats

#endif  // IMAGE_IO_BASE_OSTREAM_DATA_DESTINATION_H_  // NOLINT