Skip to content

Commit 2e51afe

Browse files
committed
Avoid #includes with a surrounding namespace
This is a followup of the discussion in esp8266#6946 (comment) to untangle the namespace/double inclusions in this library.
1 parent ca149a2 commit 2e51afe

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static const char qop_auth_quoted[] PROGMEM = "qop=\"auth\"";
3434
static const char WWW_Authenticate[] PROGMEM = "WWW-Authenticate";
3535
static const char Content_Length[] PROGMEM = "Content-Length";
3636

37+
namespace esp8266webserver {
38+
3739
template <typename ServerType>
3840
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
3941
: _server(addr, port)
@@ -864,3 +866,5 @@ String ESP8266WebServerTemplate<ServerType>::responseCodeToString(const int code
864866
}
865867
return String(r);
866868
}
869+
870+
} // namespace

libraries/ESP8266WebServer/src/ESP8266WebServer.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ namespace esp8266webserver {
8282
template<typename ServerType>
8383
class ESP8266WebServerTemplate;
8484

85+
}
86+
8587
#include "detail/RequestHandler.h"
8688

89+
namespace esp8266webserver {
90+
8791
template<typename ServerType>
8892
class ESP8266WebServerTemplate
8993
{
@@ -296,13 +300,11 @@ class ESP8266WebServerTemplate
296300
HookFunction _hook;
297301
};
298302

303+
} // namespace
299304

300305
#include "ESP8266WebServer-impl.h"
301306
#include "Parsing-impl.h"
302307

303-
};
304-
305-
306308
using ESP8266WebServer = esp8266webserver::ESP8266WebServerTemplate<WiFiServer>;
307309
using RequestHandler = esp8266webserver::RequestHandler<WiFiServer>;
308310

libraries/ESP8266WebServer/src/Parsing-impl.h

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
static const char Content_Type[] PROGMEM = "Content-Type";
3333
static const char filename[] PROGMEM = "filename";
3434

35+
namespace esp8266webserver {
36+
3537
template <typename ServerType>
3638
static bool readBytesWithTimeout(typename ServerType::ClientType& client, size_t maxLength, String& data, int timeout_ms)
3739
{
@@ -578,3 +580,5 @@ bool ESP8266WebServerTemplate<ServerType>::_parseFormUploadAborted(){
578580
_currentHandler->upload(*this, _currentUri, *_currentUpload);
579581
return false;
580582
}
583+
584+
} // namespace

libraries/ESP8266WebServer/src/detail/RequestHandler.h

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <vector>
66
#include <assert.h>
77

8+
namespace esp8266webserver {
9+
810
template<typename ServerType>
911
class RequestHandler {
1012
using WebServerType = ESP8266WebServerTemplate<ServerType>;
@@ -31,4 +33,6 @@ class RequestHandler {
3133
}
3234
};
3335

36+
} // namespace
37+
3438
#endif //REQUESTHANDLER_H

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "WString.h"
88
#include "Uri.h"
99

10-
using namespace mime;
10+
namespace esp8266webserver {
1111

1212
template<typename ServerType>
1313
class FunctionRequestHandler : public RequestHandler<ServerType> {
@@ -126,6 +126,7 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
126126

127127
String contentType = mime::getContentType(path);
128128

129+
using namespace mime;
129130
// look for gz file, only if the original specified path is not a gz. So part only works to send gzip via content encoding when a non compressed is asked for
130131
// if you point the the path to gzip you will serve the gzip as content type "application/x-gzip", not text or javascript etc...
131132
if (!path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !_fs.exists(path)) {
@@ -164,5 +165,6 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
164165
size_t _baseUriLength;
165166
};
166167

168+
} // namespace
167169

168170
#endif //REQUESTHANDLERSIMPL_H

0 commit comments

Comments
 (0)