mqt-core 3.2.1__cp312-cp312-win_arm64.whl → 3.3.1__cp312-cp312-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mqt-core might be problematic. Click here for more details.
- mqt/core/__init__.py +3 -3
- mqt/core/_commands.py +2 -2
- mqt/core/_version.py +16 -3
- mqt/core/bin/mqt-core-algorithms.dll +0 -0
- mqt/core/bin/mqt-core-circuit-optimizer.dll +0 -0
- mqt/core/bin/mqt-core-dd.dll +0 -0
- mqt/core/bin/mqt-core-ds.dll +0 -0
- mqt/core/bin/mqt-core-fomac.dll +0 -0
- mqt/core/bin/mqt-core-ir.dll +0 -0
- mqt/core/bin/mqt-core-na-fomac.dll +0 -0
- mqt/core/bin/mqt-core-na.dll +0 -0
- mqt/core/bin/mqt-core-qasm.dll +0 -0
- mqt/core/bin/mqt-core-qdmi-driver.dll +0 -0
- mqt/core/bin/mqt-core-qdmi-na-device.dll +0 -0
- mqt/core/bin/mqt-core-zx.dll +0 -0
- mqt/core/dd.cp312-win_arm64.pyd +0 -0
- mqt/core/dd.pyi +5 -7
- mqt/core/fomac.cp312-win_arm64.pyd +0 -0
- mqt/core/fomac.pyi +125 -0
- mqt/core/include/mqt-core/circuit_optimizer/CircuitOptimizer.hpp +13 -0
- mqt/core/include/mqt-core/dd/CachedEdge.hpp +7 -0
- mqt/core/include/mqt-core/dd/Operations.hpp +12 -14
- mqt/core/include/mqt-core/fomac/FoMaC.hpp +568 -0
- mqt/core/include/mqt-core/ir/QuantumComputation.hpp +29 -28
- mqt/core/include/mqt-core/ir/operations/CompoundOperation.hpp +2 -0
- mqt/core/include/mqt-core/ir/operations/IfElseOperation.hpp +169 -0
- mqt/core/include/mqt-core/ir/operations/OpType.hpp +3 -0
- mqt/core/include/mqt-core/ir/operations/OpType.inc +2 -2
- mqt/core/include/mqt-core/ir/operations/Operation.hpp +3 -1
- mqt/core/include/mqt-core/ir/operations/StandardOperation.hpp +2 -0
- mqt/core/include/mqt-core/mqt_na_qdmi/device.h +602 -0
- mqt/core/include/mqt-core/mqt_na_qdmi/types.h +78 -0
- mqt/core/include/mqt-core/na/device/Device.hpp +410 -0
- mqt/core/include/mqt-core/na/device/DeviceMemberInitializers.hpp +724 -0
- mqt/core/include/mqt-core/na/device/Generator.hpp +447 -0
- mqt/core/include/mqt-core/na/fomac/Device.hpp +169 -0
- mqt/core/include/mqt-core/qdmi/Driver.hpp +431 -0
- mqt/core/include/nlohmann/adl_serializer.hpp +55 -0
- mqt/core/include/nlohmann/byte_container_with_subtype.hpp +103 -0
- mqt/core/include/nlohmann/detail/abi_macros.hpp +111 -0
- mqt/core/include/nlohmann/detail/conversions/from_json.hpp +577 -0
- mqt/core/include/nlohmann/detail/conversions/to_chars.hpp +1118 -0
- mqt/core/include/nlohmann/detail/conversions/to_json.hpp +479 -0
- mqt/core/include/nlohmann/detail/exceptions.hpp +291 -0
- mqt/core/include/nlohmann/detail/hash.hpp +129 -0
- mqt/core/include/nlohmann/detail/input/binary_reader.hpp +3068 -0
- mqt/core/include/nlohmann/detail/input/input_adapters.hpp +549 -0
- mqt/core/include/nlohmann/detail/input/json_sax.hpp +986 -0
- mqt/core/include/nlohmann/detail/input/lexer.hpp +1643 -0
- mqt/core/include/nlohmann/detail/input/parser.hpp +519 -0
- mqt/core/include/nlohmann/detail/input/position_t.hpp +37 -0
- mqt/core/include/nlohmann/detail/iterators/internal_iterator.hpp +35 -0
- mqt/core/include/nlohmann/detail/iterators/iter_impl.hpp +760 -0
- mqt/core/include/nlohmann/detail/iterators/iteration_proxy.hpp +235 -0
- mqt/core/include/nlohmann/detail/iterators/iterator_traits.hpp +61 -0
- mqt/core/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +130 -0
- mqt/core/include/nlohmann/detail/iterators/primitive_iterator.hpp +132 -0
- mqt/core/include/nlohmann/detail/json_custom_base_class.hpp +39 -0
- mqt/core/include/nlohmann/detail/json_pointer.hpp +988 -0
- mqt/core/include/nlohmann/detail/json_ref.hpp +78 -0
- mqt/core/include/nlohmann/detail/macro_scope.hpp +595 -0
- mqt/core/include/nlohmann/detail/macro_unscope.hpp +46 -0
- mqt/core/include/nlohmann/detail/meta/call_std/begin.hpp +17 -0
- mqt/core/include/nlohmann/detail/meta/call_std/end.hpp +17 -0
- mqt/core/include/nlohmann/detail/meta/cpp_future.hpp +171 -0
- mqt/core/include/nlohmann/detail/meta/detected.hpp +70 -0
- mqt/core/include/nlohmann/detail/meta/identity_tag.hpp +21 -0
- mqt/core/include/nlohmann/detail/meta/is_sax.hpp +159 -0
- mqt/core/include/nlohmann/detail/meta/std_fs.hpp +29 -0
- mqt/core/include/nlohmann/detail/meta/type_traits.hpp +795 -0
- mqt/core/include/nlohmann/detail/meta/void_t.hpp +24 -0
- mqt/core/include/nlohmann/detail/output/binary_writer.hpp +1850 -0
- mqt/core/include/nlohmann/detail/output/output_adapters.hpp +147 -0
- mqt/core/include/nlohmann/detail/output/serializer.hpp +988 -0
- mqt/core/include/nlohmann/detail/string_concat.hpp +146 -0
- mqt/core/include/nlohmann/detail/string_escape.hpp +72 -0
- mqt/core/include/nlohmann/detail/string_utils.hpp +37 -0
- mqt/core/include/nlohmann/detail/value_t.hpp +118 -0
- mqt/core/include/nlohmann/json.hpp +5306 -0
- mqt/core/include/nlohmann/json_fwd.hpp +75 -0
- mqt/core/include/nlohmann/ordered_map.hpp +359 -0
- mqt/core/include/nlohmann/thirdparty/hedley/hedley.hpp +2045 -0
- mqt/core/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +158 -0
- mqt/core/include/qdmi/qdmi/client.h +990 -0
- mqt/core/include/qdmi/qdmi/constants.h +1139 -0
- mqt/core/include/qdmi/qdmi/device.h +602 -0
- mqt/core/include/qdmi/qdmi/types.h +78 -0
- mqt/core/include/spdlog/async.h +99 -0
- mqt/core/include/spdlog/async_logger-inl.h +84 -0
- mqt/core/include/spdlog/async_logger.h +74 -0
- mqt/core/include/spdlog/cfg/argv.h +40 -0
- mqt/core/include/spdlog/cfg/env.h +36 -0
- mqt/core/include/spdlog/cfg/helpers-inl.h +107 -0
- mqt/core/include/spdlog/cfg/helpers.h +29 -0
- mqt/core/include/spdlog/common-inl.h +68 -0
- mqt/core/include/spdlog/common.h +406 -0
- mqt/core/include/spdlog/details/backtracer-inl.h +63 -0
- mqt/core/include/spdlog/details/backtracer.h +45 -0
- mqt/core/include/spdlog/details/circular_q.h +115 -0
- mqt/core/include/spdlog/details/console_globals.h +28 -0
- mqt/core/include/spdlog/details/file_helper-inl.h +153 -0
- mqt/core/include/spdlog/details/file_helper.h +61 -0
- mqt/core/include/spdlog/details/fmt_helper.h +141 -0
- mqt/core/include/spdlog/details/log_msg-inl.h +44 -0
- mqt/core/include/spdlog/details/log_msg.h +40 -0
- mqt/core/include/spdlog/details/log_msg_buffer-inl.h +54 -0
- mqt/core/include/spdlog/details/log_msg_buffer.h +32 -0
- mqt/core/include/spdlog/details/mpmc_blocking_q.h +177 -0
- mqt/core/include/spdlog/details/null_mutex.h +35 -0
- mqt/core/include/spdlog/details/os-inl.h +606 -0
- mqt/core/include/spdlog/details/os.h +127 -0
- mqt/core/include/spdlog/details/periodic_worker-inl.h +26 -0
- mqt/core/include/spdlog/details/periodic_worker.h +58 -0
- mqt/core/include/spdlog/details/registry-inl.h +270 -0
- mqt/core/include/spdlog/details/registry.h +131 -0
- mqt/core/include/spdlog/details/synchronous_factory.h +22 -0
- mqt/core/include/spdlog/details/tcp_client-windows.h +135 -0
- mqt/core/include/spdlog/details/tcp_client.h +127 -0
- mqt/core/include/spdlog/details/thread_pool-inl.h +126 -0
- mqt/core/include/spdlog/details/thread_pool.h +117 -0
- mqt/core/include/spdlog/details/udp_client-windows.h +98 -0
- mqt/core/include/spdlog/details/udp_client.h +81 -0
- mqt/core/include/spdlog/details/windows_include.h +11 -0
- mqt/core/include/spdlog/fmt/bin_to_hex.h +224 -0
- mqt/core/include/spdlog/fmt/bundled/args.h +220 -0
- mqt/core/include/spdlog/fmt/bundled/base.h +2989 -0
- mqt/core/include/spdlog/fmt/bundled/chrono.h +2330 -0
- mqt/core/include/spdlog/fmt/bundled/color.h +637 -0
- mqt/core/include/spdlog/fmt/bundled/compile.h +539 -0
- mqt/core/include/spdlog/fmt/bundled/core.h +5 -0
- mqt/core/include/spdlog/fmt/bundled/fmt.license.rst +27 -0
- mqt/core/include/spdlog/fmt/bundled/format-inl.h +1948 -0
- mqt/core/include/spdlog/fmt/bundled/format.h +4244 -0
- mqt/core/include/spdlog/fmt/bundled/os.h +427 -0
- mqt/core/include/spdlog/fmt/bundled/ostream.h +167 -0
- mqt/core/include/spdlog/fmt/bundled/printf.h +633 -0
- mqt/core/include/spdlog/fmt/bundled/ranges.h +850 -0
- mqt/core/include/spdlog/fmt/bundled/std.h +728 -0
- mqt/core/include/spdlog/fmt/bundled/xchar.h +369 -0
- mqt/core/include/spdlog/fmt/chrono.h +23 -0
- mqt/core/include/spdlog/fmt/compile.h +23 -0
- mqt/core/include/spdlog/fmt/fmt.h +30 -0
- mqt/core/include/spdlog/fmt/ostr.h +23 -0
- mqt/core/include/spdlog/fmt/ranges.h +23 -0
- mqt/core/include/spdlog/fmt/std.h +24 -0
- mqt/core/include/spdlog/fmt/xchar.h +23 -0
- mqt/core/include/spdlog/formatter.h +17 -0
- mqt/core/include/spdlog/fwd.h +18 -0
- mqt/core/include/spdlog/logger-inl.h +198 -0
- mqt/core/include/spdlog/logger.h +379 -0
- mqt/core/include/spdlog/mdc.h +52 -0
- mqt/core/include/spdlog/pattern_formatter-inl.h +1340 -0
- mqt/core/include/spdlog/pattern_formatter.h +118 -0
- mqt/core/include/spdlog/sinks/android_sink.h +137 -0
- mqt/core/include/spdlog/sinks/ansicolor_sink-inl.h +142 -0
- mqt/core/include/spdlog/sinks/ansicolor_sink.h +116 -0
- mqt/core/include/spdlog/sinks/base_sink-inl.h +59 -0
- mqt/core/include/spdlog/sinks/base_sink.h +51 -0
- mqt/core/include/spdlog/sinks/basic_file_sink-inl.h +48 -0
- mqt/core/include/spdlog/sinks/basic_file_sink.h +66 -0
- mqt/core/include/spdlog/sinks/callback_sink.h +56 -0
- mqt/core/include/spdlog/sinks/daily_file_sink.h +254 -0
- mqt/core/include/spdlog/sinks/dist_sink.h +81 -0
- mqt/core/include/spdlog/sinks/dup_filter_sink.h +91 -0
- mqt/core/include/spdlog/sinks/hourly_file_sink.h +193 -0
- mqt/core/include/spdlog/sinks/kafka_sink.h +119 -0
- mqt/core/include/spdlog/sinks/mongo_sink.h +108 -0
- mqt/core/include/spdlog/sinks/msvc_sink.h +68 -0
- mqt/core/include/spdlog/sinks/null_sink.h +41 -0
- mqt/core/include/spdlog/sinks/ostream_sink.h +43 -0
- mqt/core/include/spdlog/sinks/qt_sinks.h +304 -0
- mqt/core/include/spdlog/sinks/ringbuffer_sink.h +67 -0
- mqt/core/include/spdlog/sinks/rotating_file_sink-inl.h +179 -0
- mqt/core/include/spdlog/sinks/rotating_file_sink.h +93 -0
- mqt/core/include/spdlog/sinks/sink-inl.h +22 -0
- mqt/core/include/spdlog/sinks/sink.h +34 -0
- mqt/core/include/spdlog/sinks/stdout_color_sinks-inl.h +38 -0
- mqt/core/include/spdlog/sinks/stdout_color_sinks.h +49 -0
- mqt/core/include/spdlog/sinks/stdout_sinks-inl.h +127 -0
- mqt/core/include/spdlog/sinks/stdout_sinks.h +84 -0
- mqt/core/include/spdlog/sinks/syslog_sink.h +104 -0
- mqt/core/include/spdlog/sinks/systemd_sink.h +121 -0
- mqt/core/include/spdlog/sinks/tcp_sink.h +75 -0
- mqt/core/include/spdlog/sinks/udp_sink.h +69 -0
- mqt/core/include/spdlog/sinks/win_eventlog_sink.h +260 -0
- mqt/core/include/spdlog/sinks/wincolor_sink-inl.h +172 -0
- mqt/core/include/spdlog/sinks/wincolor_sink.h +82 -0
- mqt/core/include/spdlog/spdlog-inl.h +96 -0
- mqt/core/include/spdlog/spdlog.h +357 -0
- mqt/core/include/spdlog/stopwatch.h +66 -0
- mqt/core/include/spdlog/tweakme.h +148 -0
- mqt/core/include/spdlog/version.h +11 -0
- mqt/core/ir/__init__.pyi +83 -45
- mqt/core/ir/operations.pyi +40 -27
- mqt/core/ir.cp312-win_arm64.pyd +0 -0
- mqt/core/lib/mqt-core-circuit-optimizer.lib +0 -0
- mqt/core/lib/mqt-core-dd.lib +0 -0
- mqt/core/lib/mqt-core-fomac.lib +0 -0
- mqt/core/lib/mqt-core-ir.lib +0 -0
- mqt/core/lib/mqt-core-na-fomac.lib +0 -0
- mqt/core/lib/mqt-core-qasm.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-driver.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-na-device-gen.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-na-device.lib +0 -0
- mqt/core/lib/pkgconfig/spdlog.pc +13 -0
- mqt/core/lib/spdlog.lib +0 -0
- mqt/core/na/__init__.py +12 -0
- mqt/core/na/fomac.cp312-win_arm64.pyd +0 -0
- mqt/core/na/fomac.pyi +117 -0
- mqt/core/nlohmann_json.natvis +278 -0
- mqt/core/plugins/qiskit/mqt_to_qiskit.py +75 -11
- mqt/core/plugins/qiskit/qiskit_to_mqt.py +108 -5
- mqt/core/share/cmake/mqt-core/AddMQTPythonBinding.cmake +3 -0
- mqt/core/share/cmake/mqt-core/Cache.cmake +17 -16
- mqt/core/share/cmake/mqt-core/PackageAddTest.cmake +6 -0
- mqt/core/share/cmake/mqt-core/StandardProjectSettings.cmake +1 -1
- mqt/core/share/cmake/mqt-core/mqt-core-config-version.cmake +3 -3
- mqt/core/share/cmake/mqt-core/mqt-core-config.cmake +3 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets-release.cmake +51 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets.cmake +124 -3
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake +15 -0
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake +20 -0
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake +110 -0
- mqt/core/share/cmake/qdmi/Cache.cmake +44 -0
- mqt/core/share/cmake/qdmi/PrefixHandling.cmake +78 -0
- mqt/core/share/cmake/qdmi/prefix_defs.txt +26 -0
- mqt/core/share/cmake/qdmi/qdmi-config-version.cmake +85 -0
- mqt/core/share/cmake/qdmi/qdmi-config.cmake +42 -0
- mqt/core/share/cmake/qdmi/qdmi-targets.cmake +129 -0
- mqt/core/share/cmake/spdlog/spdlogConfig.cmake +44 -0
- mqt/core/share/cmake/spdlog/spdlogConfigTargets-release.cmake +19 -0
- mqt/core/share/cmake/spdlog/spdlogConfigTargets.cmake +121 -0
- mqt/core/share/cmake/spdlog/spdlogConfigVersion.cmake +65 -0
- mqt/core/share/pkgconfig/nlohmann_json.pc +7 -0
- mqt_core-3.3.1.dist-info/DELVEWHEEL +2 -0
- {mqt_core-3.2.1.dist-info → mqt_core-3.3.1.dist-info}/METADATA +74 -33
- {mqt_core-3.2.1.dist-info → mqt_core-3.3.1.dist-info}/RECORD +240 -46
- {mqt_core-3.2.1.dist-info → mqt_core-3.3.1.dist-info}/WHEEL +1 -1
- mqt/core/include/mqt-core/ir/operations/ClassicControlledOperation.hpp +0 -156
- mqt_core-3.2.1.dist-info/DELVEWHEEL +0 -2
- {mqt_core-3.2.1.dist-info → mqt_core-3.3.1.dist-info}/entry_points.txt +0 -0
- {mqt_core-3.2.1.dist-info → mqt_core-3.3.1.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright(c) 2015 Gabi Melman.
|
|
3
|
+
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <cctype>
|
|
9
|
+
#include <spdlog/common.h>
|
|
10
|
+
|
|
11
|
+
#if defined(__has_include)
|
|
12
|
+
#if __has_include(<version>)
|
|
13
|
+
#include <version>
|
|
14
|
+
#endif
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#if __cpp_lib_span >= 202002L
|
|
18
|
+
#include <span>
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
// Support for logging binary data as hex
|
|
23
|
+
// format flags, any combination of the following:
|
|
24
|
+
// {:X} - print in uppercase.
|
|
25
|
+
// {:s} - don't separate each byte with space.
|
|
26
|
+
// {:p} - don't print the position on each line start.
|
|
27
|
+
// {:n} - don't split the output to lines.
|
|
28
|
+
// {:a} - show ASCII if :n is not set
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// Examples:
|
|
32
|
+
//
|
|
33
|
+
// std::vector<char> v(200, 0x0b);
|
|
34
|
+
// logger->info("Some buffer {}", spdlog::to_hex(v));
|
|
35
|
+
// char buf[128];
|
|
36
|
+
// logger->info("Some buffer {:X}", spdlog::to_hex(std::begin(buf), std::end(buf)));
|
|
37
|
+
// logger->info("Some buffer {:X}", spdlog::to_hex(std::begin(buf), std::end(buf), 16));
|
|
38
|
+
|
|
39
|
+
namespace spdlog {
|
|
40
|
+
namespace details {
|
|
41
|
+
|
|
42
|
+
template <typename It>
|
|
43
|
+
class dump_info {
|
|
44
|
+
public:
|
|
45
|
+
dump_info(It range_begin, It range_end, size_t size_per_line)
|
|
46
|
+
: begin_(range_begin),
|
|
47
|
+
end_(range_end),
|
|
48
|
+
size_per_line_(size_per_line) {}
|
|
49
|
+
|
|
50
|
+
// do not use begin() and end() to avoid collision with fmt/ranges
|
|
51
|
+
It get_begin() const { return begin_; }
|
|
52
|
+
It get_end() const { return end_; }
|
|
53
|
+
size_t size_per_line() const { return size_per_line_; }
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
It begin_, end_;
|
|
57
|
+
size_t size_per_line_;
|
|
58
|
+
};
|
|
59
|
+
} // namespace details
|
|
60
|
+
|
|
61
|
+
// create a dump_info that wraps the given container
|
|
62
|
+
template <typename Container>
|
|
63
|
+
inline details::dump_info<typename Container::const_iterator> to_hex(const Container &container,
|
|
64
|
+
size_t size_per_line = 32) {
|
|
65
|
+
static_assert(sizeof(typename Container::value_type) == 1,
|
|
66
|
+
"sizeof(Container::value_type) != 1");
|
|
67
|
+
using Iter = typename Container::const_iterator;
|
|
68
|
+
return details::dump_info<Iter>(std::begin(container), std::end(container), size_per_line);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#if __cpp_lib_span >= 202002L
|
|
72
|
+
|
|
73
|
+
template <typename Value, size_t Extent>
|
|
74
|
+
inline details::dump_info<typename std::span<Value, Extent>::iterator> to_hex(
|
|
75
|
+
const std::span<Value, Extent> &container, size_t size_per_line = 32) {
|
|
76
|
+
using Container = std::span<Value, Extent>;
|
|
77
|
+
static_assert(sizeof(typename Container::value_type) == 1,
|
|
78
|
+
"sizeof(Container::value_type) != 1");
|
|
79
|
+
using Iter = typename Container::iterator;
|
|
80
|
+
return details::dump_info<Iter>(std::begin(container), std::end(container), size_per_line);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
// create dump_info from ranges
|
|
86
|
+
template <typename It>
|
|
87
|
+
inline details::dump_info<It> to_hex(const It range_begin,
|
|
88
|
+
const It range_end,
|
|
89
|
+
size_t size_per_line = 32) {
|
|
90
|
+
return details::dump_info<It>(range_begin, range_end, size_per_line);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
} // namespace spdlog
|
|
94
|
+
|
|
95
|
+
namespace
|
|
96
|
+
#ifdef SPDLOG_USE_STD_FORMAT
|
|
97
|
+
std
|
|
98
|
+
#else
|
|
99
|
+
fmt
|
|
100
|
+
#endif
|
|
101
|
+
{
|
|
102
|
+
|
|
103
|
+
template <typename T>
|
|
104
|
+
struct formatter<spdlog::details::dump_info<T>, char> {
|
|
105
|
+
char delimiter = ' ';
|
|
106
|
+
bool put_newlines = true;
|
|
107
|
+
bool put_delimiters = true;
|
|
108
|
+
bool use_uppercase = false;
|
|
109
|
+
bool put_positions = true; // position on start of each line
|
|
110
|
+
bool show_ascii = false;
|
|
111
|
+
|
|
112
|
+
// parse the format string flags
|
|
113
|
+
template <typename ParseContext>
|
|
114
|
+
SPDLOG_CONSTEXPR_FUNC auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
|
|
115
|
+
auto it = ctx.begin();
|
|
116
|
+
while (it != ctx.end() && *it != '}') {
|
|
117
|
+
switch (*it) {
|
|
118
|
+
case 'X':
|
|
119
|
+
use_uppercase = true;
|
|
120
|
+
break;
|
|
121
|
+
case 's':
|
|
122
|
+
put_delimiters = false;
|
|
123
|
+
break;
|
|
124
|
+
case 'p':
|
|
125
|
+
put_positions = false;
|
|
126
|
+
break;
|
|
127
|
+
case 'n':
|
|
128
|
+
put_newlines = false;
|
|
129
|
+
show_ascii = false;
|
|
130
|
+
break;
|
|
131
|
+
case 'a':
|
|
132
|
+
if (put_newlines) {
|
|
133
|
+
show_ascii = true;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
++it;
|
|
139
|
+
}
|
|
140
|
+
return it;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// format the given bytes range as hex
|
|
144
|
+
template <typename FormatContext, typename Container>
|
|
145
|
+
auto format(const spdlog::details::dump_info<Container> &the_range,
|
|
146
|
+
FormatContext &ctx) const -> decltype(ctx.out()) {
|
|
147
|
+
SPDLOG_CONSTEXPR const char *hex_upper = "0123456789ABCDEF";
|
|
148
|
+
SPDLOG_CONSTEXPR const char *hex_lower = "0123456789abcdef";
|
|
149
|
+
const char *hex_chars = use_uppercase ? hex_upper : hex_lower;
|
|
150
|
+
|
|
151
|
+
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION < 60000
|
|
152
|
+
auto inserter = ctx.begin();
|
|
153
|
+
#else
|
|
154
|
+
auto inserter = ctx.out();
|
|
155
|
+
#endif
|
|
156
|
+
|
|
157
|
+
int size_per_line = static_cast<int>(the_range.size_per_line());
|
|
158
|
+
auto start_of_line = the_range.get_begin();
|
|
159
|
+
for (auto i = the_range.get_begin(); i != the_range.get_end(); i++) {
|
|
160
|
+
auto ch = static_cast<unsigned char>(*i);
|
|
161
|
+
|
|
162
|
+
if (put_newlines &&
|
|
163
|
+
(i == the_range.get_begin() || i - start_of_line >= size_per_line)) {
|
|
164
|
+
if (show_ascii && i != the_range.get_begin()) {
|
|
165
|
+
*inserter++ = delimiter;
|
|
166
|
+
*inserter++ = delimiter;
|
|
167
|
+
for (auto j = start_of_line; j < i; j++) {
|
|
168
|
+
auto pc = static_cast<unsigned char>(*j);
|
|
169
|
+
*inserter++ = std::isprint(pc) ? static_cast<char>(*j) : '.';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
put_newline(inserter, static_cast<size_t>(i - the_range.get_begin()));
|
|
174
|
+
|
|
175
|
+
// put first byte without delimiter in front of it
|
|
176
|
+
*inserter++ = hex_chars[(ch >> 4) & 0x0f];
|
|
177
|
+
*inserter++ = hex_chars[ch & 0x0f];
|
|
178
|
+
start_of_line = i;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (put_delimiters && i != the_range.get_begin()) {
|
|
183
|
+
*inserter++ = delimiter;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
*inserter++ = hex_chars[(ch >> 4) & 0x0f];
|
|
187
|
+
*inserter++ = hex_chars[ch & 0x0f];
|
|
188
|
+
}
|
|
189
|
+
if (show_ascii) // add ascii to last line
|
|
190
|
+
{
|
|
191
|
+
if (the_range.get_end() - the_range.get_begin() > size_per_line) {
|
|
192
|
+
auto blank_num = size_per_line - (the_range.get_end() - start_of_line);
|
|
193
|
+
while (blank_num-- > 0) {
|
|
194
|
+
*inserter++ = delimiter;
|
|
195
|
+
*inserter++ = delimiter;
|
|
196
|
+
if (put_delimiters) {
|
|
197
|
+
*inserter++ = delimiter;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
*inserter++ = delimiter;
|
|
202
|
+
*inserter++ = delimiter;
|
|
203
|
+
for (auto j = start_of_line; j != the_range.get_end(); j++) {
|
|
204
|
+
auto pc = static_cast<unsigned char>(*j);
|
|
205
|
+
*inserter++ = std::isprint(pc) ? static_cast<char>(*j) : '.';
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return inserter;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// put newline(and position header)
|
|
212
|
+
template <typename It>
|
|
213
|
+
void put_newline(It inserter, std::size_t pos) const {
|
|
214
|
+
#ifdef _WIN32
|
|
215
|
+
*inserter++ = '\r';
|
|
216
|
+
#endif
|
|
217
|
+
*inserter++ = '\n';
|
|
218
|
+
|
|
219
|
+
if (put_positions) {
|
|
220
|
+
spdlog::fmt_lib::format_to(inserter, SPDLOG_FMT_STRING("{:04X}: "), pos);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
} // namespace std
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Formatting library for C++ - dynamic argument lists
|
|
2
|
+
//
|
|
3
|
+
// Copyright (c) 2012 - present, Victor Zverovich
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// For the license information refer to format.h.
|
|
7
|
+
|
|
8
|
+
#ifndef FMT_ARGS_H_
|
|
9
|
+
#define FMT_ARGS_H_
|
|
10
|
+
|
|
11
|
+
#ifndef FMT_MODULE
|
|
12
|
+
# include <functional> // std::reference_wrapper
|
|
13
|
+
# include <memory> // std::unique_ptr
|
|
14
|
+
# include <vector>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#include "format.h" // std_string_view
|
|
18
|
+
|
|
19
|
+
FMT_BEGIN_NAMESPACE
|
|
20
|
+
namespace detail {
|
|
21
|
+
|
|
22
|
+
template <typename T> struct is_reference_wrapper : std::false_type {};
|
|
23
|
+
template <typename T>
|
|
24
|
+
struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};
|
|
25
|
+
|
|
26
|
+
template <typename T> auto unwrap(const T& v) -> const T& { return v; }
|
|
27
|
+
template <typename T>
|
|
28
|
+
auto unwrap(const std::reference_wrapper<T>& v) -> const T& {
|
|
29
|
+
return static_cast<const T&>(v);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// node is defined outside dynamic_arg_list to workaround a C2504 bug in MSVC
|
|
33
|
+
// 2022 (v17.10.0).
|
|
34
|
+
//
|
|
35
|
+
// Workaround for clang's -Wweak-vtables. Unlike for regular classes, for
|
|
36
|
+
// templates it doesn't complain about inability to deduce single translation
|
|
37
|
+
// unit for placing vtable. So node is made a fake template.
|
|
38
|
+
template <typename = void> struct node {
|
|
39
|
+
virtual ~node() = default;
|
|
40
|
+
std::unique_ptr<node<>> next;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
class dynamic_arg_list {
|
|
44
|
+
template <typename T> struct typed_node : node<> {
|
|
45
|
+
T value;
|
|
46
|
+
|
|
47
|
+
template <typename Arg>
|
|
48
|
+
FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {}
|
|
49
|
+
|
|
50
|
+
template <typename Char>
|
|
51
|
+
FMT_CONSTEXPR typed_node(const basic_string_view<Char>& arg)
|
|
52
|
+
: value(arg.data(), arg.size()) {}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
std::unique_ptr<node<>> head_;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
template <typename T, typename Arg> auto push(const Arg& arg) -> const T& {
|
|
59
|
+
auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));
|
|
60
|
+
auto& value = new_node->value;
|
|
61
|
+
new_node->next = std::move(head_);
|
|
62
|
+
head_ = std::move(new_node);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
} // namespace detail
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A dynamic list of formatting arguments with storage.
|
|
70
|
+
*
|
|
71
|
+
* It can be implicitly converted into `fmt::basic_format_args` for passing
|
|
72
|
+
* into type-erased formatting functions such as `fmt::vformat`.
|
|
73
|
+
*/
|
|
74
|
+
template <typename Context> class dynamic_format_arg_store {
|
|
75
|
+
private:
|
|
76
|
+
using char_type = typename Context::char_type;
|
|
77
|
+
|
|
78
|
+
template <typename T> struct need_copy {
|
|
79
|
+
static constexpr detail::type mapped_type =
|
|
80
|
+
detail::mapped_type_constant<T, char_type>::value;
|
|
81
|
+
|
|
82
|
+
enum {
|
|
83
|
+
value = !(detail::is_reference_wrapper<T>::value ||
|
|
84
|
+
std::is_same<T, basic_string_view<char_type>>::value ||
|
|
85
|
+
std::is_same<T, detail::std_string_view<char_type>>::value ||
|
|
86
|
+
(mapped_type != detail::type::cstring_type &&
|
|
87
|
+
mapped_type != detail::type::string_type &&
|
|
88
|
+
mapped_type != detail::type::custom_type))
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
template <typename T>
|
|
93
|
+
using stored_t = conditional_t<
|
|
94
|
+
std::is_convertible<T, std::basic_string<char_type>>::value &&
|
|
95
|
+
!detail::is_reference_wrapper<T>::value,
|
|
96
|
+
std::basic_string<char_type>, T>;
|
|
97
|
+
|
|
98
|
+
// Storage of basic_format_arg must be contiguous.
|
|
99
|
+
std::vector<basic_format_arg<Context>> data_;
|
|
100
|
+
std::vector<detail::named_arg_info<char_type>> named_info_;
|
|
101
|
+
|
|
102
|
+
// Storage of arguments not fitting into basic_format_arg must grow
|
|
103
|
+
// without relocation because items in data_ refer to it.
|
|
104
|
+
detail::dynamic_arg_list dynamic_args_;
|
|
105
|
+
|
|
106
|
+
friend class basic_format_args<Context>;
|
|
107
|
+
|
|
108
|
+
auto data() const -> const basic_format_arg<Context>* {
|
|
109
|
+
return named_info_.empty() ? data_.data() : data_.data() + 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
template <typename T> void emplace_arg(const T& arg) {
|
|
113
|
+
data_.emplace_back(arg);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
template <typename T>
|
|
117
|
+
void emplace_arg(const detail::named_arg<char_type, T>& arg) {
|
|
118
|
+
if (named_info_.empty())
|
|
119
|
+
data_.insert(data_.begin(), basic_format_arg<Context>(nullptr, 0));
|
|
120
|
+
data_.emplace_back(detail::unwrap(arg.value));
|
|
121
|
+
auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
|
|
122
|
+
data->pop_back();
|
|
123
|
+
};
|
|
124
|
+
std::unique_ptr<std::vector<basic_format_arg<Context>>, decltype(pop_one)>
|
|
125
|
+
guard{&data_, pop_one};
|
|
126
|
+
named_info_.push_back({arg.name, static_cast<int>(data_.size() - 2u)});
|
|
127
|
+
data_[0] = {named_info_.data(), named_info_.size()};
|
|
128
|
+
guard.release();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public:
|
|
132
|
+
constexpr dynamic_format_arg_store() = default;
|
|
133
|
+
|
|
134
|
+
operator basic_format_args<Context>() const {
|
|
135
|
+
return basic_format_args<Context>(data(), static_cast<int>(data_.size()),
|
|
136
|
+
!named_info_.empty());
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Adds an argument into the dynamic store for later passing to a formatting
|
|
141
|
+
* function.
|
|
142
|
+
*
|
|
143
|
+
* Note that custom types and string types (but not string views) are copied
|
|
144
|
+
* into the store dynamically allocating memory if necessary.
|
|
145
|
+
*
|
|
146
|
+
* **Example**:
|
|
147
|
+
*
|
|
148
|
+
* fmt::dynamic_format_arg_store<fmt::format_context> store;
|
|
149
|
+
* store.push_back(42);
|
|
150
|
+
* store.push_back("abc");
|
|
151
|
+
* store.push_back(1.5f);
|
|
152
|
+
* std::string result = fmt::vformat("{} and {} and {}", store);
|
|
153
|
+
*/
|
|
154
|
+
template <typename T> void push_back(const T& arg) {
|
|
155
|
+
if (detail::const_check(need_copy<T>::value))
|
|
156
|
+
emplace_arg(dynamic_args_.push<stored_t<T>>(arg));
|
|
157
|
+
else
|
|
158
|
+
emplace_arg(detail::unwrap(arg));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Adds a reference to the argument into the dynamic store for later passing
|
|
163
|
+
* to a formatting function.
|
|
164
|
+
*
|
|
165
|
+
* **Example**:
|
|
166
|
+
*
|
|
167
|
+
* fmt::dynamic_format_arg_store<fmt::format_context> store;
|
|
168
|
+
* char band[] = "Rolling Stones";
|
|
169
|
+
* store.push_back(std::cref(band));
|
|
170
|
+
* band[9] = 'c'; // Changing str affects the output.
|
|
171
|
+
* std::string result = fmt::vformat("{}", store);
|
|
172
|
+
* // result == "Rolling Scones"
|
|
173
|
+
*/
|
|
174
|
+
template <typename T> void push_back(std::reference_wrapper<T> arg) {
|
|
175
|
+
static_assert(
|
|
176
|
+
need_copy<T>::value,
|
|
177
|
+
"objects of built-in types and string views are always copied");
|
|
178
|
+
emplace_arg(arg.get());
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Adds named argument into the dynamic store for later passing to a
|
|
183
|
+
* formatting function. `std::reference_wrapper` is supported to avoid
|
|
184
|
+
* copying of the argument. The name is always copied into the store.
|
|
185
|
+
*/
|
|
186
|
+
template <typename T>
|
|
187
|
+
void push_back(const detail::named_arg<char_type, T>& arg) {
|
|
188
|
+
const char_type* arg_name =
|
|
189
|
+
dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();
|
|
190
|
+
if (detail::const_check(need_copy<T>::value)) {
|
|
191
|
+
emplace_arg(
|
|
192
|
+
fmt::arg(arg_name, dynamic_args_.push<stored_t<T>>(arg.value)));
|
|
193
|
+
} else {
|
|
194
|
+
emplace_arg(fmt::arg(arg_name, arg.value));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/// Erase all elements from the store.
|
|
199
|
+
void clear() {
|
|
200
|
+
data_.clear();
|
|
201
|
+
named_info_.clear();
|
|
202
|
+
dynamic_args_ = {};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/// Reserves space to store at least `new_cap` arguments including
|
|
206
|
+
/// `new_cap_named` named arguments.
|
|
207
|
+
void reserve(size_t new_cap, size_t new_cap_named) {
|
|
208
|
+
FMT_ASSERT(new_cap >= new_cap_named,
|
|
209
|
+
"set of arguments includes set of named arguments");
|
|
210
|
+
data_.reserve(new_cap);
|
|
211
|
+
named_info_.reserve(new_cap_named);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/// Returns the number of elements in the store.
|
|
215
|
+
size_t size() const noexcept { return data_.size(); }
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
FMT_END_NAMESPACE
|
|
219
|
+
|
|
220
|
+
#endif // FMT_ARGS_H_
|