| 70 | } |
| 71 | |
| 72 | int64_t ApplyTemplate::WriteCallback::process(const std::shared_ptr<io::BaseStream> stream) { |
| 73 | logger_->log_info("ApplyTemplate reading template file from %s", template_file_); |
| 74 | boost::iostreams::mapped_file_source file(template_file_); |
| 75 | |
| 76 | bustache::format format(file); |
| 77 | bustache::object data; |
| 78 | |
| 79 | for (const auto &attr : flow_file_->getAttributes()) { |
| 80 | data[attr.first] = attr.second; |
| 81 | } |
| 82 | |
| 83 | // TODO(calebj) write ostream reciever for format() to prevent excessive copying |
| 84 | std::string ostring = to_string(format(data)); |
| 85 | stream->write(reinterpret_cast<uint8_t *>(const_cast<char *>(ostring.c_str())), |
| 86 | ostring.length()); |
| 87 | |
| 88 | return ostring.length(); |
| 89 | } |
| 90 | |
| 91 | } /* namespace processors */ |
| 92 | } /* namespace minifi */ |