#ifndef V8_UTILS_OSTREAMS_H_
#define V8_UTILS_OSTREAMS_H_
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <ostream>
#include <streambuf>
#include "src/base/macros.h"
#include "src/base/platform/mutex.h"
#include "src/common/globals.h"
namespace v8 {
namespace internal {
class V8_EXPORT_PRIVATE OFStreamBase : public std::streambuf { … };
class V8_EXPORT_PRIVATE DbgStreamBuf : public std::streambuf { … };
class DbgStdoutStream : public std::ostream { … };
class V8_EXPORT_PRIVATE OFStream : public std::ostream { … };
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
class V8_EXPORT_PRIVATE AndroidLogStream : public std::streambuf {
public:
virtual ~AndroidLogStream();
protected:
std::streamsize xsputn(const char* s, std::streamsize n) override;
private:
std::string line_buffer_;
};
class StdoutStream : public std::ostream {
public:
StdoutStream() : std::ostream(&stream_) {}
private:
friend class StderrStream;
static V8_EXPORT_PRIVATE base::RecursiveMutex* GetStdoutMutex();
AndroidLogStream stream_;
base::RecursiveMutexGuard mutex_guard_{GetStdoutMutex()};
};
#else
class StdoutStream : public OFStream { … };
#endif
class StderrStream : public OFStream { … };
struct AsUC16 { … };
struct AsUC32 { … };
struct AsReversiblyEscapedUC16 { … };
struct AsEscapedUC16ForJSON { … };
struct AsHex { … };
struct AsHexBytes { … };
template <typename T>
struct PrintIteratorRange { … };
template <typename T>
auto PrintCollection(const T& collection) -> PrintIteratorRange<
typename std::common_type<decltype(std::begin(collection)),
decltype(std::end(collection))>::type> { … }
std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const AsEscapedUC16ForJSON& c);
std::ostream& operator<<(std::ostream& os, const AsUC16& c);
std::ostream& operator<<(std::ostream& os, const AsUC32& c);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const AsHex& v);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const AsHexBytes& v);
template <typename T>
std::ostream& operator<<(std::ostream& os, const PrintIteratorRange<T>& range) { … }
}
}
#endif