1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 16:25:50 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
J. Nick Koston
66e471cf2a [mdns] Modernize to C++17 nested namespace syntax 2025-11-18 14:33:07 -06:00
8 changed files with 20 additions and 31 deletions

View File

@@ -84,7 +84,9 @@ class APIFrameHelper {
public:
APIFrameHelper() = default;
explicit APIFrameHelper(std::unique_ptr<socket::Socket> socket, const ClientInfo *client_info)
: socket_(std::move(socket)), client_info_(client_info) {}
: socket_owned_(std::move(socket)), client_info_(client_info) {
socket_ = socket_owned_.get();
}
virtual ~APIFrameHelper() = default;
virtual APIError init() = 0;
virtual APIError loop();
@@ -147,8 +149,9 @@ class APIFrameHelper {
APIError write_raw_(const struct iovec *iov, int iovcnt, socket::Socket *socket, std::vector<uint8_t> &tx_buf,
const std::string &info, StateEnum &state, StateEnum failed_state);
// Socket ownership (4 bytes on 32-bit, 8 bytes on 64-bit)
std::unique_ptr<socket::Socket> socket_;
// Pointers first (4 bytes each)
socket::Socket *socket_{nullptr};
std::unique_ptr<socket::Socket> socket_owned_;
// Common state enum for all frame helpers
// Note: Not all states are used by all implementations

View File

@@ -21,8 +21,7 @@
#include "esphome/components/dashboard_import/dashboard_import.h"
#endif
namespace esphome {
namespace mdns {
namespace esphome::mdns {
static const char *const TAG = "mdns";
@@ -189,6 +188,5 @@ void MDNSComponent::dump_config() {
#endif
}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif

View File

@@ -6,8 +6,7 @@
#include "esphome/core/component.h"
#include "esphome/core/helpers.h"
namespace esphome {
namespace mdns {
namespace esphome::mdns {
// Helper struct that identifies strings that may be stored in flash storage (similar to LogString)
struct MDNSString;
@@ -79,6 +78,5 @@ class MDNSComponent : public Component {
void compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUNT> &services);
};
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif

View File

@@ -7,8 +7,7 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome {
namespace mdns {
namespace esphome::mdns {
static const char *const TAG = "mdns";
@@ -56,7 +55,6 @@ void MDNSComponent::on_shutdown() {
delay(40); // Allow the mdns packets announcing service removal to be sent
}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif // USE_ESP32

View File

@@ -9,8 +9,7 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome {
namespace mdns {
namespace esphome::mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -52,7 +51,6 @@ void MDNSComponent::on_shutdown() {
delay(10);
}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif

View File

@@ -6,8 +6,7 @@
#include "esphome/core/log.h"
#include "mdns_component.h"
namespace esphome {
namespace mdns {
namespace esphome::mdns {
void MDNSComponent::setup() {
// Host platform doesn't have actual mDNS implementation
@@ -15,7 +14,6 @@ void MDNSComponent::setup() {
void MDNSComponent::on_shutdown() {}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif

View File

@@ -9,8 +9,7 @@
#include <mDNS.h>
namespace esphome {
namespace mdns {
namespace esphome::mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -46,7 +45,6 @@ void MDNSComponent::setup() {
void MDNSComponent::on_shutdown() {}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif

View File

@@ -9,8 +9,7 @@
#include <ESP8266mDNS.h>
namespace esphome {
namespace mdns {
namespace esphome::mdns {
void MDNSComponent::setup() {
#ifdef USE_MDNS_STORE_SERVICES
@@ -51,7 +50,6 @@ void MDNSComponent::on_shutdown() {
delay(40);
}
} // namespace mdns
} // namespace esphome
} // namespace esphome::mdns
#endif