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
Hide 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
)
cmake_minimum_required
(
VERSION 2.8.7
)
project
(
restgear
)
project
(
restgear
)
include
(
CheckCXXCompilerFlag
)
if
(
CMAKE_COMPILER_IS_GNUCXX
)
CHECK_CXX_COMPILER_FLAG
(
"-std=c++11"
COMPILER_SUPPORTS_CXX11
)
add_definitions
(
-std=c++0x
)
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
()
endif
()
add_subdirectory
(
src
)
add_subdirectory
(
src
)
...
...
src/async.h
View file @
71a467ce
...
@@ -437,6 +437,7 @@ namespace Async {
...
@@ -437,6 +437,7 @@ namespace Async {
class
Resolver
{
class
Resolver
{
public:
public:
Resolver
(
const
std
::
shared_ptr
<
Private
::
Core
>
&
core
)
Resolver
(
const
std
::
shared_ptr
<
Private
::
Core
>
&
core
)
:
core_
(
core
)
:
core_
(
core
)
{
}
{
}
...
@@ -484,11 +485,11 @@ namespace Async {
...
@@ -484,11 +485,11 @@ namespace Async {
class
Rejection
{
class
Rejection
{
public:
public:
Rejection
(
const
std
::
shared_ptr
<
Private
::
Core
>&
core
)
Rejection
(
const
std
::
shared_ptr
<
Private
::
Core
>&
core
)
:
core_
(
core
)
:
core_
(
core
)
{
}
{
}
template
<
typename
Exc
>
template
<
typename
Exc
>
bool
operator
()(
Exc
exc
)
const
{
bool
operator
()(
Exc
exc
)
const
{
if
(
core_
->
state
!=
State
::
Pending
)
if
(
core_
->
state
!=
State
::
Pending
)
...
@@ -508,8 +509,8 @@ namespace Async {
...
@@ -508,8 +509,8 @@ namespace Async {
};
};
static
constexpr
Private
::
IgnoreException
IgnoreException
;
static
constexpr
Private
::
IgnoreException
IgnoreException
{}
;
static
constexpr
Private
::
NoExcept
NoExcept
;
static
constexpr
Private
::
NoExcept
NoExcept
{}
;
template
<
typename
T
>
template
<
typename
T
>
class
Promise
:
public
PromiseBase
class
Promise
:
public
PromiseBase
...
@@ -812,34 +813,37 @@ namespace Async {
...
@@ -812,34 +813,37 @@ namespace Async {
typename
Results
=
std
::
vector
<
ValueType
>
typename
Results
=
std
::
vector
<
ValueType
>
>
>
Promise
<
Results
>
whenAll
(
Iterator
first
,
Iterator
last
)
{
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
)
:
total
(
total
)
,
resolved
(
0
)
,
rejected
(
false
)
,
resolve
(
std
::
move
(
resolver
))
,
reject
(
std
::
move
(
rejection
))
{
results
.
resize
(
total
);
}
const
size_t
total
;
struct
Data
{
std
::
atomic
<
size_t
>
resolved
;
public:
std
::
atomic
<
bool
>
rejected
;
Data
(
size_t
total
,
Resolver
resolver
,
Rejection
rejection
)
:
total
(
total
)
,
resolved
(
0
)
,
rejected
(
false
)
,
resolve
(
resolver
)
,
reject
(
rejection
)
{
results
.
resize
(
total
);
}
Results
results
;
const
size_t
total
;
std
::
atomic
<
size_t
>
resolved
;
std
::
atomic
<
bool
>
rejected
;
Resolver
resolve
;
Resolver
resolve
;
Rejection
reject
;
Rejection
reject
;
};
Results
results
;
};
return
Promise
<
Results
>
([
=
](
Resolver
&
resolve
,
Rejection
&
rejection
)
{
auto
data
=
std
::
make_shared
<
Data
>
(
auto
data
=
std
::
make_shared
<
Data
>
(
st
d
::
distance
(
first
,
last
),
st
atic_cast
<
size_t
>
(
std
::
distance
(
first
,
last
)
),
resolve
,
std
::
move
(
resolve
)
,
rejection
std
::
move
(
rejection
)
);
);
size_t
index
=
0
;
size_t
index
=
0
;
...
...
src/http.h
View file @
71a467ce
...
@@ -33,6 +33,8 @@ template< class CharT, class Traits>
...
@@ -33,6 +33,8 @@ template< class CharT, class Traits>
std
::
basic_ostream
<
CharT
,
Traits
>&
crlf
(
std
::
basic_ostream
<
CharT
,
Traits
>&
os
)
{
std
::
basic_ostream
<
CharT
,
Traits
>&
crlf
(
std
::
basic_ostream
<
CharT
,
Traits
>&
os
)
{
static
constexpr
char
CRLF
[]
=
{
0xD
,
0xA
};
static
constexpr
char
CRLF
[]
=
{
0xD
,
0xA
};
os
.
write
(
CRLF
,
2
);
os
.
write
(
CRLF
,
2
);
return
os
;
}
}
// 4. HTTP Message
// 4. HTTP Message
...
...
src/http_defs.cc
View file @
71a467ce
...
@@ -25,6 +25,7 @@ namespace {
...
@@ -25,6 +25,7 @@ namespace {
bool
parseAscTimeDate
(
std
::
tm
&
tm
,
const
char
*
str
,
size_t
len
)
{
bool
parseAscTimeDate
(
std
::
tm
&
tm
,
const
char
*
str
,
size_t
len
)
{
char
*
p
=
strptime
(
str
,
"%a %b %d %H:%M:%S %Y"
,
&
tm
);
char
*
p
=
strptime
(
str
,
"%a %b %d %H:%M:%S %Y"
,
&
tm
);
return
p
!=
NULL
;
}
}
}
// anonymous namespace
}
// anonymous namespace
...
@@ -139,6 +140,7 @@ std::ostream& operator<<(std::ostream& os, Method method) {
...
@@ -139,6 +140,7 @@ std::ostream& operator<<(std::ostream& os, Method method) {
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Code
code
)
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Code
code
)
{
os
<<
codeString
(
code
);
os
<<
codeString
(
code
);
return
os
;
}
}
HttpError
::
HttpError
(
Code
code
,
std
::
string
reason
)
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) {
...
@@ -171,7 +171,7 @@ CacheControl::parseRaw(const char* str, size_t len) {
}
}
int
c
;
int
c
;
while
((
c
=
cursor
.
current
())
!=
StreamCursor
::
Eof
&&
c
==
','
||
c
==
' '
)
while
((
c
=
cursor
.
current
())
!=
StreamCursor
::
Eof
&&
(
c
==
','
||
c
==
' '
)
)
cursor
.
advance
(
1
);
cursor
.
advance
(
1
);
}
}
...
@@ -209,6 +209,8 @@ CacheControl::write(std::ostream& os) const {
...
@@ -209,6 +209,8 @@ CacheControl::write(std::ostream& os) const {
return
"min-fresh"
;
return
"min-fresh"
;
case
CacheDirective
:
:
SMaxAge
:
case
CacheDirective
:
:
SMaxAge
:
return
"s-maxage"
;
return
"s-maxage"
;
case
CacheDirective
:
:
Ext
:
return
""
;
}
}
};
};
...
@@ -219,8 +221,9 @@ CacheControl::write(std::ostream& os) const {
...
@@ -219,8 +221,9 @@ CacheControl::write(std::ostream& os) const {
case
CacheDirective
:
:
MinFresh
:
case
CacheDirective
:
:
MinFresh
:
case
CacheDirective
:
:
SMaxAge
:
case
CacheDirective
:
:
SMaxAge
:
return
true
;
return
true
;
default:
return
false
;
}
}
return
false
;
};
};
for
(
std
::
vector
<
CacheDirective
>::
size_type
i
=
0
;
i
<
directives_
.
size
();
++
i
)
{
for
(
std
::
vector
<
CacheDirective
>::
size_type
i
=
0
;
i
<
directives_
.
size
();
++
i
)
{
...
@@ -312,7 +315,10 @@ Host::parse(const std::string& data) {
...
@@ -312,7 +315,10 @@ Host::parse(const std::string& data) {
void
void
Host
::
write
(
std
::
ostream
&
os
)
const
{
Host
::
write
(
std
::
ostream
&
os
)
const
{
os
<<
host_
;
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_
;
os
<<
":"
<<
port_
;
}
}
}
}
...
...
src/http_header.h
View file @
71a467ce
...
@@ -308,8 +308,6 @@ public:
...
@@ -308,8 +308,6 @@ public:
NAME
(
"Host"
);
NAME
(
"Host"
);
Host
()
Host
()
:
host_
()
,
port_
(
-
1
)
{
}
{
}
explicit
Host
(
const
std
::
string
&
host
,
Net
::
Port
port
=
80
)
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) {
...
@@ -81,6 +81,7 @@ Collection::add(const std::shared_ptr<Header>& header) {
Collection
&
Collection
&
Collection
::
addRaw
(
const
Raw
&
raw
)
{
Collection
::
addRaw
(
const
Raw
&
raw
)
{
rawHeaders
.
insert
(
std
::
make_pair
(
raw
.
name
(),
raw
));
rawHeaders
.
insert
(
std
::
make_pair
(
raw
.
name
(),
raw
));
return
*
this
;
}
}
std
::
shared_ptr
<
const
Header
>
std
::
shared_ptr
<
const
Header
>
...
...
src/mime.cc
View file @
71a467ce
...
@@ -228,6 +228,8 @@ MediaType::toString() const {
...
@@ -228,6 +228,8 @@ MediaType::toString() const {
return str;
return str;
MIME_TYPES
MIME_TYPES
#undef TYPE
#undef TYPE
default:
return
""
;
}
}
};
};
...
@@ -238,6 +240,8 @@ MediaType::toString() const {
...
@@ -238,6 +240,8 @@ MediaType::toString() const {
return str;
return str;
MIME_SUBTYPES
MIME_SUBTYPES
#undef TYPE
#undef TYPE
default:
return
""
;
}
}
};
};
...
@@ -248,6 +252,8 @@ MediaType::toString() const {
...
@@ -248,6 +252,8 @@ MediaType::toString() const {
return "+" str;
return "+" str;
MIME_SUFFIXES
MIME_SUFFIXES
#undef SUFFIX
#undef SUFFIX
default:
return
""
;
}
}
};
};
...
...
src/net.h
View file @
71a467ce
...
@@ -96,14 +96,14 @@ digitsCount(T val) {
...
@@ -96,14 +96,14 @@ digitsCount(T val) {
template
<
>
template
<
>
struct
Size
<
const
char
*>
{
struct
Size
<
const
char
*>
{
size_t
operator
()(
const
char
*
s
)
{
size_t
operator
()(
const
char
*
s
)
const
{
return
std
::
strlen
(
s
);
return
std
::
strlen
(
s
);
}
}
};
};
template
<
size_t
N
>
template
<
size_t
N
>
struct
Size
<
char
[
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
// We omit the \0
return
N
-
1
;
return
N
-
1
;
}
}
...
@@ -112,7 +112,7 @@ struct Size<char[N]> {
...
@@ -112,7 +112,7 @@ struct Size<char[N]> {
#define DEFINE_INTEGRAL_SIZE(Int) \
#define DEFINE_INTEGRAL_SIZE(Int) \
template<> \
template<> \
struct Size<Int> { \
struct Size<Int> { \
size_t operator()(Int val) { \
size_t operator()(Int val)
const
{ \
return digitsCount(val); \
return digitsCount(val); \
} \
} \
}
}
...
@@ -128,14 +128,14 @@ DEFINE_INTEGRAL_SIZE(int64_t);
...
@@ -128,14 +128,14 @@ DEFINE_INTEGRAL_SIZE(int64_t);
template
<
>
template
<
>
struct
Size
<
bool
>
{
struct
Size
<
bool
>
{
constexpr
size_t
operator
()(
bool
)
{
constexpr
size_t
operator
()(
bool
)
const
{
return
1
;
return
1
;
}
}
};
};
template
<
>
template
<
>
struct
Size
<
char
>
{
struct
Size
<
char
>
{
constexpr
size_t
operator
()(
char
)
{
constexpr
size_t
operator
()(
char
)
const
{
return
1
;
return
1
;
}
}
};
};
...
...
src/optional.h
View file @
71a467ce
...
@@ -14,11 +14,14 @@
...
@@ -14,11 +14,14 @@
#include <tuple>
#include <tuple>
#include <functional>
#include <functional>
template
<
typename
T
>
class
Optional
;
namespace
types
{
namespace
types
{
template
<
typename
T
>
template
<
typename
T
>
class
Some
{
class
Some
{
public:
public:
template
<
typename
U
>
friend
class
Optional
;
template
<
typename
U
>
friend
class
::
Optional
;
Some
(
const
T
&
val
)
:
val_
(
val
)
{
}
Some
(
const
T
&
val
)
:
val_
(
val
)
{
}
Some
(
T
&&
val
)
:
val_
(
std
::
move
(
val
))
{
}
Some
(
T
&&
val
)
:
val_
(
std
::
move
(
val
))
{
}
...
@@ -155,6 +158,8 @@ public:
...
@@ -155,6 +158,8 @@ public:
}
}
none_flag
=
NoneMarker
;
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