spdlog-fmt.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <spdlog/fmt/fmt.h>
4 
6 
7 #if FMT_VERSION >= 100000
8 #include <spdlog/fmt/ostr.h>
9 
12 #endif
13 
14 namespace dai {
15 namespace utility {
16 static constexpr char path_convert_err[] = "<Unicode path not convertible>";
17 }
18 } // namespace dai
19 
20 template <>
21 struct fmt::formatter<dai::Path> : formatter<std::string> {
22  // https://fmt.dev/latest/api.html#formatting-user-defined-types
23  // https://fmt.dev/latest/syntax.html#format-specification-mini-language
24  template <typename FormatContext>
25  auto format(const dai::Path& p, FormatContext& ctx) {
26  std::string output;
27  try {
28  output = p.string();
29  } catch(const std::exception&) {
31  }
32  return formatter<std::string>::format(output, ctx);
33  }
34 };
35 
36 #if FMT_VERSION >= 100000
37 template <>
38 struct fmt::formatter<dai::CameraBoardSocket> : ostream_formatter {};
39 
40 template <>
41 struct fmt::formatter<dai::DatatypeEnum> : fmt::formatter<std::string> {
42  auto format(dai::DatatypeEnum my, format_context& ctx) const -> decltype(ctx.out()) {
43  return fmt::format_to(ctx.out(), "{}", static_cast<int32_t>(my));
44  }
45 };
46 #endif
dai::DatatypeEnum
DatatypeEnum
Definition: DatatypeEnum.hpp:7
dai::CameraBoardSocket
CameraBoardSocket
Definition: shared/depthai-shared/include/depthai-shared/common/CameraBoardSocket.hpp:9
dai::utility::path_convert_err
static constexpr char path_convert_err[]
Definition: spdlog-fmt.hpp:16
dai::Path::string
std::string string() const
Get path in native-encoding string; no conversion.
Definition: Path.hpp:145
DatatypeEnum.hpp
Path.hpp
fmt::formatter< dai::Path >::format
auto format(const dai::Path &p, FormatContext &ctx)
Definition: spdlog-fmt.hpp:25
CameraBoardSocket.hpp
dai::Path
Represents paths on a filesystem; accepts utf-8, Windows utf-16 wchar_t, or std::filesystem::path.
Definition: Path.hpp:27
dai
Definition: CameraExposureOffset.hpp:6


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19