12#include <llvm/Support/raw_ostream.h>
18 llvm::raw_ostream &underlyingStream;
19 std::function<bool(
char)> filterFunc;
21 void write_impl(
const char *ptr,
size_t size)
override {
22 for (
size_t i = 0; i < size; ++i) {
23 if (!filterFunc(ptr[i])) {
24 underlyingStream << ptr[i];
29 uint64_t current_pos()
const override {
return underlyingStream.tell(); }
33 : underlyingStream(os), filterFunc(std::move(filter)) {}
40template <
typename Func,
typename... Args>
43 llvm::raw_string_ostream oss(output);
44 std::invoke(std::forward<Func>(appendFn), oss, std::forward<Args>(args)...);
58 llvm::raw_string_ostream oss(output);
59 (oss << ... << std::forward<Args>(args));
~filtered_raw_ostream() override
filtered_raw_ostream(llvm::raw_ostream &os, std::function< bool(char)> filter)
std::string buildStringViaInsertionOp(Args &&...args)
Generate a string by using the insertion operator (<<) to append all args to a stream backed by the r...
std::string buildStringViaPrint(const T &base)
Generate a string by calling base.print(llvm::raw_ostream &) on a stream backed by the returned strin...
std::string buildStringViaCallback(Func &&appendFn, Args &&...args)
Generate a string by calling the given appendFn with an llvm::raw_ostream & as the first argument fol...