Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
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
pistache
Commits
71a467ce
Commit
71a467ce
authored
Dec 07, 2015
by
octal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bunch of errors reported by clang that were not reported by gcc
parent
7e2866dd
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
70 additions
and
39 deletions
+70
-39
CMakeLists.txt
CMakeLists.txt
+9
-2
src/async.h
src/async.h
+30
-26
src/http.h
src/http.h
+2
-0
src/http_defs.cc
src/http_defs.cc
+2
-0
src/http_header.cc
src/http_header.cc
+9
-3
src/http_header.h
src/http_header.h
+0
-2
src/http_headers.cc
src/http_headers.cc
+1
-0
src/mime.cc
src/mime.cc
+6
-0
src/net.h
src/net.h
+5
-5
src/optional.h
src/optional.h
+6
-1
No files found.
CMakeLists.txt
View file @
71a467ce
cmake_minimum_required
(
VERSION 2.8.7
)
project
(
restgear
)
include
(
CheckCXXCompilerFlag
)
if
(
CMAKE_COMPILER_IS_GNUCXX
)
add_definitions
(
-std=c++0x
)
CHECK_CXX_COMPILER_FLAG
(
"-std=c++11"
COMPILER_SUPPORTS_CXX11
)
CHECK_CXX_COMPILER_FLAG
(
"-std=c++0x"
COMPILER_SUPPORTS_CXX0X
)
if
(
COMPILER_SUPPORTS_CXX11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
elseif
(
COMPILER_SUPPORTS_CXX0X
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++0x"
)
else
()
message
(
STATUS
"The compiler
${
CMAKE_CXX_COMPILER
}
has no C++11 support. Please use a different C++ compiler."
)
endif
()
add_subdirectory
(
src
)
...
...
src/async.h
View file @
71a467ce
...
...
@@ -437,6 +437,7 @@ namespace Async {
class
Resolver
{
public:
Resolver
(
const
std
::
shared_ptr
<
Private
::
Core
>
&
core
)
:
core_
(
core
)
{
}
...
...
@@ -484,11 +485,11 @@ namespace Async {
class
Rejection
{
public:
Rejection
(
const
std
::
shared_ptr
<
Private
::
Core
>&
core
)
:
core_
(
core
)
{
}
template
<
typename
Exc
>
bool
operator
()(
Exc
exc
)
const
{
if
(
core_
->
state
!=
State
::
Pending
)
...
...
@@ -508,8 +509,8 @@ namespace Async {
};
static
constexpr
Private
::
IgnoreException
IgnoreException
;
static
constexpr
Private
::
NoExcept
NoExcept
;
static
constexpr
Private
::
IgnoreException
IgnoreException
{}
;
static
constexpr
Private
::
NoExcept
NoExcept
{}
;
template
<
typename
T
>
class
Promise
:
public
PromiseBase
...
...
@@ -812,16 +813,16 @@ namespace Async {
typename
Results
=
std
::
vector
<
ValueType
>
>
Promise
<
Results
>
whenAll
(
Iterator
first
,
Iterator
last
)
{
return
Promise
<
Results
>
([
=
](
Resolver
&
resolve
,
Rejection
&
rejection
)
{
/* @Security, assert that last >= first */
struct
Data
{
Data
(
const
size_t
total
,
Resolver
resolver
,
Rejection
rejection
)
public:
Data
(
size_t
total
,
Resolver
resolver
,
Rejection
rejection
)
:
total
(
total
)
,
resolved
(
0
)
,
rejected
(
false
)
,
resolve
(
std
::
move
(
resolver
)
)
,
reject
(
std
::
move
(
rejection
)
)
,
resolve
(
resolver
)
,
reject
(
rejection
)
{
results
.
resize
(
total
);
}
...
...
@@ -830,16 +831,19 @@ namespace Async {
std
::
atomic
<
size_t
>
resolved
;
std
::
atomic
<
bool
>
rejected
;
Results
results
;
Resolver
resolve
;
Rejection
reject
;
Results
results
;
};
return
Promise
<
Results
>
([
=
](
Resolver
&
resolve
,
Rejection
&
rejection
)
{
auto
data
=
std
::
make_shared
<
Data
>
(
st
d
::
distance
(
first
,
last
),
resolve
,
rejection
st
atic_cast
<
size_t
>
(
std
::
distance
(
first
,
last
)
),
std
::
move
(
resolve
)
,
std
::
move
(
rejection
)
);
size_t
index
=
0
;
...
...
src/http.h
View file @
71a467ce
...
...
@@ -33,6 +33,8 @@ template< class CharT, class Traits>
std
::
basic_ostream
<
CharT
,
Traits
>&
crlf
(
std
::
basic_ostream
<
CharT
,
Traits
>&
os
)
{
static
constexpr
char
CRLF
[]
=
{
0xD
,
0xA
};
os
.
write
(
CRLF
,
2
);
return
os
;
}
// 4. HTTP Message
...
...
src/http_defs.cc
View file @
71a467ce
...
...
@@ -25,6 +25,7 @@ namespace {
bool
parseAscTimeDate
(
std
::
tm
&
tm
,
const
char
*
str
,
size_t
len
)
{
char
*
p
=
strptime
(
str
,
"%a %b %d %H:%M:%S %Y"
,
&
tm
);
return
p
!=
NULL
;
}
}
// anonymous namespace
...
...
@@ -139,6 +140,7 @@ std::ostream& operator<<(std::ostream& os, Method method) {
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Code
code
)
{
os
<<
codeString
(
code
);
return
os
;
}
HttpError
::
HttpError
(
Code
code
,
std
::
string
reason
)
...
...
src/http_header.cc
View file @
71a467ce
...
...
@@ -171,7 +171,7 @@ CacheControl::parseRaw(const char* str, size_t len) {
}
int
c
;
while
((
c
=
cursor
.
current
())
!=
StreamCursor
::
Eof
&&
c
==
','
||
c
==
' '
)
while
((
c
=
cursor
.
current
())
!=
StreamCursor
::
Eof
&&
(
c
==
','
||
c
==
' '
)
)
cursor
.
advance
(
1
);
}
...
...
@@ -209,6 +209,8 @@ CacheControl::write(std::ostream& os) const {
return
"min-fresh"
;
case
CacheDirective
:
:
SMaxAge
:
return
"s-maxage"
;
case
CacheDirective
:
:
Ext
:
return
""
;
}
};
...
...
@@ -219,8 +221,9 @@ CacheControl::write(std::ostream& os) const {
case
CacheDirective
:
:
MinFresh
:
case
CacheDirective
:
:
SMaxAge
:
return
true
;
}
default:
return
false
;
}
};
for
(
std
::
vector
<
CacheDirective
>::
size_type
i
=
0
;
i
<
directives_
.
size
();
++
i
)
{
...
...
@@ -312,7 +315,10 @@ Host::parse(const std::string& data) {
void
Host
::
write
(
std
::
ostream
&
os
)
const
{
os
<<
host_
;
if
(
port_
!=
-
1
)
{
/* @Clarity @Robustness: maybe a found a literal different than zero
to represent a null port ?
*/
if
(
port_
!=
0
)
{
os
<<
":"
<<
port_
;
}
}
...
...
src/http_header.h
View file @
71a467ce
...
...
@@ -308,8 +308,6 @@ public:
NAME
(
"Host"
);
Host
()
:
host_
()
,
port_
(
-
1
)
{
}
explicit
Host
(
const
std
::
string
&
host
,
Net
::
Port
port
=
80
)
...
...
src/http_headers.cc
View file @
71a467ce
...
...
@@ -81,6 +81,7 @@ Collection::add(const std::shared_ptr<Header>& header) {
Collection
&
Collection
::
addRaw
(
const
Raw
&
raw
)
{
rawHeaders
.
insert
(
std
::
make_pair
(
raw
.
name
(),
raw
));
return
*
this
;
}
std
::
shared_ptr
<
const
Header
>
...
...
src/mime.cc
View file @
71a467ce
...
...
@@ -228,6 +228,8 @@ MediaType::toString() const {
return str;
MIME_TYPES
#undef TYPE
default:
return
""
;
}
};
...
...
@@ -238,6 +240,8 @@ MediaType::toString() const {
return str;
MIME_SUBTYPES
#undef TYPE
default:
return
""
;
}
};
...
...
@@ -248,6 +252,8 @@ MediaType::toString() const {
return "+" str;
MIME_SUFFIXES
#undef SUFFIX
default:
return
""
;
}
};
...
...
src/net.h
View file @
71a467ce
...
...
@@ -96,14 +96,14 @@ digitsCount(T val) {
template
<
>
struct
Size
<
const
char
*>
{
size_t
operator
()(
const
char
*
s
)
{
size_t
operator
()(
const
char
*
s
)
const
{
return
std
::
strlen
(
s
);
}
};
template
<
size_t
N
>
struct
Size
<
char
[
N
]
>
{
constexpr
size_t
operator
()(
const
char
(
&
arr
)[
N
])
{
constexpr
size_t
operator
()(
const
char
(
&
arr
)[
N
])
const
{
// We omit the \0
return
N
-
1
;
}
...
...
@@ -112,7 +112,7 @@ struct Size<char[N]> {
#define DEFINE_INTEGRAL_SIZE(Int) \
template<> \
struct Size<Int> { \
size_t operator()(Int val) { \
size_t operator()(Int val)
const
{ \
return digitsCount(val); \
} \
}
...
...
@@ -128,14 +128,14 @@ DEFINE_INTEGRAL_SIZE(int64_t);
template
<
>
struct
Size
<
bool
>
{
constexpr
size_t
operator
()(
bool
)
{
constexpr
size_t
operator
()(
bool
)
const
{
return
1
;
}
};
template
<
>
struct
Size
<
char
>
{
constexpr
size_t
operator
()(
char
)
{
constexpr
size_t
operator
()(
char
)
const
{
return
1
;
}
};
...
...
src/optional.h
View file @
71a467ce
...
...
@@ -14,11 +14,14 @@
#include <tuple>
#include <functional>
template
<
typename
T
>
class
Optional
;
namespace
types
{
template
<
typename
T
>
class
Some
{
public:
template
<
typename
U
>
friend
class
Optional
;
template
<
typename
U
>
friend
class
::
Optional
;
Some
(
const
T
&
val
)
:
val_
(
val
)
{
}
Some
(
T
&&
val
)
:
val_
(
std
::
move
(
val
))
{
}
...
...
@@ -155,6 +158,8 @@ public:
}
none_flag
=
NoneMarker
;
}
return
*
this
;
}
...
...
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