summaryrefslogtreecommitdiff
path: root/includes/image_io/utils/string_outputter_message_writer.h
blob: f34d975d9e0119751e56cdf9f39e23b877de06ee (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
#ifndef IMAGE_IO_UTILS_STRING_OUTPUTTER_MESSAGE_WRITER_H_  // NOLINT
#define IMAGE_IO_UTILS_STRING_OUTPUTTER_MESSAGE_WRITER_H_  // NOLINT

#include "image_io/base/message_writer.h"
#include "image_io/utils/string_outputter.h"

namespace photos_editing_formats {
namespace image_io {

/// A MessageWriter that writes the messages to the StringOutputter function.
class StringOutputterMessageWriter : public MessageWriter {
 public:
  /// @param outputter The outputter function to write messages to.
  explicit StringOutputterMessageWriter(const StringOutputter& outputter)
      : outputter_(outputter) {}
  void WriteMessage(const Message& message) override {
    outputter_(GetFormattedMessage(message));
    outputter_("\n");
  }

 private:
  StringOutputter outputter_;
};

}  // namespace image_io
}  // namespace photos_editing_formats

#endif  // IMAGE_IO_UTILS_STRING_OUTPUTTER_MESSAGE_WRITER_H_  // NOLINT