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
ab9c5272
Commit
ab9c5272
authored
Aug 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StaticFifoBuffer: fix indent
parent
36ff9919
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
68 deletions
+68
-68
StaticFifoBuffer.hxx
src/util/StaticFifoBuffer.hxx
+68
-68
No files found.
src/util/StaticFifoBuffer.hxx
View file @
ab9c5272
...
@@ -46,87 +46,87 @@
...
@@ -46,87 +46,87 @@
template
<
class
T
,
size_t
size
>
template
<
class
T
,
size_t
size
>
class
StaticFifoBuffer
{
class
StaticFifoBuffer
{
public
:
public
:
typedef
size_t
size_type
;
typedef
size_t
size_type
;
public
:
public
:
typedef
WritableBuffer
<
T
>
Range
;
typedef
WritableBuffer
<
T
>
Range
;
protected
:
protected
:
size_type
head
,
tail
;
size_type
head
,
tail
;
T
data
[
size
];
T
data
[
size
];
public
:
public
:
constexpr
constexpr
StaticFifoBuffer
()
:
head
(
0
),
tail
(
0
)
{}
StaticFifoBuffer
()
:
head
(
0
),
tail
(
0
)
{}
protected
:
protected
:
void
Shift
()
{
void
Shift
()
{
if
(
head
==
0
)
if
(
head
==
0
)
return
;
return
;
assert
(
head
<=
size
);
assert
(
head
<=
size
);
assert
(
tail
<=
size
);
assert
(
tail
<=
size
);
assert
(
tail
>=
head
);
assert
(
tail
>=
head
);
std
::
move
(
data
+
head
,
data
+
tail
,
data
);
std
::
move
(
data
+
head
,
data
+
tail
,
data
);
tail
-=
head
;
tail
-=
head
;
head
=
0
;
head
=
0
;
}
}
public
:
public
:
void
Clear
()
{
void
Clear
()
{
head
=
tail
=
0
;
head
=
tail
=
0
;
}
}
bool
IsEmpty
()
const
{
bool
IsEmpty
()
const
{
return
head
==
tail
;
return
head
==
tail
;
}
}
bool
IsFull
()
const
{
bool
IsFull
()
const
{
return
head
==
0
&&
tail
==
size
;
return
head
==
0
&&
tail
==
size
;
}
}
/**
/**
* Prepares writing. Returns a buffer range which may be written.
* Prepares writing. Returns a buffer range which may be written.
* When you are finished, call append().
* When you are finished, call append().
*/
*/
Range
Write
()
{
Range
Write
()
{
Shift
();
Shift
();
return
Range
(
data
+
tail
,
size
-
tail
);
return
Range
(
data
+
tail
,
size
-
tail
);
}
}
/**
/**
* Expands the tail of the buffer, after data has been written to
* Expands the tail of the buffer, after data has been written to
* the buffer returned by write().
* the buffer returned by write().
*/
*/
void
Append
(
size_type
n
)
{
void
Append
(
size_type
n
)
{
assert
(
tail
<=
size
);
assert
(
tail
<=
size
);
assert
(
n
<=
size
);
assert
(
n
<=
size
);
assert
(
tail
+
n
<=
size
);
assert
(
tail
+
n
<=
size
);
tail
+=
n
;
tail
+=
n
;
}
}
/**
/**
* Return a buffer range which may be read. The buffer pointer is
* Return a buffer range which may be read. The buffer pointer is
* writable, to allow modifications while parsing.
* writable, to allow modifications while parsing.
*/
*/
Range
Read
()
{
Range
Read
()
{
return
Range
(
data
+
head
,
tail
-
head
);
return
Range
(
data
+
head
,
tail
-
head
);
}
}
/**
/**
* Marks a chunk as consumed.
* Marks a chunk as consumed.
*/
*/
void
Consume
(
size_type
n
)
{
void
Consume
(
size_type
n
)
{
assert
(
tail
<=
size
);
assert
(
tail
<=
size
);
assert
(
head
<=
tail
);
assert
(
head
<=
tail
);
assert
(
n
<=
tail
);
assert
(
n
<=
tail
);
assert
(
head
+
n
<=
tail
);
assert
(
head
+
n
<=
tail
);
head
+=
n
;
head
+=
n
;
}
}
};
};
#endif
#endif
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