2021-10-05 13:54:41 +02:00
|
|
|
#ifndef STRINGS_h
|
|
|
|
#define STRINGS_h
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
2022-03-06 17:48:04 +01:00
|
|
|
#define ESPMAC (Sprintf("%06" PRIx64, ESP.getEfuseMac() >> 24))
|
|
|
|
#define Sprintf(f, ...) ({ char* s; asprintf(&s, f, __VA_ARGS__); String r = s; free(s); r; })
|
|
|
|
#define Stdprintf(f, ...) ({ char* s; asprintf(&s, f, __VA_ARGS__); std::string r = s; free(s); r; })
|
|
|
|
#define SMacf(f) ( \
|
|
|
|
{ \
|
|
|
|
auto nativeAddress = (f).getNative(); \
|
|
|
|
Sprintf("%02x%02x%02x%02x%02x%02x", nativeAddress[5], nativeAddress[4], nativeAddress[3], nativeAddress[2], nativeAddress[1], nativeAddress[0]); \
|
|
|
|
})
|
|
|
|
|
|
|
|
std::string slugify(const std::string& text);
|
|
|
|
String slugify(const String& text);
|
|
|
|
std::string kebabify(const std::string& text);
|
|
|
|
String kebabify(const String& text);
|
2022-03-14 02:54:50 +01:00
|
|
|
std::string hexStr(const uint8_t *data, int len);
|
2021-10-05 13:54:41 +02:00
|
|
|
std::string hexStr(const char *data, int len);
|
2022-03-06 17:48:04 +01:00
|
|
|
std::string hexStr(const std::string& s);
|
2022-03-14 02:54:50 +01:00
|
|
|
std::string hexStrRev(const uint8_t *data, int len);
|
|
|
|
std::string hexStrRev(const char *data, int len);
|
|
|
|
std::string hexStrRev(const std::string &s);
|
|
|
|
bool prefixExists(const String& prefixes, const String& s);
|
2021-10-05 13:54:41 +02:00
|
|
|
#endif
|