From 8af9f032ccf95d3fd657b7d5dc69df431ab03e2e Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 3 Oct 2021 18:38:40 +0200 Subject: [PATCH] Fixed namespace issues --- src/configmanager_priv.h | 4 +++- src/configutils_espchrono.h | 4 ++-- src/configutils_espcpputils.h | 4 ---- src/configutils_priv_enum.h | 4 +++- src/configutils_sntp.h | 4 ---- src/configwrapper_base.cpp | 4 ---- src/configwrapper_cpputils.cpp | 5 +---- src/configwrapper_espchrono.cpp | 10 ---------- src/configwrapper_espcpputils.cpp | 5 +---- src/configwrapper_espwifistack.cpp | 5 +---- src/configwrapper_optional.cpp | 4 ---- src/configwrapper_priv.h | 4 +++- src/configwrapper_sntp.cpp | 2 -- 13 files changed, 14 insertions(+), 45 deletions(-) diff --git a/src/configmanager_priv.h b/src/configmanager_priv.h index b279fd0..b49eba6 100644 --- a/src/configmanager_priv.h +++ b/src/configmanager_priv.h @@ -13,10 +13,12 @@ #include "espchrono.h" #define INSTANTIATE_CONFIGMANAGER_TEMPLATES(Type) \ + namespace espconfig { \ template esp_err_t ConfigManager::init(); \ /* template bool ConfigManager::erase(); */ \ template ConfigStatusReturnType ConfigManager::reset(); \ - template ConfigWrapperInterface *ConfigManager::findConfigByKey(std::string_view key); + template ConfigWrapperInterface *ConfigManager::findConfigByKey(std::string_view key); \ + } // namespace espconfig namespace espconfig { namespace { diff --git a/src/configutils_espchrono.h b/src/configutils_espchrono.h index 68d994d..2926ff8 100644 --- a/src/configutils_espchrono.h +++ b/src/configutils_espchrono.h @@ -4,10 +4,10 @@ #include "configutils_priv_enum.h" #include "espchrono.h" -namespace espconfig { - IMPLEMENT_NVS_GET_SET_ENUM(espchrono::DayLightSavingMode) +namespace espconfig { + #define IMPLEMENT_NVS_GET_SET_CHRONO(Name) \ inline esp_err_t nvs_get(nvs_handle handle, const char* key, Name* out_value) \ { \ diff --git a/src/configutils_espcpputils.h b/src/configutils_espcpputils.h index f093fdc..ec9207a 100644 --- a/src/configutils_espcpputils.h +++ b/src/configutils_espcpputils.h @@ -4,8 +4,4 @@ #include "configutils_priv_enum.h" #include "taskutils.h" -namespace espconfig { - IMPLEMENT_NVS_GET_SET_ENUM(espcpputils::CoreAffinity) - -} // namespace espconfig diff --git a/src/configutils_priv_enum.h b/src/configutils_priv_enum.h index 9f35c34..55c8e98 100644 --- a/src/configutils_priv_enum.h +++ b/src/configutils_priv_enum.h @@ -10,6 +10,7 @@ #include "configutils_base.h" #define IMPLEMENT_NVS_GET_SET_ENUM(Name) \ + namespace espconfig { \ inline esp_err_t nvs_get(nvs_handle handle, const char* key, Name* out_value) \ { \ std::underlying_type_t temp; \ @@ -22,4 +23,5 @@ inline esp_err_t nvs_set(nvs_handle handle, const char* key, Name value) \ { \ return nvs_set(handle, key, std::underlying_type_t(value)); \ - } + } \ + } // namespace espconfig diff --git a/src/configutils_sntp.h b/src/configutils_sntp.h index dbbce72..a0e73d4 100644 --- a/src/configutils_sntp.h +++ b/src/configutils_sntp.h @@ -6,8 +6,4 @@ // local includes #include "configutils_priv_enum.h" -namespace espconfig { - IMPLEMENT_NVS_GET_SET_ENUM(sntp_sync_mode_t) - -} // namespace espconfig diff --git a/src/configwrapper_base.cpp b/src/configwrapper_base.cpp index bb59175..0e2e619 100644 --- a/src/configwrapper_base.cpp +++ b/src/configwrapper_base.cpp @@ -3,8 +3,6 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::cpputils::toString; #include "configwrapper_priv.h" -namespace espconfig { - INSTANTIATE_CONFIGWRAPPER_TEMPLATES(bool) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(uint8_t) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(int8_t) @@ -17,5 +15,3 @@ INSTANTIATE_CONFIGWRAPPER_TEMPLATES(int64_t) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(float) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(double) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::string) - -} // namespace espconfig diff --git a/src/configwrapper_cpputils.cpp b/src/configwrapper_cpputils.cpp index 35eaf24..bccd247 100644 --- a/src/configwrapper_cpputils.cpp +++ b/src/configwrapper_cpputils.cpp @@ -2,7 +2,4 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::cpputils::toString; #include "configwrapper_priv.h" -namespace espconfig { -using ColorHelper = cpputils::ColorHelper; -INSTANTIATE_CONFIGWRAPPER_TEMPLATES(ColorHelper) -} // namespace espconfig +INSTANTIATE_CONFIGWRAPPER_TEMPLATES(cpputils::ColorHelper) diff --git a/src/configwrapper_espchrono.cpp b/src/configwrapper_espchrono.cpp index 027222f..c1e1f85 100644 --- a/src/configwrapper_espchrono.cpp +++ b/src/configwrapper_espchrono.cpp @@ -2,18 +2,8 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::espchrono::toString; #include "configwrapper_priv.h" -namespace espconfig { - -using DayLightSavingMode = espchrono::DayLightSavingMode; -using milliseconds32 = espchrono::milliseconds32; -using seconds32 = espchrono::seconds32; -using minutes32 = espchrono::minutes32; -using hours32 = espchrono::hours32; - INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espchrono::DayLightSavingMode) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espchrono::milliseconds32) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espchrono::seconds32) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espchrono::minutes32) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espchrono::hours32) - -} // namespace espconfig diff --git a/src/configwrapper_espcpputils.cpp b/src/configwrapper_espcpputils.cpp index 890c8d9..d4b1249 100644 --- a/src/configwrapper_espcpputils.cpp +++ b/src/configwrapper_espcpputils.cpp @@ -2,7 +2,4 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::espcpputils::toString; #include "configwrapper_priv.h" -namespace espconfig { -using CoreAffinity = espcpputils::CoreAffinity; -INSTANTIATE_CONFIGWRAPPER_TEMPLATES(CoreAffinity) -} // namespace espconfig +INSTANTIATE_CONFIGWRAPPER_TEMPLATES(espcpputils::CoreAffinity) diff --git a/src/configwrapper_espwifistack.cpp b/src/configwrapper_espwifistack.cpp index 25e2e23..58024b1 100644 --- a/src/configwrapper_espwifistack.cpp +++ b/src/configwrapper_espwifistack.cpp @@ -2,7 +2,4 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::wifi_stack::toString; #include "configwrapper_priv.h" -namespace espconfig { -using ip_address_t = wifi_stack::ip_address_t; -INSTANTIATE_CONFIGWRAPPER_TEMPLATES(ip_address_t) -} // namespace espconfig +INSTANTIATE_CONFIGWRAPPER_TEMPLATES(wifi_stack::ip_address_t) diff --git a/src/configwrapper_optional.cpp b/src/configwrapper_optional.cpp index 56b5768..ffa2d02 100644 --- a/src/configwrapper_optional.cpp +++ b/src/configwrapper_optional.cpp @@ -3,8 +3,6 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::cpputils::toString; #include "configwrapper_priv.h" -namespace espconfig { - INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) @@ -15,5 +13,3 @@ INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(std::optional) - -} // namespace espconfig diff --git a/src/configwrapper_priv.h b/src/configwrapper_priv.h index 253b411..acbdf7b 100644 --- a/src/configwrapper_priv.h +++ b/src/configwrapper_priv.h @@ -18,6 +18,7 @@ #include "cpputils.h" #define INSTANTIATE_CONFIGWRAPPER_TEMPLATES(TYPE) \ + namespace espconfig { \ template ConfigWrapper::ConfigWrapper(const TYPE &defaultValue, AllowReset allowReset, ConstraintCallback constraintCallback, const char *nvsName); \ template ConfigWrapper::ConfigWrapper(TYPE &&defaultValue, AllowReset allowReset, ConstraintCallback constraintCallback, const char *nvsName); \ template ConfigWrapper::ConfigWrapper(const ConfigWrapper &factoryConfig, ConstraintCallback constraintCallback, const char *nvsName); \ @@ -31,7 +32,8 @@ template ConfigStatusReturnType ConfigWrapper::reset(nvs_handle_t nvsHandle); \ template ConfigStatusReturnType ConfigWrapper::forceReset(nvs_handle_t nvsHandle); \ template ConfigConstraintReturnType ConfigWrapper::checkValue(value_t value) const; \ - template ConfigStatusReturnType ConfigWrapper::writeToFlash(nvs_handle_t nvsHandle, value_t value); + template ConfigStatusReturnType ConfigWrapper::writeToFlash(nvs_handle_t nvsHandle, value_t value); \ + } // namespace espconfig namespace espconfig { namespace { diff --git a/src/configwrapper_sntp.cpp b/src/configwrapper_sntp.cpp index 0baf106..9a3ce27 100644 --- a/src/configwrapper_sntp.cpp +++ b/src/configwrapper_sntp.cpp @@ -3,6 +3,4 @@ #define CONFIGWRAPPER_TOSTRING_USINGS using ::espcpputils::toString; #include "configwrapper_priv.h" -namespace espconfig { INSTANTIATE_CONFIGWRAPPER_TEMPLATES(sntp_sync_mode_t) -} // namespace espconfig