Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9da28e5c
Commit
9da28e5c
authored
Sep 07, 2020
by
Max Kellermann
Committed by
Max Kellermann
Aug 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
io/BufferedOutputStream: more API documentation
parent
d1f9b06f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
BufferedOutputStream.hxx
src/fs/io/BufferedOutputStream.hxx
+30
-1
No files found.
src/fs/io/BufferedOutputStream.hxx
View file @
9da28e5c
/*
* Copyright 2014-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2014-20
21
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -46,6 +46,9 @@ class OutputStream;
* number of OutputStream::Write() calls.
*
* All wchar_t based strings are converted to UTF-8.
*
* To make sure everything is written to the underlying #OutputStream,
* call Flush() before destructing this object.
*/
class
BufferedOutputStream
{
OutputStream
&
os
;
...
...
@@ -56,27 +59,49 @@ public:
explicit
BufferedOutputStream
(
OutputStream
&
_os
)
noexcept
:
os
(
_os
),
buffer
(
32768
)
{}
/**
* Write the contents of a buffer.
*/
void
Write
(
const
void
*
data
,
std
::
size_t
size
);
/**
* Write the given object. Note that this is only safe with
* POD types. Types with padding can expose sensitive data.
*/
template
<
typename
T
>
void
WriteT
(
const
T
&
value
)
{
Write
(
&
value
,
sizeof
(
value
));
}
/**
* Write one narrow character.
*/
void
Write
(
const
char
&
ch
)
{
WriteT
(
ch
);
}
/**
* Write a null-terminated string.
*/
void
Write
(
const
char
*
p
);
/**
* Write a printf-style formatted string.
*/
gcc_printf
(
2
,
3
)
void
Format
(
const
char
*
fmt
,
...);
#ifdef _UNICODE
/**
* Write one narrow character.
*/
void
Write
(
const
wchar_t
&
ch
)
{
WriteWideToUTF8
(
&
ch
,
1
);
}
/**
* Write a null-terminated wide string.
*/
void
Write
(
const
wchar_t
*
p
);
#endif
...
...
@@ -93,6 +118,10 @@ private:
#endif
};
/**
* Helper function which constructs a #BufferedOutputStream, calls the
* given function and flushes the #BufferedOutputStream.
*/
template
<
typename
F
>
void
WithBufferedOutputStream
(
OutputStream
&
os
,
F
&&
f
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment