aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/output.h
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commit863a59a65247c24db7cb06789bc5cf79d04da32f (patch)
tree139dc000c8cd4a40f5659e421b7c75135d080307 /util/stream/output.h
parentf64e95a9eb9ab03240599eb9581c5a9102426a96 (diff)
downloadydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/stream/output.h')
-rw-r--r--util/stream/output.h226
1 files changed, 113 insertions, 113 deletions
diff --git a/util/stream/output.h b/util/stream/output.h
index 00eef50b95..14b82509e6 100644
--- a/util/stream/output.h
+++ b/util/stream/output.h
@@ -10,19 +10,19 @@
#include <type_traits>
-/**
- * @addtogroup Streams_Base
- * @{
- */
-
-/**
- * Abstract output stream.
- */
+/**
+ * @addtogroup Streams_Base
+ * @{
+ */
+
+/**
+ * Abstract output stream.
+ */
class IOutputStream: public TNonCopyable {
public:
- /**
- * Data block for output.
- */
+ /**
+ * Data block for output.
+ */
struct TPart {
inline TPart(const void* Buf, size_t Len) noexcept
: buf(Buf)
@@ -62,34 +62,34 @@ public:
return *this;
};
- /**
- * Writes into this stream.
- *
- * @param buf Data to write.
- * @param len Number of bytes to write.
- */
+ /**
+ * Writes into this stream.
+ *
+ * @param buf Data to write.
+ * @param len Number of bytes to write.
+ */
inline void Write(const void* buf, size_t len) {
if (len) {
DoWrite(buf, len);
}
}
- /**
- * Writes a string into this stream.
- *
- * @param st String to write.
- */
+ /**
+ * Writes a string into this stream.
+ *
+ * @param st String to write.
+ */
inline void Write(const TStringBuf st) {
Write(st.data(), st.size());
}
- /**
- * Writes several data blocks into this stream.
- *
- * @param parts Pointer to the start of the data blocks
- * array.
- * @param count Number of data blocks to write.
- */
+ /**
+ * Writes several data blocks into this stream.
+ *
+ * @param parts Pointer to the start of the data blocks
+ * array.
+ * @param count Number of data blocks to write.
+ */
inline void Write(const TPart* parts, size_t count) {
if (count > 1) {
DoWriteV(parts, count);
@@ -98,56 +98,56 @@ public:
}
}
- /**
- * Writes a single character into this stream.
- *
- * @param ch Character to write.
- */
+ /**
+ * Writes a single character into this stream.
+ *
+ * @param ch Character to write.
+ */
inline void Write(char ch) {
DoWriteC(ch);
}
- /**
- * Flushes this stream's buffer, if any.
- *
- * Note that this can also be done with a `Flush` manipulator:
- * @code
- * stream << "some string" << Flush;
- * @endcode
- */
+ /**
+ * Flushes this stream's buffer, if any.
+ *
+ * Note that this can also be done with a `Flush` manipulator:
+ * @code
+ * stream << "some string" << Flush;
+ * @endcode
+ */
inline void Flush() {
DoFlush();
}
- /**
- * Flushes and closes this stream. No more data can be written into a stream
- * once it's closed.
- */
+ /**
+ * Flushes and closes this stream. No more data can be written into a stream
+ * once it's closed.
+ */
inline void Finish() {
DoFinish();
}
protected:
- /**
- * Writes into this stream.
- *
- * @param buf Data to write.
- * @param len Number of bytes to write.
- * @throws yexception If IO error occurs.
- */
+ /**
+ * Writes into this stream.
+ *
+ * @param buf Data to write.
+ * @param len Number of bytes to write.
+ * @throws yexception If IO error occurs.
+ */
virtual void DoWrite(const void* buf, size_t len) = 0;
-
- /**
- * Writes several data blocks into this stream.
- *
- * @param parts Pointer to the start of the data blocks
- * array.
- * @param count Number of data blocks to write.
- * @throws yexception If IO error occurs.
- */
+
+ /**
+ * Writes several data blocks into this stream.
+ *
+ * @param parts Pointer to the start of the data blocks
+ * array.
+ * @param count Number of data blocks to write.
+ * @throws yexception If IO error occurs.
+ */
virtual void DoWriteV(const TPart* parts, size_t count);
-
- /**
+
+ /**
* Writes a single character into this stream. Can be overridden with a faster implementation.
*
* @param ch Character to write.
@@ -155,36 +155,36 @@ protected:
virtual void DoWriteC(char ch);
/**
- * Flushes this stream's buffer, if any.
- *
- * @throws yexception If IO error occurs.
- */
+ * Flushes this stream's buffer, if any.
+ *
+ * @throws yexception If IO error occurs.
+ */
virtual void DoFlush();
-
- /**
- * Flushes and closes this stream. No more data can be written into a stream
- * once it's closed.
- *
- * @throws yexception If IO error occurs.
- */
+
+ /**
+ * Flushes and closes this stream. No more data can be written into a stream
+ * once it's closed.
+ *
+ * @throws yexception If IO error occurs.
+ */
virtual void DoFinish();
};
-/**
+/**
* `operator<<` for `IOutputStream` by default delegates to this function.
- *
- * Note that while `operator<<` uses overloading (and thus argument-dependent
- * lookup), `Out` uses template specializations. This makes it possible to
- * have a single `Out` declaration, and then just provide specializations in
- * cpp files, letting the linker figure everything else out. This approach
- * reduces compilation times.
- *
- * However, if the flexibility of overload resolution is needed, then one should
- * just overload `operator<<`.
- *
- * @param out Output stream to write into.
- * @param value Value to write.
- */
+ *
+ * Note that while `operator<<` uses overloading (and thus argument-dependent
+ * lookup), `Out` uses template specializations. This makes it possible to
+ * have a single `Out` declaration, and then just provide specializations in
+ * cpp files, letting the linker figure everything else out. This approach
+ * reduces compilation times.
+ *
+ * However, if the flexibility of overload resolution is needed, then one should
+ * just overload `operator<<`.
+ *
+ * @param out Output stream to write into.
+ * @param value Value to write.
+ */
template <class T>
void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value);
@@ -259,46 +259,46 @@ static inline IOutputStream& operator<<(IOutputStream& o, wchar32* t) {
return o;
}
-namespace NPrivate {
+namespace NPrivate {
IOutputStream& StdOutStream() noexcept;
IOutputStream& StdErrStream() noexcept;
-}
-
-/**
- * Standard output stream.
- */
-#define Cout (::NPrivate::StdOutStream())
-
-/**
- * Standard error stream.
- */
-#define Cerr (::NPrivate::StdErrStream())
-
-/**
- * Standard log stream.
- */
+}
+
+/**
+ * Standard output stream.
+ */
+#define Cout (::NPrivate::StdOutStream())
+
+/**
+ * Standard error stream.
+ */
+#define Cerr (::NPrivate::StdErrStream())
+
+/**
+ * Standard log stream.
+ */
#define Clog Cerr
-/**
- * End-of-line output manipulator, basically the same as `std::endl`.
+/**
+ * End-of-line output manipulator, basically the same as `std::endl`.
*/
static inline void Endl(IOutputStream& o) {
(o << '\n').Flush();
}
-/**
- * Flushing stream manipulator, basically the same as `std::flush`.
- */
+/**
+ * Flushing stream manipulator, basically the same as `std::flush`.
+ */
static inline void Flush(IOutputStream& o) {
o.Flush();
}
/*
- * Also see format.h for additional manipulators.
- */
+ * Also see format.h for additional manipulators.
+ */
#include "debug.h"
void RedirectStdioToAndroidLog(bool redirect);
-/** @} */
+/** @} */