Sync from fork #2
@@ -23,18 +23,12 @@ set(sources
|
|||||||
src/strutils.cpp
|
src/strutils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(dependencies
|
|
||||||
fmt
|
|
||||||
)
|
|
||||||
|
|
||||||
idf_component_register(
|
idf_component_register(
|
||||||
INCLUDE_DIRS
|
INCLUDE_DIRS
|
||||||
src
|
src
|
||||||
SRCS
|
SRCS
|
||||||
${headers}
|
${headers}
|
||||||
${sources}
|
${sources}
|
||||||
REQUIRES
|
|
||||||
${dependencies}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(${COMPONENT_TARGET}
|
target_compile_options(${COMPONENT_TARGET}
|
||||||
|
@@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
// system includes
|
// system includes
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <format>
|
||||||
// 3rdparty lib includes
|
|
||||||
#include <fmt/core.h>
|
|
||||||
|
|
||||||
namespace cpputils {
|
namespace cpputils {
|
||||||
std::string toString(ColorHelper color)
|
std::string toString(ColorHelper color)
|
||||||
{
|
{
|
||||||
return fmt::format("#{:02X}{:02X}{:02X}", color.r, color.g, color.b);
|
return std::format("#{:02X}{:02X}{:02X}", color.r, color.g, color.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::expected<ColorHelper, std::string> parseColor(std::string_view str)
|
std::expected<ColorHelper, std::string> parseColor(std::string_view str)
|
||||||
@@ -28,7 +26,7 @@ std::expected<ColorHelper, std::string> parseColor(std::string_view str)
|
|||||||
return helper;
|
return helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::unexpected(fmt::format("invalid color {}", str));
|
return std::unexpected(std::format("invalid color {}", str));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cpputils
|
} // namespace cpputils
|
||||||
|
@@ -3,9 +3,7 @@
|
|||||||
// system includes
|
// system includes
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <expected>
|
#include <expected>
|
||||||
|
#include <format>
|
||||||
// 3rdparty lib includes
|
|
||||||
#include <fmt/core.h>
|
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "cppmacros.h"
|
#include "cppmacros.h"
|
||||||
@@ -38,14 +36,14 @@ struct parseEnum;
|
|||||||
using TheEnum = Name; \
|
using TheEnum = Name; \
|
||||||
Values(DECLARE_TYPESAFE_ENUM_HELPER2) \
|
Values(DECLARE_TYPESAFE_ENUM_HELPER2) \
|
||||||
} \
|
} \
|
||||||
return fmt::format("Unknown " #Name "({})", int(value)); \
|
return std::format("Unknown " #Name "({})", int(value)); \
|
||||||
} \
|
} \
|
||||||
inline std::expected<Name, std::string> parse##Name(std::string_view str) \
|
inline std::expected<Name, std::string> parse##Name(std::string_view str) \
|
||||||
{ \
|
{ \
|
||||||
using TheEnum = Name; \
|
using TheEnum = Name; \
|
||||||
if (false) {} \
|
if (false) {} \
|
||||||
Values(DECLARE_TYPESAFE_ENUM_HELPER3) \
|
Values(DECLARE_TYPESAFE_ENUM_HELPER3) \
|
||||||
return std::unexpected(fmt::format("invalid " #Name " ({})", str)); \
|
return std::unexpected(std::format("invalid " #Name " ({})", str)); \
|
||||||
} \
|
} \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
void iterate##Name(T &&cb) \
|
void iterate##Name(T &&cb) \
|
||||||
|
@@ -3,12 +3,10 @@
|
|||||||
// system includes
|
// system includes
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <expected>
|
||||||
|
#include <format>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <expected>
|
|
||||||
|
|
||||||
// 3rdparty lib includes
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
namespace cpputils {
|
namespace cpputils {
|
||||||
template<typename T> std::expected<T, std::string> fromString(std::string_view str) = delete;
|
template<typename T> std::expected<T, std::string> fromString(std::string_view str) = delete;
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
// system includes
|
// system includes
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <format>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
|
||||||
#include <fmt/core.h>
|
|
||||||
|
|
||||||
namespace cpputils {
|
namespace cpputils {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -56,7 +55,7 @@ std::expected<std::basic_string<unsigned char>, std::string> fromHexString(std::
|
|||||||
case 'A'...'F': nibbles.nibble0 = c - 'A' + 10; break;
|
case 'A'...'F': nibbles.nibble0 = c - 'A' + 10; break;
|
||||||
case 'a'...'f': nibbles.nibble0 = c - 'a' + 10; break;
|
case 'a'...'f': nibbles.nibble0 = c - 'a' + 10; break;
|
||||||
default:
|
default:
|
||||||
return std::unexpected(fmt::format("invalid character {} at pos {}", c, std::distance(std::begin(hex), iter)));
|
return std::unexpected(std::format("invalid character {} at pos {}", c, std::distance(std::begin(hex), iter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
iter++;
|
iter++;
|
||||||
@@ -67,7 +66,7 @@ std::expected<std::basic_string<unsigned char>, std::string> fromHexString(std::
|
|||||||
case 'A'...'F': nibbles.nibble1 = c - 'A' + 10; break;
|
case 'A'...'F': nibbles.nibble1 = c - 'A' + 10; break;
|
||||||
case 'a'...'f': nibbles.nibble1 = c - 'a' + 10; break;
|
case 'a'...'f': nibbles.nibble1 = c - 'a' + 10; break;
|
||||||
default:
|
default:
|
||||||
return std::unexpected(fmt::format("invalid character {} at pos {}", c, std::distance(std::begin(hex), iter)));
|
return std::unexpected(std::format("invalid character {} at pos {}", c, std::distance(std::begin(hex), iter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
iter++;
|
iter++;
|
||||||
|
Reference in New Issue
Block a user