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
49784513
Commit
49784513
authored
Nov 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/{Const,Writable}Buffer, ...: rename IsEmpty() to empty(), imitating STL
parent
52305113
Show whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
142 additions
and
142 deletions
+142
-142
MusicBuffer.hxx
src/MusicBuffer.hxx
+1
-1
TagFile.cxx
src/TagFile.cxx
+1
-1
TagStream.cxx
src/TagStream.cxx
+1
-1
ClientCommands.cxx
src/command/ClientCommands.cxx
+4
-4
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+2
-2
MessageCommands.cxx
src/command/MessageCommands.cxx
+2
-2
OtherCommands.cxx
src/command/OtherCommands.cxx
+1
-1
OutputCommands.cxx
src/command/OutputCommands.cxx
+1
-1
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+1
-1
QueueCommands.cxx
src/command/QueueCommands.cxx
+1
-1
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+1
-1
Bridge.cxx
src/decoder/Bridge.cxx
+1
-1
DecoderBuffer.cxx
src/decoder/DecoderBuffer.cxx
+1
-1
FaadDecoderPlugin.cxx
src/decoder/plugins/FaadDecoderPlugin.cxx
+3
-3
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+1
-1
FlacMetadata.cxx
src/decoder/plugins/FlacMetadata.cxx
+1
-1
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+1
-1
PcmDecoderPlugin.cxx
src/decoder/plugins/PcmDecoderPlugin.cxx
+2
-2
BufferedSocket.cxx
src/event/BufferedSocket.cxx
+2
-2
FullyBufferedSocket.cxx
src/event/FullyBufferedSocket.cxx
+5
-5
BufferedOutputStream.cxx
src/fs/io/BufferedOutputStream.cxx
+3
-3
BufferedReader.cxx
src/fs/io/BufferedReader.cxx
+5
-5
GunzipReader.cxx
src/fs/io/GunzipReader.cxx
+2
-2
AsyncInputStream.cxx
src/input/AsyncInputStream.cxx
+6
-6
AsyncInputStream.hxx
src/input/AsyncInputStream.hxx
+1
-1
TextInputStream.cxx
src/input/TextInputStream.cxx
+3
-3
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+3
-3
VorbisComments.cxx
src/lib/xiph/VorbisComments.cxx
+2
-2
Source.cxx
src/output/Source.cxx
+5
-5
Thread.cxx
src/output/Thread.cxx
+1
-1
PcmDsd.cxx
src/pcm/PcmDsd.cxx
+1
-1
Builder.cxx
src/tag/Builder.cxx
+2
-2
Builder.hxx
src/tag/Builder.hxx
+2
-2
Id3Scan.cxx
src/tag/Id3Scan.cxx
+1
-1
AllocatedArray.hxx
src/util/AllocatedArray.hxx
+1
-1
CircularBuffer.hxx
src/util/CircularBuffer.hxx
+1
-1
ConstBuffer.hxx
src/util/ConstBuffer.hxx
+6
-6
DivideString.hxx
src/util/DivideString.hxx
+1
-1
DynamicFifoBuffer.hxx
src/util/DynamicFifoBuffer.hxx
+1
-1
ForeignFifoBuffer.hxx
src/util/ForeignFifoBuffer.hxx
+2
-2
PeakBuffer.cxx
src/util/PeakBuffer.cxx
+10
-10
PeakBuffer.hxx
src/util/PeakBuffer.hxx
+1
-1
SliceBuffer.hxx
src/util/SliceBuffer.hxx
+1
-1
StaticFifoBuffer.hxx
src/util/StaticFifoBuffer.hxx
+2
-2
StringView.cxx
src/util/StringView.cxx
+2
-2
StringView.hxx
src/util/StringView.hxx
+1
-1
UriUtil.cxx
src/util/UriUtil.cxx
+1
-1
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+6
-6
DivideStringTest.hxx
test/DivideStringTest.hxx
+3
-3
TestCircularBuffer.hxx
test/TestCircularBuffer.hxx
+30
-30
run_convert.cxx
test/run_convert.cxx
+3
-3
No files found.
src/MusicBuffer.hxx
View file @
49784513
...
...
@@ -50,7 +50,7 @@ public:
* object is inaccessible to other threads.
*/
bool
IsEmptyUnsafe
()
const
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
#endif
...
...
src/TagFile.cxx
View file @
49784513
...
...
@@ -109,7 +109,7 @@ tag_file_scan(Path path, TagBuilder &builder)
if
(
!
tag_file_scan
(
path
,
full_tag_handler
,
&
builder
))
return
false
;
if
(
builder
.
IsE
mpty
())
if
(
builder
.
e
mpty
())
ScanGenericTags
(
path
,
full_tag_handler
,
&
builder
);
return
true
;
...
...
src/TagStream.cxx
View file @
49784513
...
...
@@ -94,7 +94,7 @@ tag_stream_scan(InputStream &is, TagBuilder &builder)
if
(
!
tag_stream_scan
(
is
,
full_tag_handler
,
&
builder
))
return
false
;
if
(
builder
.
IsE
mpty
())
if
(
builder
.
e
mpty
())
ScanGenericTags
(
is
,
full_tag_handler
,
&
builder
);
return
true
;
...
...
src/command/ClientCommands.cxx
View file @
49784513
...
...
@@ -58,7 +58,7 @@ handle_password(Client &client, Request args, Response &r)
static
TagMask
ParseTagMask
(
Request
request
)
{
if
(
request
.
IsE
mpty
())
if
(
request
.
e
mpty
())
throw
ProtocolError
(
ACK_ERROR_ARG
,
"Not enough arguments"
);
TagMask
result
=
TagMask
::
None
();
...
...
@@ -77,14 +77,14 @@ ParseTagMask(Request request)
CommandResult
handle_tagtypes
(
Client
&
client
,
Request
request
,
Response
&
r
)
{
if
(
request
.
IsE
mpty
())
{
if
(
request
.
e
mpty
())
{
tag_print_types
(
r
);
return
CommandResult
::
OK
;
}
const
char
*
cmd
=
request
.
shift
();
if
(
StringIsEqual
(
cmd
,
"all"
))
{
if
(
!
request
.
IsE
mpty
())
{
if
(
!
request
.
e
mpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
}
...
...
@@ -92,7 +92,7 @@ handle_tagtypes(Client &client, Request request, Response &r)
client
.
tag_mask
=
TagMask
::
All
();
return
CommandResult
::
OK
;
}
else
if
(
StringIsEqual
(
cmd
,
"clear"
))
{
if
(
!
request
.
IsE
mpty
())
{
if
(
!
request
.
e
mpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
}
...
...
src/command/DatabaseCommands.cxx
View file @
49784513
...
...
@@ -169,7 +169,7 @@ handle_count(Client &client, Request args, Response &r)
}
SongFilter
filter
;
if
(
!
args
.
IsE
mpty
()
&&
!
filter
.
Parse
(
args
,
false
))
{
if
(
!
args
.
e
mpty
()
&&
!
filter
.
Parse
(
args
,
false
))
{
r
.
Error
(
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
}
...
...
@@ -235,7 +235,7 @@ handle_list(Client &client, Request args, Response &r)
args
.
pop_back
();
}
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
filter
.
reset
(
new
SongFilter
());
if
(
!
filter
->
Parse
(
args
,
false
))
{
r
.
Error
(
ACK_ERROR_ARG
,
"not able to parse args"
);
...
...
src/command/MessageCommands.cxx
View file @
49784513
...
...
@@ -76,7 +76,7 @@ handle_unsubscribe(Client &client, Request args, Response &r)
CommandResult
handle_channels
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
std
::
set
<
std
::
string
>
channels
;
for
(
const
auto
&
c
:
*
client
.
GetInstance
().
client_list
)
...
...
@@ -93,7 +93,7 @@ CommandResult
handle_read_messages
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
while
(
!
client
.
messages
.
empty
())
{
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
...
...
src/command/OtherCommands.cxx
View file @
49784513
...
...
@@ -284,7 +284,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
const
char
*
path
=
""
;
assert
(
args
.
size
<=
1
);
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
path
=
args
.
front
();
if
(
*
path
==
0
||
StringIsEqual
(
path
,
"/"
))
...
...
src/command/OutputCommands.cxx
View file @
49784513
...
...
@@ -71,7 +71,7 @@ handle_toggleoutput(Client &client, Request args, Response &r)
CommandResult
handle_devices
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
printAudioDevices
(
r
,
client
.
GetPartition
().
outputs
);
return
CommandResult
::
OK
;
...
...
src/command/PlayerCommands.cxx
View file @
49784513
...
...
@@ -95,7 +95,7 @@ handle_pause(Client &client, Request args, gcc_unused Response &r)
{
auto
&
pc
=
client
.
GetPlayerControl
();
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
bool
pause_flag
=
args
.
ParseBool
(
0
);
pc
.
LockSetPause
(
pause_flag
);
}
else
...
...
src/command/QueueCommands.cxx
View file @
49784513
...
...
@@ -242,7 +242,7 @@ handle_playlistinfo(Client &client, Request args, Response &r)
CommandResult
handle_playlistid
(
Client
&
client
,
Request
args
,
Response
&
r
)
{
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
playlist_print_id
(
r
,
client
.
GetPlaylist
(),
id
);
}
else
{
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
49784513
...
...
@@ -801,7 +801,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagBuilder
tag
;
tag
.
AddItem
(
tag_type
,
pair
->
value
);
if
(
tag
.
IsE
mpty
())
if
(
tag
.
e
mpty
())
/* if no tag item has been added, then the
given value was not acceptable
(e.g. empty); forcefully insert an empty
...
...
src/decoder/Bridge.cxx
View file @
49784513
...
...
@@ -496,7 +496,7 @@ DecoderBridge::SubmitData(InputStream *is,
SongTime
::
FromS
(
timestamp
)
-
dc
.
song
->
GetStartTime
(),
kbit_rate
);
if
(
dest
.
IsE
mpty
())
{
if
(
dest
.
e
mpty
())
{
/* the chunk is full, flush it */
FlushChunk
();
continue
;
...
...
src/decoder/DecoderBuffer.cxx
View file @
49784513
...
...
@@ -25,7 +25,7 @@ bool
DecoderBuffer
::
Fill
()
{
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
if
(
w
.
e
mpty
())
/* buffer is full */
return
false
;
...
...
src/decoder/plugins/FaadDecoderPlugin.cxx
View file @
49784513
...
...
@@ -127,7 +127,7 @@ adts_song_duration(DecoderBuffer &buffer)
if
(
frames
==
0
)
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
assert
(
!
data
.
IsE
mpty
());
assert
(
!
data
.
e
mpty
());
assert
(
frame_length
<=
data
.
size
);
sample_rate
=
adts_sample_rates
[(
data
.
data
[
2
]
&
0x3c
)
>>
2
];
...
...
@@ -255,7 +255,7 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
AudioFormat
&
audio_format
)
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
throw
std
::
runtime_error
(
"Empty file"
);
uint8_t
channels
;
...
...
@@ -283,7 +283,7 @@ faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer &buffer,
NeAACDecFrameInfo
*
frame_info
)
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
return
nullptr
;
return
NeAACDecDecode
(
decoder
,
frame_info
,
...
...
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
49784513
...
...
@@ -617,7 +617,7 @@ FfmpegCheckTag(DecoderClient &client, InputStream &is,
TagBuilder
tag
;
FfmpegScanTag
(
format_context
,
audio_stream
,
tag
);
if
(
!
tag
.
IsE
mpty
())
if
(
!
tag
.
e
mpty
())
client
.
SubmitTag
(
is
,
tag
.
Commit
());
}
...
...
src/decoder/plugins/FlacMetadata.cxx
View file @
49784513
...
...
@@ -97,7 +97,7 @@ flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
if
(
handler
.
pair
!=
nullptr
)
{
const
char
*
comment
=
(
const
char
*
)
entry
->
entry
;
const
DivideString
split
(
comment
,
'='
);
if
(
split
.
IsDefined
()
&&
!
split
.
IsE
mpty
())
if
(
split
.
IsDefined
()
&&
!
split
.
e
mpty
())
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
split
.
GetFirst
(),
split
.
GetSecond
());
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
49784513
...
...
@@ -211,7 +211,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
&
rgi
,
add_tag_handler
,
&
tag_builder
)
&&
!
tag_builder
.
IsE
mpty
())
{
!
tag_builder
.
e
mpty
())
{
client
.
SubmitReplayGain
(
&
rgi
);
Tag
tag
=
tag_builder
.
Commit
();
...
...
src/decoder/plugins/PcmDecoderPlugin.cxx
View file @
49784513
...
...
@@ -44,7 +44,7 @@ FillBuffer(DecoderClient &client, InputStream &is, B &buffer)
{
buffer
.
Shift
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
if
(
w
.
e
mpty
())
return
true
;
size_t
nbytes
=
decoder_read
(
client
,
is
,
w
.
data
,
w
.
size
);
...
...
@@ -185,7 +185,7 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
r
.
size
=
(
r
.
size
/
3
)
*
4
;
}
cmd
=
!
r
.
IsE
mpty
()
cmd
=
!
r
.
e
mpty
()
?
client
.
SubmitData
(
is
,
r
.
data
,
r
.
size
,
0
)
:
client
.
GetCommand
();
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
...
...
src/event/BufferedSocket.cxx
View file @
49784513
...
...
@@ -53,7 +53,7 @@ BufferedSocket::ReadToBuffer()
assert
(
IsDefined
());
const
auto
buffer
=
input
.
Write
();
assert
(
!
buffer
.
IsE
mpty
());
assert
(
!
buffer
.
e
mpty
());
const
auto
nbytes
=
DirectRead
(
buffer
.
data
,
buffer
.
size
);
if
(
nbytes
>
0
)
...
...
@@ -69,7 +69,7 @@ BufferedSocket::ResumeInput()
while
(
true
)
{
const
auto
buffer
=
input
.
Read
();
if
(
buffer
.
IsE
mpty
())
{
if
(
buffer
.
e
mpty
())
{
ScheduleRead
();
return
true
;
}
...
...
src/event/FullyBufferedSocket.cxx
View file @
49784513
...
...
@@ -52,7 +52,7 @@ FullyBufferedSocket::Flush()
assert
(
IsDefined
());
const
auto
data
=
output
.
Read
();
if
(
data
.
IsE
mpty
())
{
if
(
data
.
e
mpty
())
{
IdleMonitor
::
Cancel
();
CancelWrite
();
return
true
;
...
...
@@ -64,7 +64,7 @@ FullyBufferedSocket::Flush()
output
.
Consume
(
nbytes
);
if
(
output
.
IsE
mpty
())
{
if
(
output
.
e
mpty
())
{
IdleMonitor
::
Cancel
();
CancelWrite
();
}
...
...
@@ -80,7 +80,7 @@ FullyBufferedSocket::Write(const void *data, size_t length)
if
(
length
==
0
)
return
true
;
const
bool
was_empty
=
output
.
IsE
mpty
();
const
bool
was_empty
=
output
.
e
mpty
();
if
(
!
output
.
Append
(
data
,
length
))
{
OnSocketError
(
std
::
make_exception_ptr
(
std
::
runtime_error
(
"Output buffer is full"
)));
...
...
@@ -96,7 +96,7 @@ bool
FullyBufferedSocket
::
OnSocketReady
(
unsigned
flags
)
{
if
(
flags
&
WRITE
)
{
assert
(
!
output
.
IsE
mpty
());
assert
(
!
output
.
e
mpty
());
assert
(
!
IdleMonitor
::
IsActive
());
if
(
!
Flush
())
...
...
@@ -112,6 +112,6 @@ FullyBufferedSocket::OnSocketReady(unsigned flags)
void
FullyBufferedSocket
::
OnIdle
()
{
if
(
Flush
()
&&
!
output
.
IsE
mpty
())
if
(
Flush
()
&&
!
output
.
e
mpty
())
ScheduleWrite
();
}
src/fs/io/BufferedOutputStream.cxx
View file @
49784513
...
...
@@ -70,7 +70,7 @@ void
BufferedOutputStream
::
Format
(
const
char
*
fmt
,
...)
{
auto
r
=
buffer
.
Write
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
Flush
();
r
=
buffer
.
Write
();
}
...
...
@@ -123,7 +123,7 @@ BufferedOutputStream::WriteWideToUTF8(const wchar_t *src, size_t src_length)
return
;
auto
r
=
buffer
.
Write
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
Flush
();
r
=
buffer
.
Write
();
}
...
...
@@ -158,7 +158,7 @@ void
BufferedOutputStream
::
Flush
()
{
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
if
(
r
.
e
mpty
())
return
;
os
.
Write
(
r
.
data
,
r
.
size
);
...
...
src/fs/io/BufferedReader.cxx
View file @
49784513
...
...
@@ -34,13 +34,13 @@ BufferedReader::Fill(bool need_more)
return
!
need_more
;
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
if
(
buffer
.
GetCapacity
()
>=
MAX_SIZE
)
return
!
need_more
;
buffer
.
Grow
(
buffer
.
GetCapacity
()
*
2
);
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
}
size_t
nbytes
=
reader
.
Read
(
w
.
data
,
w
.
size
);
...
...
@@ -104,14 +104,14 @@ BufferedReader::ReadLine()
}
}
while
(
Fill
(
true
));
if
(
!
eof
||
buffer
.
IsE
mpty
())
if
(
!
eof
||
buffer
.
e
mpty
())
return
nullptr
;
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
buffer
.
Grow
(
buffer
.
GetCapacity
()
+
1
);
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
}
/* terminate the last line */
...
...
src/fs/io/GunzipReader.cxx
View file @
49784513
...
...
@@ -39,7 +39,7 @@ inline bool
GunzipReader
::
FillBuffer
()
{
auto
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
size_t
nbytes
=
next
.
Read
(
w
.
data
,
w
.
size
);
if
(
nbytes
==
0
)
...
...
@@ -62,7 +62,7 @@ GunzipReader::Read(void *data, size_t size)
int
flush
=
Z_NO_FLUSH
;
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
if
(
FillBuffer
())
r
=
buffer
.
Read
();
else
...
...
src/input/AsyncInputStream.cxx
View file @
49784513
...
...
@@ -88,7 +88,7 @@ bool
AsyncInputStream
::
IsEOF
()
noexcept
{
return
(
KnownSize
()
&&
offset
>=
size
)
||
(
!
open
&&
buffer
.
IsE
mpty
());
(
!
open
&&
buffer
.
e
mpty
());
}
void
...
...
@@ -108,7 +108,7 @@ AsyncInputStream::Seek(offset_type new_offset)
while
(
new_offset
>
offset
)
{
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
if
(
r
.
e
mpty
())
break
;
const
size_t
nbytes
=
...
...
@@ -162,7 +162,7 @@ AsyncInputStream::IsAvailable() noexcept
{
return
postponed_exception
||
IsEOF
()
||
!
buffer
.
IsE
mpty
();
!
buffer
.
e
mpty
();
}
size_t
...
...
@@ -176,7 +176,7 @@ AsyncInputStream::Read(void *ptr, size_t read_size)
Check
();
r
=
buffer
.
Read
();
if
(
!
r
.
IsE
mpty
()
||
IsEOF
())
if
(
!
r
.
e
mpty
()
||
IsEOF
())
break
;
cond
.
wait
(
mutex
);
...
...
@@ -209,7 +209,7 @@ void
AsyncInputStream
::
AppendToBuffer
(
const
void
*
data
,
size_t
append_size
)
noexcept
{
auto
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
size_t
nbytes
=
std
::
min
(
w
.
size
,
append_size
);
memcpy
(
w
.
data
,
data
,
nbytes
);
...
...
@@ -218,7 +218,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) noexcept
const
size_t
remaining
=
append_size
-
nbytes
;
if
(
remaining
>
0
)
{
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
assert
(
w
.
size
>=
remaining
);
memcpy
(
w
.
data
,
(
const
uint8_t
*
)
data
+
nbytes
,
remaining
);
...
...
src/input/AsyncInputStream.hxx
View file @
49784513
...
...
@@ -114,7 +114,7 @@ protected:
}
bool
IsBufferEmpty
()
const
noexcept
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
bool
IsBufferFull
()
const
noexcept
{
...
...
src/input/TextInputStream.cxx
View file @
49784513
...
...
@@ -47,7 +47,7 @@ TextInputStream::ReadLine()
/* line too long: terminate the current
line */
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
dest
[
0
]
=
0
;
line
=
buffer
.
Read
().
data
;
buffer
.
Clear
();
...
...
@@ -79,12 +79,12 @@ TextInputStream::ReadLine()
line */
dest
=
buffer
.
Write
();
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
dest
[
0
]
=
0
;
auto
r
=
buffer
.
Read
();
buffer
.
Clear
();
return
r
.
IsE
mpty
()
return
r
.
e
mpty
()
?
nullptr
:
r
.
data
;
}
...
...
src/input/ThreadInputStream.cxx
View file @
49784513
...
...
@@ -80,7 +80,7 @@ ThreadInputStream::ThreadFunc()
assert
(
!
postponed_exception
);
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
wake_cond
.
wait
(
mutex
);
}
else
{
size_t
nbytes
;
...
...
@@ -122,7 +122,7 @@ ThreadInputStream::IsAvailable() noexcept
{
assert
(
!
thread
.
IsInside
());
return
!
buffer
.
IsE
mpty
()
||
eof
||
postponed_exception
;
return
!
buffer
.
e
mpty
()
||
eof
||
postponed_exception
;
}
inline
size_t
...
...
@@ -135,7 +135,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
std
::
rethrow_exception
(
postponed_exception
);
auto
r
=
buffer
.
Read
();
if
(
!
r
.
IsE
mpty
())
{
if
(
!
r
.
e
mpty
())
{
size_t
nbytes
=
std
::
min
(
read_size
,
r
.
size
);
memcpy
(
ptr
,
r
.
data
,
nbytes
);
buffer
.
Consume
(
nbytes
);
...
...
src/lib/xiph/VorbisComments.cxx
View file @
49784513
...
...
@@ -71,7 +71,7 @@ vorbis_scan_comment(const char *comment,
{
if
(
handler
.
pair
!=
nullptr
)
{
const
DivideString
split
(
comment
,
'='
);
if
(
split
.
IsDefined
()
&&
!
split
.
IsE
mpty
())
if
(
split
.
IsDefined
()
&&
!
split
.
e
mpty
())
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
split
.
GetFirst
(),
split
.
GetSecond
());
...
...
@@ -104,7 +104,7 @@ vorbis_comments_to_tag(char **comments)
{
TagBuilder
tag_builder
;
vorbis_comments_scan
(
comments
,
add_tag_handler
,
&
tag_builder
);
return
tag_builder
.
IsE
mpty
()
return
tag_builder
.
e
mpty
()
?
nullptr
:
tag_builder
.
CommitNew
();
}
src/output/Source.cxx
View file @
49784513
...
...
@@ -138,7 +138,7 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk,
assert
(
data
.
size
%
in_audio_format
.
GetFrameSize
()
==
0
);
if
(
!
data
.
IsE
mpty
()
&&
replay_gain_filter
!=
nullptr
)
{
if
(
!
data
.
e
mpty
()
&&
replay_gain_filter
!=
nullptr
)
{
replay_gain_filter_set_mode
(
*
replay_gain_filter
,
replay_gain_mode
);
...
...
@@ -161,7 +161,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
{
auto
data
=
GetChunkData
(
chunk
,
replay_gain_filter_instance
,
&
replay_gain_serial
);
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
return
data
;
/* cross-fade */
...
...
@@ -170,7 +170,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
auto
other_data
=
GetChunkData
(
*
chunk
.
other
,
other_replay_gain_filter_instance
,
&
other_replay_gain_serial
);
if
(
other_data
.
IsE
mpty
())
if
(
other_data
.
e
mpty
())
return
data
;
/* if the "other" chunk is longer, then that trailer
...
...
@@ -211,7 +211,7 @@ bool
AudioOutputSource
::
Fill
(
Mutex
&
mutex
)
{
if
(
current_chunk
!=
nullptr
&&
pending_tag
==
nullptr
&&
pending_data
.
IsE
mpty
())
pending_data
.
e
mpty
())
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
if
(
current_chunk
!=
nullptr
)
...
...
@@ -242,6 +242,6 @@ AudioOutputSource::ConsumeData(size_t nbytes) noexcept
{
pending_data
.
skip_front
(
nbytes
);
if
(
pending_data
.
IsE
mpty
())
if
(
pending_data
.
e
mpty
())
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
}
src/output/Thread.cxx
View file @
49784513
...
...
@@ -259,7 +259,7 @@ AudioOutputControl::PlayChunk() noexcept
while
(
command
==
Command
::
NONE
)
{
const
auto
data
=
source
.
PeekData
();
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
break
;
if
(
skip_delay
)
...
...
src/pcm/PcmDsd.cxx
View file @
49784513
...
...
@@ -48,7 +48,7 @@ ConstBuffer<float>
PcmDsd
::
ToFloat
(
unsigned
channels
,
ConstBuffer
<
uint8_t
>
src
)
{
assert
(
!
src
.
IsNull
());
assert
(
!
src
.
IsE
mpty
());
assert
(
!
src
.
e
mpty
());
assert
(
src
.
size
%
channels
==
0
);
assert
(
channels
<=
dsd2pcm
.
max_size
());
...
...
src/tag/Builder.cxx
View file @
49784513
...
...
@@ -191,7 +191,7 @@ TagBuilder::Complement(const Tag &other)
inline
void
TagBuilder
::
AddItemInternal
(
TagType
type
,
StringView
value
)
{
assert
(
!
value
.
IsE
mpty
());
assert
(
!
value
.
e
mpty
());
auto
f
=
FixTagString
(
value
);
if
(
!
f
.
IsNull
())
...
...
@@ -209,7 +209,7 @@ TagBuilder::AddItemInternal(TagType type, StringView value)
void
TagBuilder
::
AddItem
(
TagType
type
,
StringView
value
)
{
if
(
value
.
IsE
mpty
()
||
!
IsTagEnabled
(
type
))
if
(
value
.
e
mpty
()
||
!
IsTagEnabled
(
type
))
return
;
AddItemInternal
(
type
,
value
);
...
...
src/tag/Builder.hxx
View file @
49784513
...
...
@@ -74,7 +74,7 @@ public:
* Returns true if the tag contains no items. This ignores
* the "duration" attribute.
*/
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
items
.
empty
();
}
...
...
@@ -83,7 +83,7 @@ public:
*/
gcc_pure
bool
IsDefined
()
const
noexcept
{
return
!
duration
.
IsNegative
()
||
has_playlist
||
!
IsE
mpty
();
return
!
duration
.
IsNegative
()
||
has_playlist
||
!
e
mpty
();
}
void
Clear
();
...
...
src/tag/Id3Scan.cxx
View file @
49784513
...
...
@@ -334,7 +334,7 @@ tag_id3_import(struct id3_tag *tag)
{
TagBuilder
tag_builder
;
scan_id3_tag
(
tag
,
add_tag_handler
,
&
tag_builder
);
return
tag_builder
.
IsE
mpty
()
return
tag_builder
.
e
mpty
()
?
nullptr
:
tag_builder
.
CommitNew
();
}
...
...
src/util/AllocatedArray.hxx
View file @
49784513
...
...
@@ -112,7 +112,7 @@ public:
* Returns true if no memory was allocated so far.
*/
constexpr
bool
empty
()
const
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
/**
...
...
src/util/CircularBuffer.hxx
View file @
49784513
...
...
@@ -90,7 +90,7 @@ public:
return
capacity
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
head
==
tail
;
}
...
...
src/util/ConstBuffer.hxx
View file @
49784513
...
...
@@ -84,7 +84,7 @@ struct ConstBuffer<void> {
return
data
!=
nullptr
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
}
};
...
...
@@ -167,7 +167,7 @@ struct ConstBuffer {
return
data
!=
nullptr
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
}
...
...
@@ -217,7 +217,7 @@ struct ConstBuffer {
#endif
reference_type
front
()
const
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
return
data
[
0
];
}
...
...
@@ -231,7 +231,7 @@ struct ConstBuffer {
#endif
reference_type
back
()
const
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
return
data
[
size
-
1
];
}
...
...
@@ -242,7 +242,7 @@ struct ConstBuffer {
*/
void
pop_front
()
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
++
data
;
...
...
@@ -255,7 +255,7 @@ struct ConstBuffer {
*/
void
pop_back
()
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
--
size
;
...
...
src/util/DivideString.hxx
View file @
49784513
...
...
@@ -53,7 +53,7 @@ public:
/**
* Is the first part empty?
*/
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
assert
(
IsDefined
());
return
*
first
==
0
;
...
...
src/util/DynamicFifoBuffer.hxx
View file @
49784513
...
...
@@ -55,7 +55,7 @@ public:
using
ForeignFifoBuffer
<
T
>::
GetCapacity
;
using
ForeignFifoBuffer
<
T
>::
Clear
;
using
ForeignFifoBuffer
<
T
>::
IsE
mpty
;
using
ForeignFifoBuffer
<
T
>::
e
mpty
;
using
ForeignFifoBuffer
<
T
>::
IsFull
;
using
ForeignFifoBuffer
<
T
>::
GetAvailable
;
using
ForeignFifoBuffer
<
T
>::
Read
;
...
...
src/util/ForeignFifoBuffer.hxx
View file @
49784513
...
...
@@ -134,7 +134,7 @@ public:
head
=
tail
=
0
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
head
==
tail
;
}
...
...
@@ -147,7 +147,7 @@ public:
* When you are finished, call Append().
*/
Range
Write
()
{
if
(
IsE
mpty
())
if
(
e
mpty
())
Clear
();
else
if
(
tail
==
capacity
)
Shift
();
...
...
src/util/PeakBuffer.cxx
View file @
49784513
...
...
@@ -32,10 +32,10 @@ PeakBuffer::~PeakBuffer()
}
bool
PeakBuffer
::
IsE
mpty
()
const
noexcept
PeakBuffer
::
e
mpty
()
const
noexcept
{
return
(
normal_buffer
==
nullptr
||
normal_buffer
->
IsE
mpty
())
&&
(
peak_buffer
==
nullptr
||
peak_buffer
->
IsE
mpty
());
return
(
normal_buffer
==
nullptr
||
normal_buffer
->
e
mpty
())
&&
(
peak_buffer
==
nullptr
||
peak_buffer
->
e
mpty
());
}
WritableBuffer
<
void
>
...
...
@@ -43,13 +43,13 @@ PeakBuffer::Read() const noexcept
{
if
(
normal_buffer
!=
nullptr
)
{
const
auto
p
=
normal_buffer
->
Read
();
if
(
!
p
.
IsE
mpty
())
if
(
!
p
.
e
mpty
())
return
p
.
ToVoid
();
}
if
(
peak_buffer
!=
nullptr
)
{
const
auto
p
=
peak_buffer
->
Read
();
if
(
!
p
.
IsE
mpty
())
if
(
!
p
.
e
mpty
())
return
p
.
ToVoid
();
}
...
...
@@ -59,14 +59,14 @@ PeakBuffer::Read() const noexcept
void
PeakBuffer
::
Consume
(
size_t
length
)
noexcept
{
if
(
normal_buffer
!=
nullptr
&&
!
normal_buffer
->
IsE
mpty
())
{
if
(
normal_buffer
!=
nullptr
&&
!
normal_buffer
->
e
mpty
())
{
normal_buffer
->
Consume
(
length
);
return
;
}
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
e
mpty
())
{
peak_buffer
->
Consume
(
length
);
if
(
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
->
e
mpty
())
{
delete
peak_buffer
;
peak_buffer
=
nullptr
;
}
...
...
@@ -86,7 +86,7 @@ AppendTo(DynamicFifoBuffer<uint8_t> &buffer,
do
{
const
auto
p
=
buffer
.
Write
();
if
(
p
.
IsE
mpty
())
if
(
p
.
e
mpty
())
break
;
const
size_t
nbytes
=
std
::
min
(
length
,
p
.
size
);
...
...
@@ -107,7 +107,7 @@ PeakBuffer::Append(const void *data, size_t length)
if
(
length
==
0
)
return
true
;
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
e
mpty
())
{
size_t
nbytes
=
AppendTo
(
*
peak_buffer
,
data
,
length
);
return
nbytes
==
length
;
}
...
...
src/util/PeakBuffer.hxx
View file @
49784513
...
...
@@ -57,7 +57,7 @@ public:
PeakBuffer
&
operator
=
(
const
PeakBuffer
&
)
=
delete
;
gcc_pure
bool
IsE
mpty
()
const
noexcept
;
bool
e
mpty
()
const
noexcept
;
gcc_pure
WritableBuffer
<
void
>
Read
()
const
noexcept
;
...
...
src/util/SliceBuffer.hxx
View file @
49784513
...
...
@@ -79,7 +79,7 @@ public:
return
buffer
.
size
();
}
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
n_allocated
==
0
;
}
...
...
src/util/StaticFifoBuffer.hxx
View file @
49784513
...
...
@@ -78,7 +78,7 @@ public:
head
=
tail
=
0
;
}
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
head
==
tail
;
}
...
...
@@ -91,7 +91,7 @@ public:
* When you are finished, call Append().
*/
Range
Write
()
{
if
(
IsE
mpty
())
if
(
e
mpty
())
Clear
();
else
if
(
tail
==
size
)
Shift
();
...
...
src/util/StringView.cxx
View file @
49784513
...
...
@@ -34,7 +34,7 @@ template<typename T>
void
BasicStringView
<
T
>::
StripLeft
()
noexcept
{
while
(
!
IsE
mpty
()
&&
IsWhitespaceOrNull
(
front
()))
while
(
!
e
mpty
()
&&
IsWhitespaceOrNull
(
front
()))
pop_front
();
}
...
...
@@ -42,7 +42,7 @@ template<typename T>
void
BasicStringView
<
T
>::
StripRight
()
noexcept
{
while
(
!
IsE
mpty
()
&&
IsWhitespaceOrNull
(
back
()))
while
(
!
e
mpty
()
&&
IsWhitespaceOrNull
(
back
()))
pop_back
();
}
...
...
src/util/StringView.hxx
View file @
49784513
...
...
@@ -58,7 +58,7 @@ struct BasicStringView : ConstBuffer<T> {
constexpr
BasicStringView
(
std
::
nullptr_t
n
)
noexcept
:
ConstBuffer
<
T
>
(
n
)
{}
using
ConstBuffer
<
T
>::
IsE
mpty
;
using
ConstBuffer
<
T
>::
e
mpty
;
using
ConstBuffer
<
T
>::
front
;
using
ConstBuffer
<
T
>::
back
;
using
ConstBuffer
<
T
>::
pop_front
;
...
...
src/util/UriUtil.cxx
View file @
49784513
...
...
@@ -41,7 +41,7 @@ gcc_pure
static
bool
IsValidScheme
(
StringView
p
)
noexcept
{
if
(
p
.
IsE
mpty
()
||
!
IsValidSchemeStart
(
p
.
front
()))
if
(
p
.
e
mpty
()
||
!
IsValidSchemeStart
(
p
.
front
()))
return
false
;
for
(
size_t
i
=
1
;
i
<
p
.
size
;
++
i
)
...
...
src/util/WritableBuffer.hxx
View file @
49784513
...
...
@@ -76,7 +76,7 @@ struct WritableBuffer<void> {
return
data
!=
nullptr
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
}
};
...
...
@@ -161,7 +161,7 @@ struct WritableBuffer {
return
data
!=
nullptr
;
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
}
...
...
@@ -201,7 +201,7 @@ struct WritableBuffer {
#endif
reference_type
front
()
const
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
return
data
[
0
];
}
...
...
@@ -215,7 +215,7 @@ struct WritableBuffer {
#endif
reference_type
back
()
const
{
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
return
data
[
size
-
1
];
}
...
...
@@ -225,7 +225,7 @@ struct WritableBuffer {
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_front
()
{
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
++
data
;
--
size
;
...
...
@@ -236,7 +236,7 @@ struct WritableBuffer {
* not actually modify the buffer). Buffer must not be empty.
*/
void
pop_back
()
{
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
--
size
;
}
...
...
test/DivideStringTest.hxx
View file @
49784513
...
...
@@ -23,7 +23,7 @@ public:
constexpr
char
input
[]
=
"foo.bar"
;
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
!
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
!
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
input
+
4
,
ds
.
GetSecond
());
}
...
...
@@ -32,7 +32,7 @@ public:
constexpr
char
input
[]
=
".bar"
;
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
""
));
CPPUNIT_ASSERT_EQUAL
(
input
+
1
,
ds
.
GetSecond
());
}
...
...
@@ -47,7 +47,7 @@ public:
constexpr
char
input
[]
=
" foo
\t
.
\n
bar
\r
"
;
const
DivideString
ds
(
input
,
'.'
,
true
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
!
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
!
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
input
+
7
,
ds
.
GetSecond
());
}
...
...
test/TestCircularBuffer.hxx
View file @
49784513
...
...
@@ -25,52 +25,52 @@ public:
/* checks on empty buffer */
/* [.......X] */
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Write
().
size
);
/* append one element */
/* [O......X] */
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Write
().
size
);
/* append 6 elements, buffer is now full */
/* [OOOOOOOX] */
buffer
.
Append
(
6
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [0]; can append one at [7] */
/* [XOOOOOO.] */
buffer
.
Consume
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
7
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
...
...
@@ -78,66 +78,66 @@ public:
be written to because head==1 */
/* [XOOOOOOO] */
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [1..3]; can append [0..2] */
/* [...XOOOO] */
buffer
.
Consume
(
3
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Write
().
size
);
/* append [0..1] */
/* [OO.XOOOO] */
buffer
.
Append
(
2
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
2
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
/* append [2] */
/* [OOOXOOOO] */
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [4..7] */
/* [OOO....X] */
buffer
.
Consume
(
4
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Write
().
size
);
...
...
@@ -146,12 +146,12 @@ public:
special code to rewind/reset an empty buffer */
/* [..X.....] */
buffer
.
Consume
(
3
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
5
),
buffer
.
Write
().
size
);
}
...
...
test/run_convert.cxx
View file @
49784513
...
...
@@ -62,7 +62,7 @@ try {
while
(
true
)
{
{
const
auto
dest
=
buffer
.
Write
();
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
ssize_t
nbytes
=
read
(
0
,
dest
.
data
,
dest
.
size
);
if
(
nbytes
<=
0
)
...
...
@@ -72,10 +72,10 @@ try {
}
auto
src
=
buffer
.
Read
();
assert
(
!
src
.
IsE
mpty
());
assert
(
!
src
.
e
mpty
());
src
.
size
-=
src
.
size
%
in_frame_size
;
if
(
src
.
IsE
mpty
())
if
(
src
.
e
mpty
())
continue
;
buffer
.
Consume
(
src
.
size
);
...
...
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