io/BufferedOutputStream: use std::size_t
This commit is contained in:
parent
19d19cd737
commit
f9f3306db9
@ -41,7 +41,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BufferedOutputStream::AppendToBuffer(const void *data, size_t size) noexcept
|
BufferedOutputStream::AppendToBuffer(const void *data, std::size_t size) noexcept
|
||||||
{
|
{
|
||||||
auto r = buffer.Write();
|
auto r = buffer.Write();
|
||||||
if (r.size < size)
|
if (r.size < size)
|
||||||
@ -53,7 +53,7 @@ BufferedOutputStream::AppendToBuffer(const void *data, size_t size) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BufferedOutputStream::Write(const void *data, size_t size)
|
BufferedOutputStream::Write(const void *data, std::size_t size)
|
||||||
{
|
{
|
||||||
/* try to append to the current buffer */
|
/* try to append to the current buffer */
|
||||||
if (AppendToBuffer(data, size))
|
if (AppendToBuffer(data, size))
|
||||||
@ -88,7 +88,7 @@ BufferedOutputStream::Format(const char *fmt, ...)
|
|||||||
/* format into the buffer */
|
/* format into the buffer */
|
||||||
std::va_list ap;
|
std::va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
size_t size = vsnprintf(r.data, r.size, fmt, ap);
|
std::size_t size = vsnprintf(r.data, r.size, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (gcc_unlikely(size >= r.size)) {
|
if (gcc_unlikely(size >= r.size)) {
|
||||||
@ -127,7 +127,8 @@ BufferedOutputStream::Write(const wchar_t *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BufferedOutputStream::WriteWideToUTF8(const wchar_t *src, size_t src_length)
|
BufferedOutputStream::WriteWideToUTF8(const wchar_t *src,
|
||||||
|
std::size_t src_length)
|
||||||
{
|
{
|
||||||
if (src_length == 0)
|
if (src_length == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
explicit BufferedOutputStream(OutputStream &_os) noexcept
|
explicit BufferedOutputStream(OutputStream &_os) noexcept
|
||||||
:os(_os), buffer(32768) {}
|
:os(_os), buffer(32768) {}
|
||||||
|
|
||||||
void Write(const void *data, size_t size);
|
void Write(const void *data, std::size_t size);
|
||||||
|
|
||||||
void Write(const char &ch) {
|
void Write(const char &ch) {
|
||||||
Write(&ch, sizeof(ch));
|
Write(&ch, sizeof(ch));
|
||||||
@ -81,10 +81,10 @@ public:
|
|||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool AppendToBuffer(const void *data, size_t size) noexcept;
|
bool AppendToBuffer(const void *data, std::size_t size) noexcept;
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
void WriteWideToUTF8(const wchar_t *p, size_t length);
|
void WriteWideToUTF8(const wchar_t *p, std::size_t length);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user