Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
folly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
folly
Commits
1034506c
Commit
1034506c
authored
Jun 11, 2012
by
Tudor Bosman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor changes to folly/experimental/io
Reviewed By: philipp@fb.com FB internal diff: D491952
parent
2e76cb01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
folly/Bits.h
folly/Bits.h
+14
-0
folly/experimental/io/IOBufQueue.h
folly/experimental/io/IOBufQueue.h
+10
-0
folly/experimental/io/TypedIOBuf.h
folly/experimental/io/TypedIOBuf.h
+29
-0
No files found.
folly/Bits.h
View file @
1034506c
...
...
@@ -329,6 +329,20 @@ struct EndianInt : public detail::EndianIntBase<T> {
class
Endian
{
public:
enum
class
Order
:
uint8_t
{
LITTLE
,
BIG
};
static
constexpr
Order
order
=
#if __BYTE_ORDER == __LITTLE_ENDIAN
Order
::
LITTLE
;
#elif __BYTE_ORDER == __BIG_ENDIAN
Order
::
BIG
;
#else
# error Your machine uses a weird endianness!
#endif
/* __BYTE_ORDER */
template
<
class
T
>
static
T
swap
(
T
x
)
{
return
detail
::
EndianInt
<
T
>::
swap
(
x
);
}
...
...
folly/experimental/io/IOBufQueue.h
View file @
1034506c
...
...
@@ -36,6 +36,16 @@ class IOBufQueue {
bool
cacheChainLength
;
};
/**
* Commonly used Options, currently the only possible value other than
* the default.
*/
static
Options
cacheChainLength
()
{
Options
options
;
options
.
cacheChainLength
=
true
;
return
options
;
}
explicit
IOBufQueue
(
const
Options
&
options
=
Options
());
/**
...
...
folly/experimental/io/TypedIOBuf.h
View file @
1034506c
...
...
@@ -17,6 +17,8 @@
#ifndef FOLLY_IO_TYPEDIOBUF_H_
#define FOLLY_IO_TYPEDIOBUF_H_
#include <algorithm>
#include <iterator>
#include <type_traits>
#include "folly/experimental/io/IOBuf.h"
...
...
@@ -106,6 +108,33 @@ class TypedIOBuf {
buf_
->
reserve
(
smul
(
minHeadroom
),
smul
(
minTailroom
));
}
/**
* Simple wrapper to make it easier to treat this TypedIOBuf as an array of
* T.
*/
const
T
&
operator
[](
ssize_t
idx
)
const
{
assert
(
idx
>=
0
&&
idx
<
length
());
return
data
()[
idx
];
}
/**
* Append one element.
*/
void
push
(
const
T
&
data
)
{
push
(
&
data
,
&
data
+
1
);
}
/**
* Append multiple elements in a sequence; will call distance().
*/
template
<
class
IT
>
void
push
(
IT
begin
,
IT
end
)
{
auto
n
=
std
::
distance
(
begin
,
end
);
reserve
(
headroom
(),
n
);
std
::
copy
(
begin
,
end
,
writableTail
());
append
(
n
);
}
// Movable
TypedIOBuf
(
TypedIOBuf
&&
)
=
default
;
TypedIOBuf
&
operator
=
(
TypedIOBuf
&&
)
=
default
;
...
...
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