mqt-core 3.3.2__cp314-cp314t-macosx_11_0_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.
- mqt/core/__init__.py +77 -0
- mqt/core/__main__.py +55 -0
- mqt/core/_commands.py +52 -0
- mqt/core/_compat/__init__.py +11 -0
- mqt/core/_compat/typing.py +29 -0
- mqt/core/_version.py +34 -0
- mqt/core/_version.pyi +12 -0
- mqt/core/dd.cpython-314t-darwin.so +0 -0
- mqt/core/dd.pyi +1016 -0
- mqt/core/dd_evaluation.py +368 -0
- mqt/core/fomac.cpython-314t-darwin.so +0 -0
- mqt/core/fomac.pyi +125 -0
- mqt/core/include/mqt-core/algorithms/BernsteinVazirani.hpp +39 -0
- mqt/core/include/mqt-core/algorithms/GHZState.hpp +18 -0
- mqt/core/include/mqt-core/algorithms/Grover.hpp +33 -0
- mqt/core/include/mqt-core/algorithms/QFT.hpp +21 -0
- mqt/core/include/mqt-core/algorithms/QPE.hpp +30 -0
- mqt/core/include/mqt-core/algorithms/RandomCliffordCircuit.hpp +22 -0
- mqt/core/include/mqt-core/algorithms/StatePreparation.hpp +43 -0
- mqt/core/include/mqt-core/algorithms/WState.hpp +18 -0
- mqt/core/include/mqt-core/algorithms/mqt_core_algorithms_export.h +43 -0
- mqt/core/include/mqt-core/boost/config/abi/borland_prefix.hpp +27 -0
- mqt/core/include/mqt-core/boost/config/abi/borland_suffix.hpp +12 -0
- mqt/core/include/mqt-core/boost/config/abi/msvc_prefix.hpp +22 -0
- mqt/core/include/mqt-core/boost/config/abi/msvc_suffix.hpp +8 -0
- mqt/core/include/mqt-core/boost/config/abi_prefix.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/abi_suffix.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx03.hpp +211 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx11.hpp +212 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx14.hpp +47 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx17.hpp +65 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx20.hpp +59 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx23.hpp +41 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx98.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/auto_link.hpp +525 -0
- mqt/core/include/mqt-core/boost/config/compiler/borland.hpp +342 -0
- mqt/core/include/mqt-core/boost/config/compiler/clang.hpp +370 -0
- mqt/core/include/mqt-core/boost/config/compiler/clang_version.hpp +89 -0
- mqt/core/include/mqt-core/boost/config/compiler/codegear.hpp +389 -0
- mqt/core/include/mqt-core/boost/config/compiler/comeau.hpp +59 -0
- mqt/core/include/mqt-core/boost/config/compiler/common_edg.hpp +185 -0
- mqt/core/include/mqt-core/boost/config/compiler/compaq_cxx.hpp +19 -0
- mqt/core/include/mqt-core/boost/config/compiler/cray.hpp +446 -0
- mqt/core/include/mqt-core/boost/config/compiler/diab.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/compiler/digitalmars.hpp +146 -0
- mqt/core/include/mqt-core/boost/config/compiler/gcc.hpp +386 -0
- mqt/core/include/mqt-core/boost/config/compiler/gcc_xml.hpp +115 -0
- mqt/core/include/mqt-core/boost/config/compiler/greenhills.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/compiler/hp_acc.hpp +153 -0
- mqt/core/include/mqt-core/boost/config/compiler/intel.hpp +577 -0
- mqt/core/include/mqt-core/boost/config/compiler/kai.hpp +33 -0
- mqt/core/include/mqt-core/boost/config/compiler/metrowerks.hpp +201 -0
- mqt/core/include/mqt-core/boost/config/compiler/mpw.hpp +143 -0
- mqt/core/include/mqt-core/boost/config/compiler/nvcc.hpp +64 -0
- mqt/core/include/mqt-core/boost/config/compiler/pathscale.hpp +141 -0
- mqt/core/include/mqt-core/boost/config/compiler/pgi.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/compiler/sgi_mipspro.hpp +29 -0
- mqt/core/include/mqt-core/boost/config/compiler/sunpro_cc.hpp +225 -0
- mqt/core/include/mqt-core/boost/config/compiler/vacpp.hpp +189 -0
- mqt/core/include/mqt-core/boost/config/compiler/visualc.hpp +398 -0
- mqt/core/include/mqt-core/boost/config/compiler/xlcpp.hpp +303 -0
- mqt/core/include/mqt-core/boost/config/compiler/xlcpp_zos.hpp +174 -0
- mqt/core/include/mqt-core/boost/config/detail/cxx_composite.hpp +218 -0
- mqt/core/include/mqt-core/boost/config/detail/posix_features.hpp +95 -0
- mqt/core/include/mqt-core/boost/config/detail/select_compiler_config.hpp +157 -0
- mqt/core/include/mqt-core/boost/config/detail/select_platform_config.hpp +147 -0
- mqt/core/include/mqt-core/boost/config/detail/select_stdlib_config.hpp +121 -0
- mqt/core/include/mqt-core/boost/config/detail/suffix.hpp +1334 -0
- mqt/core/include/mqt-core/boost/config/header_deprecated.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/helper_macros.hpp +37 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/cmath.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/complex.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/functional.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/memory.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/utility.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/platform/aix.hpp +33 -0
- mqt/core/include/mqt-core/boost/config/platform/amigaos.hpp +15 -0
- mqt/core/include/mqt-core/boost/config/platform/beos.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/platform/bsd.hpp +83 -0
- mqt/core/include/mqt-core/boost/config/platform/cloudabi.hpp +18 -0
- mqt/core/include/mqt-core/boost/config/platform/cray.hpp +18 -0
- mqt/core/include/mqt-core/boost/config/platform/cygwin.hpp +71 -0
- mqt/core/include/mqt-core/boost/config/platform/haiku.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/hpux.hpp +87 -0
- mqt/core/include/mqt-core/boost/config/platform/irix.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/linux.hpp +106 -0
- mqt/core/include/mqt-core/boost/config/platform/macos.hpp +87 -0
- mqt/core/include/mqt-core/boost/config/platform/qnxnto.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/solaris.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/symbian.hpp +97 -0
- mqt/core/include/mqt-core/boost/config/platform/vms.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/platform/vxworks.hpp +422 -0
- mqt/core/include/mqt-core/boost/config/platform/wasm.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/platform/win32.hpp +90 -0
- mqt/core/include/mqt-core/boost/config/platform/zos.hpp +32 -0
- mqt/core/include/mqt-core/boost/config/pragma_message.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/requires_threads.hpp +92 -0
- mqt/core/include/mqt-core/boost/config/stdlib/dinkumware.hpp +324 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libcomo.hpp +93 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libcpp.hpp +180 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libstdcpp3.hpp +482 -0
- mqt/core/include/mqt-core/boost/config/stdlib/modena.hpp +79 -0
- mqt/core/include/mqt-core/boost/config/stdlib/msl.hpp +98 -0
- mqt/core/include/mqt-core/boost/config/stdlib/roguewave.hpp +208 -0
- mqt/core/include/mqt-core/boost/config/stdlib/sgi.hpp +168 -0
- mqt/core/include/mqt-core/boost/config/stdlib/stlport.hpp +258 -0
- mqt/core/include/mqt-core/boost/config/stdlib/vacpp.hpp +74 -0
- mqt/core/include/mqt-core/boost/config/stdlib/xlcpp_zos.hpp +61 -0
- mqt/core/include/mqt-core/boost/config/user.hpp +133 -0
- mqt/core/include/mqt-core/boost/config/warning_disable.hpp +47 -0
- mqt/core/include/mqt-core/boost/config/workaround.hpp +305 -0
- mqt/core/include/mqt-core/boost/config.hpp +67 -0
- mqt/core/include/mqt-core/boost/cstdint.hpp +556 -0
- mqt/core/include/mqt-core/boost/cxx11_char_types.hpp +70 -0
- mqt/core/include/mqt-core/boost/detail/workaround.hpp +10 -0
- mqt/core/include/mqt-core/boost/limits.hpp +146 -0
- mqt/core/include/mqt-core/boost/multiprecision/complex128.hpp +24 -0
- mqt/core/include/mqt-core/boost/multiprecision/complex_adaptor.hpp +1046 -0
- mqt/core/include/mqt-core/boost/multiprecision/concepts/mp_number_archetypes.hpp +257 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/io.hpp +698 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/transcendental.hpp +157 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float.hpp +2297 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_complex.hpp +12 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_dec_float.hpp +3690 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add.hpp +368 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add_unsigned.hpp +387 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/bitwise.hpp +889 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/checked.hpp +178 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/comparison.hpp +374 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/cpp_int_config.hpp +161 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/divide.hpp +703 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/import_export.hpp +248 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/intel_intrinsics.hpp +138 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/limits.hpp +282 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/literals.hpp +295 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/misc.hpp +1457 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/multiply.hpp +848 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/serialize.hpp +211 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/value_pack.hpp +42 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int.hpp +2360 -0
- mqt/core/include/mqt-core/boost/multiprecision/debug_adaptor.hpp +760 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/assert.hpp +29 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/atomic.hpp +62 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/bitscan.hpp +317 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/check_cpp11_config.hpp +64 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/constexpr.hpp +88 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/default_ops.hpp +4052 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/digits.hpp +49 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/dynamic_array.hpp +44 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/empty_value.hpp +87 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/endian.hpp +35 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/et_ops.hpp +1831 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/float128_functions.hpp +95 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/float_string_cvt.hpp +333 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/fpclassify.hpp +101 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/constants.hpp +288 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/pow.hpp +905 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trig.hpp +1058 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trunc.hpp +82 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/generic_interconvert.hpp +687 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/hash.hpp +56 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/integer_ops.hpp +474 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/itos.hpp +39 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/min_max.hpp +106 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/no_et_ops.hpp +661 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/no_exceptions_support.hpp +55 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/number_base.hpp +1656 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/number_compare.hpp +848 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/precision.hpp +313 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/rebind.hpp +19 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/standalone_config.hpp +148 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/static_array.hpp +42 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/string_helpers.hpp +48 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/tables.hpp +80 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/ublas_interop.hpp +75 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/uniform_int_distribution.hpp +212 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/utype_helper.hpp +374 -0
- mqt/core/include/mqt-core/boost/multiprecision/eigen.hpp +248 -0
- mqt/core/include/mqt-core/boost/multiprecision/float128.hpp +920 -0
- mqt/core/include/mqt-core/boost/multiprecision/fwd.hpp +268 -0
- mqt/core/include/mqt-core/boost/multiprecision/gmp.hpp +4060 -0
- mqt/core/include/mqt-core/boost/multiprecision/integer.hpp +363 -0
- mqt/core/include/mqt-core/boost/multiprecision/logged_adaptor.hpp +834 -0
- mqt/core/include/mqt-core/boost/multiprecision/miller_rabin.hpp +221 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpc.hpp +1721 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpfi.hpp +2559 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpfr.hpp +3644 -0
- mqt/core/include/mqt-core/boost/multiprecision/number.hpp +2500 -0
- mqt/core/include/mqt-core/boost/multiprecision/random.hpp +23 -0
- mqt/core/include/mqt-core/boost/multiprecision/rational_adaptor.hpp +1289 -0
- mqt/core/include/mqt-core/boost/multiprecision/tommath.hpp +1034 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/explicit_conversion.hpp +67 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/extract_exponent_type.hpp +28 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_backend.hpp +91 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_byte_container.hpp +51 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_complex.hpp +22 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_convertible_arithmetic.hpp +51 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_restricted_conversion.hpp +47 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_variable_precision.hpp +25 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/max_digits10.hpp +79 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/std_integer_traits.hpp +90 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/transcendental_reduction_type.hpp +21 -0
- mqt/core/include/mqt-core/boost/version.hpp +32 -0
- mqt/core/include/mqt-core/circuit_optimizer/CircuitOptimizer.hpp +119 -0
- mqt/core/include/mqt-core/circuit_optimizer/mqt_core_circuit_optimizer_export.h +43 -0
- mqt/core/include/mqt-core/datastructures/DirectedAcyclicGraph.hpp +117 -0
- mqt/core/include/mqt-core/datastructures/DirectedGraph.hpp +158 -0
- mqt/core/include/mqt-core/datastructures/DisjointSet.hpp +50 -0
- mqt/core/include/mqt-core/datastructures/Layer.hpp +172 -0
- mqt/core/include/mqt-core/datastructures/SymmetricMatrix.hpp +57 -0
- mqt/core/include/mqt-core/datastructures/UndirectedGraph.hpp +227 -0
- mqt/core/include/mqt-core/datastructures/mqt_core_ds_export.h +43 -0
- mqt/core/include/mqt-core/dd/Approximation.hpp +45 -0
- mqt/core/include/mqt-core/dd/CachedEdge.hpp +174 -0
- mqt/core/include/mqt-core/dd/Complex.hpp +165 -0
- mqt/core/include/mqt-core/dd/ComplexNumbers.hpp +150 -0
- mqt/core/include/mqt-core/dd/ComplexValue.hpp +184 -0
- mqt/core/include/mqt-core/dd/ComputeTable.hpp +183 -0
- mqt/core/include/mqt-core/dd/DDDefinitions.hpp +139 -0
- mqt/core/include/mqt-core/dd/DDpackageConfig.hpp +104 -0
- mqt/core/include/mqt-core/dd/DensityNoiseTable.hpp +114 -0
- mqt/core/include/mqt-core/dd/Edge.hpp +416 -0
- mqt/core/include/mqt-core/dd/Export.hpp +438 -0
- mqt/core/include/mqt-core/dd/FunctionalityConstruction.hpp +75 -0
- mqt/core/include/mqt-core/dd/GateMatrixDefinitions.hpp +43 -0
- mqt/core/include/mqt-core/dd/LinkedListBase.hpp +45 -0
- mqt/core/include/mqt-core/dd/MemoryManager.hpp +193 -0
- mqt/core/include/mqt-core/dd/Node.hpp +223 -0
- mqt/core/include/mqt-core/dd/NoiseFunctionality.hpp +144 -0
- mqt/core/include/mqt-core/dd/Operations.hpp +306 -0
- mqt/core/include/mqt-core/dd/Package.hpp +2036 -0
- mqt/core/include/mqt-core/dd/Package_fwd.hpp +22 -0
- mqt/core/include/mqt-core/dd/RealNumber.hpp +255 -0
- mqt/core/include/mqt-core/dd/RealNumberUniqueTable.hpp +217 -0
- mqt/core/include/mqt-core/dd/Simulation.hpp +98 -0
- mqt/core/include/mqt-core/dd/StateGeneration.hpp +143 -0
- mqt/core/include/mqt-core/dd/StochasticNoiseOperationTable.hpp +88 -0
- mqt/core/include/mqt-core/dd/UnaryComputeTable.hpp +121 -0
- mqt/core/include/mqt-core/dd/UniqueTable.hpp +243 -0
- mqt/core/include/mqt-core/dd/mqt_core_dd_export.h +43 -0
- mqt/core/include/mqt-core/dd/statistics/MemoryManagerStatistics.hpp +84 -0
- mqt/core/include/mqt-core/dd/statistics/PackageStatistics.hpp +55 -0
- mqt/core/include/mqt-core/dd/statistics/Statistics.hpp +48 -0
- mqt/core/include/mqt-core/dd/statistics/TableStatistics.hpp +79 -0
- mqt/core/include/mqt-core/dd/statistics/UniqueTableStatistics.hpp +31 -0
- mqt/core/include/mqt-core/fomac/FoMaC.hpp +568 -0
- mqt/core/include/mqt-core/ir/Definitions.hpp +108 -0
- mqt/core/include/mqt-core/ir/Permutation.hpp +213 -0
- mqt/core/include/mqt-core/ir/QuantumComputation.hpp +596 -0
- mqt/core/include/mqt-core/ir/Register.hpp +125 -0
- mqt/core/include/mqt-core/ir/mqt_core_ir_export.h +43 -0
- mqt/core/include/mqt-core/ir/operations/AodOperation.hpp +92 -0
- mqt/core/include/mqt-core/ir/operations/CompoundOperation.hpp +212 -0
- mqt/core/include/mqt-core/ir/operations/Control.hpp +142 -0
- mqt/core/include/mqt-core/ir/operations/Expression.hpp +847 -0
- mqt/core/include/mqt-core/ir/operations/IfElseOperation.hpp +169 -0
- mqt/core/include/mqt-core/ir/operations/NonUnitaryOperation.hpp +118 -0
- mqt/core/include/mqt-core/ir/operations/OpType.hpp +120 -0
- mqt/core/include/mqt-core/ir/operations/OpType.inc +76 -0
- mqt/core/include/mqt-core/ir/operations/Operation.hpp +247 -0
- mqt/core/include/mqt-core/ir/operations/StandardOperation.hpp +140 -0
- mqt/core/include/mqt-core/ir/operations/SymbolicOperation.hpp +144 -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/NAComputation.hpp +185 -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/entities/Atom.hpp +62 -0
- mqt/core/include/mqt-core/na/entities/Location.hpp +154 -0
- mqt/core/include/mqt-core/na/entities/Zone.hpp +95 -0
- mqt/core/include/mqt-core/na/fomac/Device.hpp +169 -0
- mqt/core/include/mqt-core/na/mqt_core_na_export.h +43 -0
- mqt/core/include/mqt-core/na/operations/GlobalCZOp.hpp +38 -0
- mqt/core/include/mqt-core/na/operations/GlobalOp.hpp +58 -0
- mqt/core/include/mqt-core/na/operations/GlobalRYOp.hpp +42 -0
- mqt/core/include/mqt-core/na/operations/LoadOp.hpp +89 -0
- mqt/core/include/mqt-core/na/operations/LocalOp.hpp +56 -0
- mqt/core/include/mqt-core/na/operations/LocalRZOp.hpp +42 -0
- mqt/core/include/mqt-core/na/operations/LocalUOp.hpp +49 -0
- mqt/core/include/mqt-core/na/operations/MoveOp.hpp +66 -0
- mqt/core/include/mqt-core/na/operations/Op.hpp +62 -0
- mqt/core/include/mqt-core/na/operations/ShuttlingOp.hpp +51 -0
- mqt/core/include/mqt-core/na/operations/StoreOp.hpp +87 -0
- mqt/core/include/mqt-core/qasm3/Exception.hpp +85 -0
- mqt/core/include/mqt-core/qasm3/Gate.hpp +65 -0
- mqt/core/include/mqt-core/qasm3/Importer.hpp +192 -0
- mqt/core/include/mqt-core/qasm3/InstVisitor.hpp +145 -0
- mqt/core/include/mqt-core/qasm3/NestedEnvironment.hpp +41 -0
- mqt/core/include/mqt-core/qasm3/Parser.hpp +170 -0
- mqt/core/include/mqt-core/qasm3/Scanner.hpp +73 -0
- mqt/core/include/mqt-core/qasm3/Statement.hpp +486 -0
- mqt/core/include/mqt-core/qasm3/Statement_fwd.hpp +39 -0
- mqt/core/include/mqt-core/qasm3/StdGates.hpp +232 -0
- mqt/core/include/mqt-core/qasm3/Token.hpp +198 -0
- mqt/core/include/mqt-core/qasm3/Types.hpp +238 -0
- mqt/core/include/mqt-core/qasm3/Types_fwd.hpp +22 -0
- mqt/core/include/mqt-core/qasm3/mqt_core_qasm_export.h +43 -0
- mqt/core/include/mqt-core/qasm3/passes/CompilerPass.hpp +22 -0
- mqt/core/include/mqt-core/qasm3/passes/ConstEvalPass.hpp +102 -0
- mqt/core/include/mqt-core/qasm3/passes/TypeCheckPass.hpp +124 -0
- mqt/core/include/mqt-core/qdmi/Driver.hpp +431 -0
- mqt/core/include/mqt-core/zx/FunctionalityConstruction.hpp +125 -0
- mqt/core/include/mqt-core/zx/Rational.hpp +318 -0
- mqt/core/include/mqt-core/zx/Rules.hpp +132 -0
- mqt/core/include/mqt-core/zx/Simplify.hpp +182 -0
- mqt/core/include/mqt-core/zx/Utils.hpp +212 -0
- mqt/core/include/mqt-core/zx/ZXDefinitions.hpp +93 -0
- mqt/core/include/mqt-core/zx/ZXDiagram.hpp +480 -0
- mqt/core/include/mqt-core/zx/mqt_core_zx_export.h +43 -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 +2078 -0
- mqt/core/ir/operations.pyi +1011 -0
- mqt/core/ir/registers.pyi +91 -0
- mqt/core/ir/symbolic.pyi +177 -0
- mqt/core/ir.cpython-314t-darwin.so +0 -0
- mqt/core/lib/libmqt-core-algorithms.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-algorithms.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-algorithms.dylib +0 -0
- mqt/core/lib/libmqt-core-circuit-optimizer.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-circuit-optimizer.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-circuit-optimizer.dylib +0 -0
- mqt/core/lib/libmqt-core-dd.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-dd.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-dd.dylib +0 -0
- mqt/core/lib/libmqt-core-ds.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-ds.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-ds.dylib +0 -0
- mqt/core/lib/libmqt-core-fomac.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-fomac.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-fomac.dylib +0 -0
- mqt/core/lib/libmqt-core-ir.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-ir.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-ir.dylib +0 -0
- mqt/core/lib/libmqt-core-na-fomac.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-na-fomac.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-na-fomac.dylib +0 -0
- mqt/core/lib/libmqt-core-na.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-na.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-na.dylib +0 -0
- mqt/core/lib/libmqt-core-qasm.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-qasm.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-qasm.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-driver.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-driver.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-driver.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-na-device-gen.a +0 -0
- mqt/core/lib/libmqt-core-qdmi-na-device.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-na-device.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-qdmi-na-device.dylib +0 -0
- mqt/core/lib/libmqt-core-zx.3.3.2.dylib +0 -0
- mqt/core/lib/libmqt-core-zx.3.3.dylib +0 -0
- mqt/core/lib/libmqt-core-zx.dylib +0 -0
- mqt/core/lib/libspdlog.a +0 -0
- mqt/core/lib/pkgconfig/spdlog.pc +13 -0
- mqt/core/na/__init__.py +12 -0
- mqt/core/na/fomac.cpython-314t-darwin.so +0 -0
- mqt/core/na/fomac.pyi +117 -0
- mqt/core/plugins/__init__.py +9 -0
- mqt/core/plugins/qiskit/__init__.py +19 -0
- mqt/core/plugins/qiskit/mqt_to_qiskit.py +420 -0
- mqt/core/plugins/qiskit/qiskit_to_mqt.py +562 -0
- mqt/core/py.typed +2 -0
- mqt/core/share/cmake/mqt-core/AddMQTPythonBinding.cmake +55 -0
- mqt/core/share/cmake/mqt-core/Cache.cmake +33 -0
- mqt/core/share/cmake/mqt-core/FindGMP.cmake +103 -0
- mqt/core/share/cmake/mqt-core/PackageAddTest.cmake +46 -0
- mqt/core/share/cmake/mqt-core/PreventInSourceBuilds.cmake +25 -0
- mqt/core/share/cmake/mqt-core/StandardProjectSettings.cmake +87 -0
- mqt/core/share/cmake/mqt-core/mqt-core-config-version.cmake +85 -0
- mqt/core/share/cmake/mqt-core/mqt-core-config.cmake +52 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets-release.cmake +141 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets.cmake +446 -0
- 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 +109 -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 +118 -0
- mqt/core/share/cmake/spdlog/spdlogConfigVersion.cmake +65 -0
- mqt/core/share/pkgconfig/nlohmann_json.pc +7 -0
- mqt_core-3.3.2.dist-info/METADATA +210 -0
- mqt_core-3.3.2.dist-info/RECORD +546 -0
- mqt_core-3.3.2.dist-info/WHEEL +6 -0
- mqt_core-3.3.2.dist-info/entry_points.txt +4 -0
- mqt_core-3.3.2.dist-info/licenses/LICENSE.md +22 -0
|
@@ -0,0 +1,1340 @@
|
|
|
1
|
+
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
|
2
|
+
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#ifndef SPDLOG_HEADER_ONLY
|
|
7
|
+
#include <spdlog/pattern_formatter.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include <spdlog/details/fmt_helper.h>
|
|
11
|
+
#include <spdlog/details/log_msg.h>
|
|
12
|
+
#include <spdlog/details/os.h>
|
|
13
|
+
|
|
14
|
+
#ifndef SPDLOG_NO_TLS
|
|
15
|
+
#include <spdlog/mdc.h>
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#include <spdlog/fmt/fmt.h>
|
|
19
|
+
#include <spdlog/formatter.h>
|
|
20
|
+
|
|
21
|
+
#include <algorithm>
|
|
22
|
+
#include <array>
|
|
23
|
+
#include <cctype>
|
|
24
|
+
#include <chrono>
|
|
25
|
+
#include <cstring>
|
|
26
|
+
#include <ctime>
|
|
27
|
+
#include <iterator>
|
|
28
|
+
#include <memory>
|
|
29
|
+
#include <mutex>
|
|
30
|
+
#include <string>
|
|
31
|
+
#include <thread>
|
|
32
|
+
#include <utility>
|
|
33
|
+
#include <vector>
|
|
34
|
+
|
|
35
|
+
namespace spdlog {
|
|
36
|
+
namespace details {
|
|
37
|
+
|
|
38
|
+
///////////////////////////////////////////////////////////////////////
|
|
39
|
+
// name & level pattern appender
|
|
40
|
+
///////////////////////////////////////////////////////////////////////
|
|
41
|
+
|
|
42
|
+
class scoped_padder {
|
|
43
|
+
public:
|
|
44
|
+
scoped_padder(size_t wrapped_size, const padding_info &padinfo, memory_buf_t &dest)
|
|
45
|
+
: padinfo_(padinfo),
|
|
46
|
+
dest_(dest) {
|
|
47
|
+
remaining_pad_ = static_cast<long>(padinfo.width_) - static_cast<long>(wrapped_size);
|
|
48
|
+
if (remaining_pad_ <= 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (padinfo_.side_ == padding_info::pad_side::left) {
|
|
53
|
+
pad_it(remaining_pad_);
|
|
54
|
+
remaining_pad_ = 0;
|
|
55
|
+
} else if (padinfo_.side_ == padding_info::pad_side::center) {
|
|
56
|
+
auto half_pad = remaining_pad_ / 2;
|
|
57
|
+
auto reminder = remaining_pad_ & 1;
|
|
58
|
+
pad_it(half_pad);
|
|
59
|
+
remaining_pad_ = half_pad + reminder; // for the right side
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
template <typename T>
|
|
64
|
+
static unsigned int count_digits(T n) {
|
|
65
|
+
return fmt_helper::count_digits(n);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
~scoped_padder() {
|
|
69
|
+
if (remaining_pad_ >= 0) {
|
|
70
|
+
pad_it(remaining_pad_);
|
|
71
|
+
} else if (padinfo_.truncate_) {
|
|
72
|
+
long new_size = static_cast<long>(dest_.size()) + remaining_pad_;
|
|
73
|
+
if (new_size < 0) {
|
|
74
|
+
new_size = 0;
|
|
75
|
+
}
|
|
76
|
+
dest_.resize(static_cast<size_t>(new_size));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
void pad_it(long count) {
|
|
82
|
+
fmt_helper::append_string_view(string_view_t(spaces_.data(), static_cast<size_t>(count)),
|
|
83
|
+
dest_);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const padding_info &padinfo_;
|
|
87
|
+
memory_buf_t &dest_;
|
|
88
|
+
long remaining_pad_;
|
|
89
|
+
string_view_t spaces_{" ", 64};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
struct null_scoped_padder {
|
|
93
|
+
null_scoped_padder(size_t /*wrapped_size*/,
|
|
94
|
+
const padding_info & /*padinfo*/,
|
|
95
|
+
memory_buf_t & /*dest*/) {}
|
|
96
|
+
|
|
97
|
+
template <typename T>
|
|
98
|
+
static unsigned int count_digits(T /* number */) {
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
template <typename ScopedPadder>
|
|
104
|
+
class name_formatter final : public flag_formatter {
|
|
105
|
+
public:
|
|
106
|
+
explicit name_formatter(padding_info padinfo)
|
|
107
|
+
: flag_formatter(padinfo) {}
|
|
108
|
+
|
|
109
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
110
|
+
ScopedPadder p(msg.logger_name.size(), padinfo_, dest);
|
|
111
|
+
fmt_helper::append_string_view(msg.logger_name, dest);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// log level appender
|
|
116
|
+
template <typename ScopedPadder>
|
|
117
|
+
class level_formatter final : public flag_formatter {
|
|
118
|
+
public:
|
|
119
|
+
explicit level_formatter(padding_info padinfo)
|
|
120
|
+
: flag_formatter(padinfo) {}
|
|
121
|
+
|
|
122
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
123
|
+
const string_view_t &level_name = level::to_string_view(msg.level);
|
|
124
|
+
ScopedPadder p(level_name.size(), padinfo_, dest);
|
|
125
|
+
fmt_helper::append_string_view(level_name, dest);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// short log level appender
|
|
130
|
+
template <typename ScopedPadder>
|
|
131
|
+
class short_level_formatter final : public flag_formatter {
|
|
132
|
+
public:
|
|
133
|
+
explicit short_level_formatter(padding_info padinfo)
|
|
134
|
+
: flag_formatter(padinfo) {}
|
|
135
|
+
|
|
136
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
137
|
+
string_view_t level_name{level::to_short_c_str(msg.level)};
|
|
138
|
+
ScopedPadder p(level_name.size(), padinfo_, dest);
|
|
139
|
+
fmt_helper::append_string_view(level_name, dest);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
///////////////////////////////////////////////////////////////////////
|
|
144
|
+
// Date time pattern appenders
|
|
145
|
+
///////////////////////////////////////////////////////////////////////
|
|
146
|
+
|
|
147
|
+
static const char *ampm(const tm &t) { return t.tm_hour >= 12 ? "PM" : "AM"; }
|
|
148
|
+
|
|
149
|
+
static int to12h(const tm &t) { return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour; }
|
|
150
|
+
|
|
151
|
+
// Abbreviated weekday name
|
|
152
|
+
static std::array<const char *, 7> days{{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}};
|
|
153
|
+
|
|
154
|
+
template <typename ScopedPadder>
|
|
155
|
+
class a_formatter final : public flag_formatter {
|
|
156
|
+
public:
|
|
157
|
+
explicit a_formatter(padding_info padinfo)
|
|
158
|
+
: flag_formatter(padinfo) {}
|
|
159
|
+
|
|
160
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
161
|
+
string_view_t field_value{days[static_cast<size_t>(tm_time.tm_wday)]};
|
|
162
|
+
ScopedPadder p(field_value.size(), padinfo_, dest);
|
|
163
|
+
fmt_helper::append_string_view(field_value, dest);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Full weekday name
|
|
168
|
+
static std::array<const char *, 7> full_days{
|
|
169
|
+
{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}};
|
|
170
|
+
|
|
171
|
+
template <typename ScopedPadder>
|
|
172
|
+
class A_formatter : public flag_formatter {
|
|
173
|
+
public:
|
|
174
|
+
explicit A_formatter(padding_info padinfo)
|
|
175
|
+
: flag_formatter(padinfo) {}
|
|
176
|
+
|
|
177
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
178
|
+
string_view_t field_value{full_days[static_cast<size_t>(tm_time.tm_wday)]};
|
|
179
|
+
ScopedPadder p(field_value.size(), padinfo_, dest);
|
|
180
|
+
fmt_helper::append_string_view(field_value, dest);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Abbreviated month
|
|
185
|
+
static const std::array<const char *, 12> months{
|
|
186
|
+
{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}};
|
|
187
|
+
|
|
188
|
+
template <typename ScopedPadder>
|
|
189
|
+
class b_formatter final : public flag_formatter {
|
|
190
|
+
public:
|
|
191
|
+
explicit b_formatter(padding_info padinfo)
|
|
192
|
+
: flag_formatter(padinfo) {}
|
|
193
|
+
|
|
194
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
195
|
+
string_view_t field_value{months[static_cast<size_t>(tm_time.tm_mon)]};
|
|
196
|
+
ScopedPadder p(field_value.size(), padinfo_, dest);
|
|
197
|
+
fmt_helper::append_string_view(field_value, dest);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Full month name
|
|
202
|
+
static const std::array<const char *, 12> full_months{{"January", "February", "March", "April",
|
|
203
|
+
"May", "June", "July", "August", "September",
|
|
204
|
+
"October", "November", "December"}};
|
|
205
|
+
|
|
206
|
+
template <typename ScopedPadder>
|
|
207
|
+
class B_formatter final : public flag_formatter {
|
|
208
|
+
public:
|
|
209
|
+
explicit B_formatter(padding_info padinfo)
|
|
210
|
+
: flag_formatter(padinfo) {}
|
|
211
|
+
|
|
212
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
213
|
+
string_view_t field_value{full_months[static_cast<size_t>(tm_time.tm_mon)]};
|
|
214
|
+
ScopedPadder p(field_value.size(), padinfo_, dest);
|
|
215
|
+
fmt_helper::append_string_view(field_value, dest);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Date and time representation (Thu Aug 23 15:35:46 2014)
|
|
220
|
+
template <typename ScopedPadder>
|
|
221
|
+
class c_formatter final : public flag_formatter {
|
|
222
|
+
public:
|
|
223
|
+
explicit c_formatter(padding_info padinfo)
|
|
224
|
+
: flag_formatter(padinfo) {}
|
|
225
|
+
|
|
226
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
227
|
+
const size_t field_size = 24;
|
|
228
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
229
|
+
|
|
230
|
+
fmt_helper::append_string_view(days[static_cast<size_t>(tm_time.tm_wday)], dest);
|
|
231
|
+
dest.push_back(' ');
|
|
232
|
+
fmt_helper::append_string_view(months[static_cast<size_t>(tm_time.tm_mon)], dest);
|
|
233
|
+
dest.push_back(' ');
|
|
234
|
+
fmt_helper::append_int(tm_time.tm_mday, dest);
|
|
235
|
+
dest.push_back(' ');
|
|
236
|
+
// time
|
|
237
|
+
|
|
238
|
+
fmt_helper::pad2(tm_time.tm_hour, dest);
|
|
239
|
+
dest.push_back(':');
|
|
240
|
+
fmt_helper::pad2(tm_time.tm_min, dest);
|
|
241
|
+
dest.push_back(':');
|
|
242
|
+
fmt_helper::pad2(tm_time.tm_sec, dest);
|
|
243
|
+
dest.push_back(' ');
|
|
244
|
+
fmt_helper::append_int(tm_time.tm_year + 1900, dest);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// year - 2 digit
|
|
249
|
+
template <typename ScopedPadder>
|
|
250
|
+
class C_formatter final : public flag_formatter {
|
|
251
|
+
public:
|
|
252
|
+
explicit C_formatter(padding_info padinfo)
|
|
253
|
+
: flag_formatter(padinfo) {}
|
|
254
|
+
|
|
255
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
256
|
+
const size_t field_size = 2;
|
|
257
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
258
|
+
fmt_helper::pad2(tm_time.tm_year % 100, dest);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01
|
|
263
|
+
template <typename ScopedPadder>
|
|
264
|
+
class D_formatter final : public flag_formatter {
|
|
265
|
+
public:
|
|
266
|
+
explicit D_formatter(padding_info padinfo)
|
|
267
|
+
: flag_formatter(padinfo) {}
|
|
268
|
+
|
|
269
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
270
|
+
const size_t field_size = 8;
|
|
271
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
272
|
+
|
|
273
|
+
fmt_helper::pad2(tm_time.tm_mon + 1, dest);
|
|
274
|
+
dest.push_back('/');
|
|
275
|
+
fmt_helper::pad2(tm_time.tm_mday, dest);
|
|
276
|
+
dest.push_back('/');
|
|
277
|
+
fmt_helper::pad2(tm_time.tm_year % 100, dest);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// year - 4 digit
|
|
282
|
+
template <typename ScopedPadder>
|
|
283
|
+
class Y_formatter final : public flag_formatter {
|
|
284
|
+
public:
|
|
285
|
+
explicit Y_formatter(padding_info padinfo)
|
|
286
|
+
: flag_formatter(padinfo) {}
|
|
287
|
+
|
|
288
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
289
|
+
const size_t field_size = 4;
|
|
290
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
291
|
+
fmt_helper::append_int(tm_time.tm_year + 1900, dest);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// month 1-12
|
|
296
|
+
template <typename ScopedPadder>
|
|
297
|
+
class m_formatter final : public flag_formatter {
|
|
298
|
+
public:
|
|
299
|
+
explicit m_formatter(padding_info padinfo)
|
|
300
|
+
: flag_formatter(padinfo) {}
|
|
301
|
+
|
|
302
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
303
|
+
const size_t field_size = 2;
|
|
304
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
305
|
+
fmt_helper::pad2(tm_time.tm_mon + 1, dest);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// day of month 1-31
|
|
310
|
+
template <typename ScopedPadder>
|
|
311
|
+
class d_formatter final : public flag_formatter {
|
|
312
|
+
public:
|
|
313
|
+
explicit d_formatter(padding_info padinfo)
|
|
314
|
+
: flag_formatter(padinfo) {}
|
|
315
|
+
|
|
316
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
317
|
+
const size_t field_size = 2;
|
|
318
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
319
|
+
fmt_helper::pad2(tm_time.tm_mday, dest);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// hours in 24 format 0-23
|
|
324
|
+
template <typename ScopedPadder>
|
|
325
|
+
class H_formatter final : public flag_formatter {
|
|
326
|
+
public:
|
|
327
|
+
explicit H_formatter(padding_info padinfo)
|
|
328
|
+
: flag_formatter(padinfo) {}
|
|
329
|
+
|
|
330
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
331
|
+
const size_t field_size = 2;
|
|
332
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
333
|
+
fmt_helper::pad2(tm_time.tm_hour, dest);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// hours in 12 format 1-12
|
|
338
|
+
template <typename ScopedPadder>
|
|
339
|
+
class I_formatter final : public flag_formatter {
|
|
340
|
+
public:
|
|
341
|
+
explicit I_formatter(padding_info padinfo)
|
|
342
|
+
: flag_formatter(padinfo) {}
|
|
343
|
+
|
|
344
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
345
|
+
const size_t field_size = 2;
|
|
346
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
347
|
+
fmt_helper::pad2(to12h(tm_time), dest);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// minutes 0-59
|
|
352
|
+
template <typename ScopedPadder>
|
|
353
|
+
class M_formatter final : public flag_formatter {
|
|
354
|
+
public:
|
|
355
|
+
explicit M_formatter(padding_info padinfo)
|
|
356
|
+
: flag_formatter(padinfo) {}
|
|
357
|
+
|
|
358
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
359
|
+
const size_t field_size = 2;
|
|
360
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
361
|
+
fmt_helper::pad2(tm_time.tm_min, dest);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// seconds 0-59
|
|
366
|
+
template <typename ScopedPadder>
|
|
367
|
+
class S_formatter final : public flag_formatter {
|
|
368
|
+
public:
|
|
369
|
+
explicit S_formatter(padding_info padinfo)
|
|
370
|
+
: flag_formatter(padinfo) {}
|
|
371
|
+
|
|
372
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
373
|
+
const size_t field_size = 2;
|
|
374
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
375
|
+
fmt_helper::pad2(tm_time.tm_sec, dest);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// milliseconds
|
|
380
|
+
template <typename ScopedPadder>
|
|
381
|
+
class e_formatter final : public flag_formatter {
|
|
382
|
+
public:
|
|
383
|
+
explicit e_formatter(padding_info padinfo)
|
|
384
|
+
: flag_formatter(padinfo) {}
|
|
385
|
+
|
|
386
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
387
|
+
auto millis = fmt_helper::time_fraction<std::chrono::milliseconds>(msg.time);
|
|
388
|
+
const size_t field_size = 3;
|
|
389
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
390
|
+
fmt_helper::pad3(static_cast<uint32_t>(millis.count()), dest);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// microseconds
|
|
395
|
+
template <typename ScopedPadder>
|
|
396
|
+
class f_formatter final : public flag_formatter {
|
|
397
|
+
public:
|
|
398
|
+
explicit f_formatter(padding_info padinfo)
|
|
399
|
+
: flag_formatter(padinfo) {}
|
|
400
|
+
|
|
401
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
402
|
+
auto micros = fmt_helper::time_fraction<std::chrono::microseconds>(msg.time);
|
|
403
|
+
|
|
404
|
+
const size_t field_size = 6;
|
|
405
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
406
|
+
fmt_helper::pad6(static_cast<size_t>(micros.count()), dest);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// nanoseconds
|
|
411
|
+
template <typename ScopedPadder>
|
|
412
|
+
class F_formatter final : public flag_formatter {
|
|
413
|
+
public:
|
|
414
|
+
explicit F_formatter(padding_info padinfo)
|
|
415
|
+
: flag_formatter(padinfo) {}
|
|
416
|
+
|
|
417
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
418
|
+
auto ns = fmt_helper::time_fraction<std::chrono::nanoseconds>(msg.time);
|
|
419
|
+
const size_t field_size = 9;
|
|
420
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
421
|
+
fmt_helper::pad9(static_cast<size_t>(ns.count()), dest);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// seconds since epoch
|
|
426
|
+
template <typename ScopedPadder>
|
|
427
|
+
class E_formatter final : public flag_formatter {
|
|
428
|
+
public:
|
|
429
|
+
explicit E_formatter(padding_info padinfo)
|
|
430
|
+
: flag_formatter(padinfo) {}
|
|
431
|
+
|
|
432
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
433
|
+
const size_t field_size = 10;
|
|
434
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
435
|
+
auto duration = msg.time.time_since_epoch();
|
|
436
|
+
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
|
437
|
+
fmt_helper::append_int(seconds, dest);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
// AM/PM
|
|
442
|
+
template <typename ScopedPadder>
|
|
443
|
+
class p_formatter final : public flag_formatter {
|
|
444
|
+
public:
|
|
445
|
+
explicit p_formatter(padding_info padinfo)
|
|
446
|
+
: flag_formatter(padinfo) {}
|
|
447
|
+
|
|
448
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
449
|
+
const size_t field_size = 2;
|
|
450
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
451
|
+
fmt_helper::append_string_view(ampm(tm_time), dest);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// 12 hour clock 02:55:02 pm
|
|
456
|
+
template <typename ScopedPadder>
|
|
457
|
+
class r_formatter final : public flag_formatter {
|
|
458
|
+
public:
|
|
459
|
+
explicit r_formatter(padding_info padinfo)
|
|
460
|
+
: flag_formatter(padinfo) {}
|
|
461
|
+
|
|
462
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
463
|
+
const size_t field_size = 11;
|
|
464
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
465
|
+
|
|
466
|
+
fmt_helper::pad2(to12h(tm_time), dest);
|
|
467
|
+
dest.push_back(':');
|
|
468
|
+
fmt_helper::pad2(tm_time.tm_min, dest);
|
|
469
|
+
dest.push_back(':');
|
|
470
|
+
fmt_helper::pad2(tm_time.tm_sec, dest);
|
|
471
|
+
dest.push_back(' ');
|
|
472
|
+
fmt_helper::append_string_view(ampm(tm_time), dest);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// 24-hour HH:MM time, equivalent to %H:%M
|
|
477
|
+
template <typename ScopedPadder>
|
|
478
|
+
class R_formatter final : public flag_formatter {
|
|
479
|
+
public:
|
|
480
|
+
explicit R_formatter(padding_info padinfo)
|
|
481
|
+
: flag_formatter(padinfo) {}
|
|
482
|
+
|
|
483
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
484
|
+
const size_t field_size = 5;
|
|
485
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
486
|
+
|
|
487
|
+
fmt_helper::pad2(tm_time.tm_hour, dest);
|
|
488
|
+
dest.push_back(':');
|
|
489
|
+
fmt_helper::pad2(tm_time.tm_min, dest);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
|
|
494
|
+
template <typename ScopedPadder>
|
|
495
|
+
class T_formatter final : public flag_formatter {
|
|
496
|
+
public:
|
|
497
|
+
explicit T_formatter(padding_info padinfo)
|
|
498
|
+
: flag_formatter(padinfo) {}
|
|
499
|
+
|
|
500
|
+
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
501
|
+
const size_t field_size = 8;
|
|
502
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
503
|
+
|
|
504
|
+
fmt_helper::pad2(tm_time.tm_hour, dest);
|
|
505
|
+
dest.push_back(':');
|
|
506
|
+
fmt_helper::pad2(tm_time.tm_min, dest);
|
|
507
|
+
dest.push_back(':');
|
|
508
|
+
fmt_helper::pad2(tm_time.tm_sec, dest);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
// ISO 8601 offset from UTC in timezone (+-HH:MM)
|
|
513
|
+
template <typename ScopedPadder>
|
|
514
|
+
class z_formatter final : public flag_formatter {
|
|
515
|
+
public:
|
|
516
|
+
explicit z_formatter(padding_info padinfo)
|
|
517
|
+
: flag_formatter(padinfo) {}
|
|
518
|
+
|
|
519
|
+
z_formatter() = default;
|
|
520
|
+
z_formatter(const z_formatter &) = delete;
|
|
521
|
+
z_formatter &operator=(const z_formatter &) = delete;
|
|
522
|
+
|
|
523
|
+
void format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
524
|
+
const size_t field_size = 6;
|
|
525
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
526
|
+
|
|
527
|
+
auto total_minutes = get_cached_offset(msg, tm_time);
|
|
528
|
+
bool is_negative = total_minutes < 0;
|
|
529
|
+
if (is_negative) {
|
|
530
|
+
total_minutes = -total_minutes;
|
|
531
|
+
dest.push_back('-');
|
|
532
|
+
} else {
|
|
533
|
+
dest.push_back('+');
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
fmt_helper::pad2(total_minutes / 60, dest); // hours
|
|
537
|
+
dest.push_back(':');
|
|
538
|
+
fmt_helper::pad2(total_minutes % 60, dest); // minutes
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
private:
|
|
542
|
+
log_clock::time_point last_update_{std::chrono::seconds(0)};
|
|
543
|
+
int offset_minutes_{0};
|
|
544
|
+
|
|
545
|
+
int get_cached_offset(const log_msg &msg, const std::tm &tm_time) {
|
|
546
|
+
// refresh every 10 seconds
|
|
547
|
+
if (msg.time - last_update_ >= std::chrono::seconds(10)) {
|
|
548
|
+
offset_minutes_ = os::utc_minutes_offset(tm_time);
|
|
549
|
+
last_update_ = msg.time;
|
|
550
|
+
}
|
|
551
|
+
return offset_minutes_;
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// Thread id
|
|
556
|
+
template <typename ScopedPadder>
|
|
557
|
+
class t_formatter final : public flag_formatter {
|
|
558
|
+
public:
|
|
559
|
+
explicit t_formatter(padding_info padinfo)
|
|
560
|
+
: flag_formatter(padinfo) {}
|
|
561
|
+
|
|
562
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
563
|
+
const auto field_size = ScopedPadder::count_digits(msg.thread_id);
|
|
564
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
565
|
+
fmt_helper::append_int(msg.thread_id, dest);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// Current pid
|
|
570
|
+
template <typename ScopedPadder>
|
|
571
|
+
class pid_formatter final : public flag_formatter {
|
|
572
|
+
public:
|
|
573
|
+
explicit pid_formatter(padding_info padinfo)
|
|
574
|
+
: flag_formatter(padinfo) {}
|
|
575
|
+
|
|
576
|
+
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override {
|
|
577
|
+
const auto pid = static_cast<uint32_t>(details::os::pid());
|
|
578
|
+
auto field_size = ScopedPadder::count_digits(pid);
|
|
579
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
580
|
+
fmt_helper::append_int(pid, dest);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
template <typename ScopedPadder>
|
|
585
|
+
class v_formatter final : public flag_formatter {
|
|
586
|
+
public:
|
|
587
|
+
explicit v_formatter(padding_info padinfo)
|
|
588
|
+
: flag_formatter(padinfo) {}
|
|
589
|
+
|
|
590
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
591
|
+
ScopedPadder p(msg.payload.size(), padinfo_, dest);
|
|
592
|
+
fmt_helper::append_string_view(msg.payload, dest);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
class ch_formatter final : public flag_formatter {
|
|
597
|
+
public:
|
|
598
|
+
explicit ch_formatter(char ch)
|
|
599
|
+
: ch_(ch) {}
|
|
600
|
+
|
|
601
|
+
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override {
|
|
602
|
+
dest.push_back(ch_);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
private:
|
|
606
|
+
char ch_;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// aggregate user chars to display as is
|
|
610
|
+
class aggregate_formatter final : public flag_formatter {
|
|
611
|
+
public:
|
|
612
|
+
aggregate_formatter() = default;
|
|
613
|
+
|
|
614
|
+
void add_ch(char ch) { str_ += ch; }
|
|
615
|
+
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override {
|
|
616
|
+
fmt_helper::append_string_view(str_, dest);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
private:
|
|
620
|
+
std::string str_;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// mark the color range. expect it to be in the form of "%^colored text%$"
|
|
624
|
+
class color_start_formatter final : public flag_formatter {
|
|
625
|
+
public:
|
|
626
|
+
explicit color_start_formatter(padding_info padinfo)
|
|
627
|
+
: flag_formatter(padinfo) {}
|
|
628
|
+
|
|
629
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
630
|
+
msg.color_range_start = dest.size();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
class color_stop_formatter final : public flag_formatter {
|
|
635
|
+
public:
|
|
636
|
+
explicit color_stop_formatter(padding_info padinfo)
|
|
637
|
+
: flag_formatter(padinfo) {}
|
|
638
|
+
|
|
639
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
640
|
+
msg.color_range_end = dest.size();
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// print source location
|
|
645
|
+
template <typename ScopedPadder>
|
|
646
|
+
class source_location_formatter final : public flag_formatter {
|
|
647
|
+
public:
|
|
648
|
+
explicit source_location_formatter(padding_info padinfo)
|
|
649
|
+
: flag_formatter(padinfo) {}
|
|
650
|
+
|
|
651
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
652
|
+
if (msg.source.empty()) {
|
|
653
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
size_t text_size;
|
|
658
|
+
if (padinfo_.enabled()) {
|
|
659
|
+
// calc text size for padding based on "filename:line"
|
|
660
|
+
text_size = std::char_traits<char>::length(msg.source.filename) +
|
|
661
|
+
ScopedPadder::count_digits(msg.source.line) + 1;
|
|
662
|
+
} else {
|
|
663
|
+
text_size = 0;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
ScopedPadder p(text_size, padinfo_, dest);
|
|
667
|
+
fmt_helper::append_string_view(msg.source.filename, dest);
|
|
668
|
+
dest.push_back(':');
|
|
669
|
+
fmt_helper::append_int(msg.source.line, dest);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
// print source filename
|
|
674
|
+
template <typename ScopedPadder>
|
|
675
|
+
class source_filename_formatter final : public flag_formatter {
|
|
676
|
+
public:
|
|
677
|
+
explicit source_filename_formatter(padding_info padinfo)
|
|
678
|
+
: flag_formatter(padinfo) {}
|
|
679
|
+
|
|
680
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
681
|
+
if (msg.source.empty()) {
|
|
682
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
size_t text_size =
|
|
686
|
+
padinfo_.enabled() ? std::char_traits<char>::length(msg.source.filename) : 0;
|
|
687
|
+
ScopedPadder p(text_size, padinfo_, dest);
|
|
688
|
+
fmt_helper::append_string_view(msg.source.filename, dest);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
template <typename ScopedPadder>
|
|
693
|
+
class short_filename_formatter final : public flag_formatter {
|
|
694
|
+
public:
|
|
695
|
+
explicit short_filename_formatter(padding_info padinfo)
|
|
696
|
+
: flag_formatter(padinfo) {}
|
|
697
|
+
|
|
698
|
+
#ifdef _MSC_VER
|
|
699
|
+
#pragma warning(push)
|
|
700
|
+
#pragma warning(disable : 4127) // consider using 'if constexpr' instead
|
|
701
|
+
#endif // _MSC_VER
|
|
702
|
+
static const char *basename(const char *filename) {
|
|
703
|
+
// if the size is 2 (1 character + null terminator) we can use the more efficient strrchr
|
|
704
|
+
// the branch will be elided by optimizations
|
|
705
|
+
if (sizeof(os::folder_seps) == 2) {
|
|
706
|
+
const char *rv = std::strrchr(filename, os::folder_seps[0]);
|
|
707
|
+
return rv != nullptr ? rv + 1 : filename;
|
|
708
|
+
} else {
|
|
709
|
+
const std::reverse_iterator<const char *> begin(filename + std::strlen(filename));
|
|
710
|
+
const std::reverse_iterator<const char *> end(filename);
|
|
711
|
+
|
|
712
|
+
const auto it = std::find_first_of(begin, end, std::begin(os::folder_seps),
|
|
713
|
+
std::end(os::folder_seps) - 1);
|
|
714
|
+
return it != end ? it.base() : filename;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
#ifdef _MSC_VER
|
|
718
|
+
#pragma warning(pop)
|
|
719
|
+
#endif // _MSC_VER
|
|
720
|
+
|
|
721
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
722
|
+
if (msg.source.empty()) {
|
|
723
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
auto filename = basename(msg.source.filename);
|
|
727
|
+
size_t text_size = padinfo_.enabled() ? std::char_traits<char>::length(filename) : 0;
|
|
728
|
+
ScopedPadder p(text_size, padinfo_, dest);
|
|
729
|
+
fmt_helper::append_string_view(filename, dest);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
template <typename ScopedPadder>
|
|
734
|
+
class source_linenum_formatter final : public flag_formatter {
|
|
735
|
+
public:
|
|
736
|
+
explicit source_linenum_formatter(padding_info padinfo)
|
|
737
|
+
: flag_formatter(padinfo) {}
|
|
738
|
+
|
|
739
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
740
|
+
if (msg.source.empty()) {
|
|
741
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
auto field_size = ScopedPadder::count_digits(msg.source.line);
|
|
746
|
+
ScopedPadder p(field_size, padinfo_, dest);
|
|
747
|
+
fmt_helper::append_int(msg.source.line, dest);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
// print source funcname
|
|
752
|
+
template <typename ScopedPadder>
|
|
753
|
+
class source_funcname_formatter final : public flag_formatter {
|
|
754
|
+
public:
|
|
755
|
+
explicit source_funcname_formatter(padding_info padinfo)
|
|
756
|
+
: flag_formatter(padinfo) {}
|
|
757
|
+
|
|
758
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
759
|
+
if (msg.source.empty()) {
|
|
760
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
size_t text_size =
|
|
764
|
+
padinfo_.enabled() ? std::char_traits<char>::length(msg.source.funcname) : 0;
|
|
765
|
+
ScopedPadder p(text_size, padinfo_, dest);
|
|
766
|
+
fmt_helper::append_string_view(msg.source.funcname, dest);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
// print elapsed time since last message
|
|
771
|
+
template <typename ScopedPadder, typename Units>
|
|
772
|
+
class elapsed_formatter final : public flag_formatter {
|
|
773
|
+
public:
|
|
774
|
+
using DurationUnits = Units;
|
|
775
|
+
|
|
776
|
+
explicit elapsed_formatter(padding_info padinfo)
|
|
777
|
+
: flag_formatter(padinfo),
|
|
778
|
+
last_message_time_(log_clock::now()) {}
|
|
779
|
+
|
|
780
|
+
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override {
|
|
781
|
+
auto delta = (std::max)(msg.time - last_message_time_, log_clock::duration::zero());
|
|
782
|
+
auto delta_units = std::chrono::duration_cast<DurationUnits>(delta);
|
|
783
|
+
last_message_time_ = msg.time;
|
|
784
|
+
auto delta_count = static_cast<size_t>(delta_units.count());
|
|
785
|
+
auto n_digits = static_cast<size_t>(ScopedPadder::count_digits(delta_count));
|
|
786
|
+
ScopedPadder p(n_digits, padinfo_, dest);
|
|
787
|
+
fmt_helper::append_int(delta_count, dest);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
private:
|
|
791
|
+
log_clock::time_point last_message_time_;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// Class for formatting Mapped Diagnostic Context (MDC) in log messages.
|
|
795
|
+
// Example: [logger-name] [info] [mdc_key_1:mdc_value_1 mdc_key_2:mdc_value_2] some message
|
|
796
|
+
#ifndef SPDLOG_NO_TLS
|
|
797
|
+
template <typename ScopedPadder>
|
|
798
|
+
class mdc_formatter : public flag_formatter {
|
|
799
|
+
public:
|
|
800
|
+
explicit mdc_formatter(padding_info padinfo)
|
|
801
|
+
: flag_formatter(padinfo) {}
|
|
802
|
+
|
|
803
|
+
void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override {
|
|
804
|
+
auto &mdc_map = mdc::get_context();
|
|
805
|
+
if (mdc_map.empty()) {
|
|
806
|
+
ScopedPadder p(0, padinfo_, dest);
|
|
807
|
+
return;
|
|
808
|
+
} else {
|
|
809
|
+
format_mdc(mdc_map, dest);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
void format_mdc(const mdc::mdc_map_t &mdc_map, memory_buf_t &dest) {
|
|
814
|
+
auto last_element = --mdc_map.end();
|
|
815
|
+
for (auto it = mdc_map.begin(); it != mdc_map.end(); ++it) {
|
|
816
|
+
auto &pair = *it;
|
|
817
|
+
const auto &key = pair.first;
|
|
818
|
+
const auto &value = pair.second;
|
|
819
|
+
size_t content_size = key.size() + value.size() + 1; // 1 for ':'
|
|
820
|
+
|
|
821
|
+
if (it != last_element) {
|
|
822
|
+
content_size++; // 1 for ' '
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
ScopedPadder p(content_size, padinfo_, dest);
|
|
826
|
+
fmt_helper::append_string_view(key, dest);
|
|
827
|
+
fmt_helper::append_string_view(":", dest);
|
|
828
|
+
fmt_helper::append_string_view(value, dest);
|
|
829
|
+
if (it != last_element) {
|
|
830
|
+
fmt_helper::append_string_view(" ", dest);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
#endif
|
|
836
|
+
|
|
837
|
+
// Full info formatter
|
|
838
|
+
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
|
|
839
|
+
class full_formatter final : public flag_formatter {
|
|
840
|
+
public:
|
|
841
|
+
explicit full_formatter(padding_info padinfo)
|
|
842
|
+
: flag_formatter(padinfo) {}
|
|
843
|
+
|
|
844
|
+
void format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) override {
|
|
845
|
+
using std::chrono::duration_cast;
|
|
846
|
+
using std::chrono::milliseconds;
|
|
847
|
+
using std::chrono::seconds;
|
|
848
|
+
|
|
849
|
+
// cache the date/time part for the next second.
|
|
850
|
+
auto duration = msg.time.time_since_epoch();
|
|
851
|
+
auto secs = duration_cast<seconds>(duration);
|
|
852
|
+
|
|
853
|
+
if (cache_timestamp_ != secs || cached_datetime_.size() == 0) {
|
|
854
|
+
cached_datetime_.clear();
|
|
855
|
+
cached_datetime_.push_back('[');
|
|
856
|
+
fmt_helper::append_int(tm_time.tm_year + 1900, cached_datetime_);
|
|
857
|
+
cached_datetime_.push_back('-');
|
|
858
|
+
|
|
859
|
+
fmt_helper::pad2(tm_time.tm_mon + 1, cached_datetime_);
|
|
860
|
+
cached_datetime_.push_back('-');
|
|
861
|
+
|
|
862
|
+
fmt_helper::pad2(tm_time.tm_mday, cached_datetime_);
|
|
863
|
+
cached_datetime_.push_back(' ');
|
|
864
|
+
|
|
865
|
+
fmt_helper::pad2(tm_time.tm_hour, cached_datetime_);
|
|
866
|
+
cached_datetime_.push_back(':');
|
|
867
|
+
|
|
868
|
+
fmt_helper::pad2(tm_time.tm_min, cached_datetime_);
|
|
869
|
+
cached_datetime_.push_back(':');
|
|
870
|
+
|
|
871
|
+
fmt_helper::pad2(tm_time.tm_sec, cached_datetime_);
|
|
872
|
+
cached_datetime_.push_back('.');
|
|
873
|
+
|
|
874
|
+
cache_timestamp_ = secs;
|
|
875
|
+
}
|
|
876
|
+
dest.append(cached_datetime_.begin(), cached_datetime_.end());
|
|
877
|
+
|
|
878
|
+
auto millis = fmt_helper::time_fraction<milliseconds>(msg.time);
|
|
879
|
+
fmt_helper::pad3(static_cast<uint32_t>(millis.count()), dest);
|
|
880
|
+
dest.push_back(']');
|
|
881
|
+
dest.push_back(' ');
|
|
882
|
+
|
|
883
|
+
// append logger name if exists
|
|
884
|
+
if (msg.logger_name.size() > 0) {
|
|
885
|
+
dest.push_back('[');
|
|
886
|
+
fmt_helper::append_string_view(msg.logger_name, dest);
|
|
887
|
+
dest.push_back(']');
|
|
888
|
+
dest.push_back(' ');
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
dest.push_back('[');
|
|
892
|
+
// wrap the level name with color
|
|
893
|
+
msg.color_range_start = dest.size();
|
|
894
|
+
// fmt_helper::append_string_view(level::to_c_str(msg.level), dest);
|
|
895
|
+
fmt_helper::append_string_view(level::to_string_view(msg.level), dest);
|
|
896
|
+
msg.color_range_end = dest.size();
|
|
897
|
+
dest.push_back(']');
|
|
898
|
+
dest.push_back(' ');
|
|
899
|
+
|
|
900
|
+
// add source location if present
|
|
901
|
+
if (!msg.source.empty()) {
|
|
902
|
+
dest.push_back('[');
|
|
903
|
+
const char *filename =
|
|
904
|
+
details::short_filename_formatter<details::null_scoped_padder>::basename(
|
|
905
|
+
msg.source.filename);
|
|
906
|
+
fmt_helper::append_string_view(filename, dest);
|
|
907
|
+
dest.push_back(':');
|
|
908
|
+
fmt_helper::append_int(msg.source.line, dest);
|
|
909
|
+
dest.push_back(']');
|
|
910
|
+
dest.push_back(' ');
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
#ifndef SPDLOG_NO_TLS
|
|
914
|
+
// add mdc if present
|
|
915
|
+
auto &mdc_map = mdc::get_context();
|
|
916
|
+
if (!mdc_map.empty()) {
|
|
917
|
+
dest.push_back('[');
|
|
918
|
+
mdc_formatter_.format_mdc(mdc_map, dest);
|
|
919
|
+
dest.push_back(']');
|
|
920
|
+
dest.push_back(' ');
|
|
921
|
+
}
|
|
922
|
+
#endif
|
|
923
|
+
// fmt_helper::append_string_view(msg.msg(), dest);
|
|
924
|
+
fmt_helper::append_string_view(msg.payload, dest);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
private:
|
|
928
|
+
std::chrono::seconds cache_timestamp_{0};
|
|
929
|
+
memory_buf_t cached_datetime_;
|
|
930
|
+
|
|
931
|
+
#ifndef SPDLOG_NO_TLS
|
|
932
|
+
mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info {}};
|
|
933
|
+
#endif
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
} // namespace details
|
|
937
|
+
|
|
938
|
+
SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern,
|
|
939
|
+
pattern_time_type time_type,
|
|
940
|
+
std::string eol,
|
|
941
|
+
custom_flags custom_user_flags)
|
|
942
|
+
: pattern_(std::move(pattern)),
|
|
943
|
+
eol_(std::move(eol)),
|
|
944
|
+
pattern_time_type_(time_type),
|
|
945
|
+
need_localtime_(false),
|
|
946
|
+
last_log_secs_(0),
|
|
947
|
+
custom_handlers_(std::move(custom_user_flags)) {
|
|
948
|
+
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
|
949
|
+
compile_pattern_(pattern_);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// use by default full formatter for if pattern is not given
|
|
953
|
+
SPDLOG_INLINE pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
|
|
954
|
+
: pattern_("%+"),
|
|
955
|
+
eol_(std::move(eol)),
|
|
956
|
+
pattern_time_type_(time_type),
|
|
957
|
+
need_localtime_(true),
|
|
958
|
+
last_log_secs_(0) {
|
|
959
|
+
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
|
960
|
+
formatters_.push_back(details::make_unique<details::full_formatter>(details::padding_info{}));
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
SPDLOG_INLINE std::unique_ptr<formatter> pattern_formatter::clone() const {
|
|
964
|
+
custom_flags cloned_custom_formatters;
|
|
965
|
+
for (auto &it : custom_handlers_) {
|
|
966
|
+
cloned_custom_formatters[it.first] = it.second->clone();
|
|
967
|
+
}
|
|
968
|
+
auto cloned = details::make_unique<pattern_formatter>(pattern_, pattern_time_type_, eol_,
|
|
969
|
+
std::move(cloned_custom_formatters));
|
|
970
|
+
cloned->need_localtime(need_localtime_);
|
|
971
|
+
#if defined(__GNUC__) && __GNUC__ < 5
|
|
972
|
+
return std::move(cloned);
|
|
973
|
+
#else
|
|
974
|
+
return cloned;
|
|
975
|
+
#endif
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory_buf_t &dest) {
|
|
979
|
+
if (need_localtime_) {
|
|
980
|
+
const auto secs =
|
|
981
|
+
std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch());
|
|
982
|
+
if (secs != last_log_secs_) {
|
|
983
|
+
cached_tm_ = get_time_(msg);
|
|
984
|
+
last_log_secs_ = secs;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
for (auto &f : formatters_) {
|
|
989
|
+
f->format(msg, cached_tm_, dest);
|
|
990
|
+
}
|
|
991
|
+
// write eol
|
|
992
|
+
details::fmt_helper::append_string_view(eol_, dest);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
SPDLOG_INLINE void pattern_formatter::set_pattern(std::string pattern) {
|
|
996
|
+
pattern_ = std::move(pattern);
|
|
997
|
+
need_localtime_ = false;
|
|
998
|
+
compile_pattern_(pattern_);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
SPDLOG_INLINE void pattern_formatter::need_localtime(bool need) { need_localtime_ = need; }
|
|
1002
|
+
|
|
1003
|
+
SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg) {
|
|
1004
|
+
if (pattern_time_type_ == pattern_time_type::local) {
|
|
1005
|
+
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
1006
|
+
}
|
|
1007
|
+
return details::os::gmtime(log_clock::to_time_t(msg.time));
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
template <typename Padder>
|
|
1011
|
+
SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_info padding) {
|
|
1012
|
+
// process custom flags
|
|
1013
|
+
auto it = custom_handlers_.find(flag);
|
|
1014
|
+
if (it != custom_handlers_.end()) {
|
|
1015
|
+
auto custom_handler = it->second->clone();
|
|
1016
|
+
custom_handler->set_padding_info(padding);
|
|
1017
|
+
formatters_.push_back(std::move(custom_handler));
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// process built-in flags
|
|
1022
|
+
switch (flag) {
|
|
1023
|
+
case ('+'): // default formatter
|
|
1024
|
+
formatters_.push_back(details::make_unique<details::full_formatter>(padding));
|
|
1025
|
+
need_localtime_ = true;
|
|
1026
|
+
break;
|
|
1027
|
+
|
|
1028
|
+
case 'n': // logger name
|
|
1029
|
+
formatters_.push_back(details::make_unique<details::name_formatter<Padder>>(padding));
|
|
1030
|
+
break;
|
|
1031
|
+
|
|
1032
|
+
case 'l': // level
|
|
1033
|
+
formatters_.push_back(details::make_unique<details::level_formatter<Padder>>(padding));
|
|
1034
|
+
break;
|
|
1035
|
+
|
|
1036
|
+
case 'L': // short level
|
|
1037
|
+
formatters_.push_back(
|
|
1038
|
+
details::make_unique<details::short_level_formatter<Padder>>(padding));
|
|
1039
|
+
break;
|
|
1040
|
+
|
|
1041
|
+
case ('t'): // thread id
|
|
1042
|
+
formatters_.push_back(details::make_unique<details::t_formatter<Padder>>(padding));
|
|
1043
|
+
break;
|
|
1044
|
+
|
|
1045
|
+
case ('v'): // the message text
|
|
1046
|
+
formatters_.push_back(details::make_unique<details::v_formatter<Padder>>(padding));
|
|
1047
|
+
break;
|
|
1048
|
+
|
|
1049
|
+
case ('a'): // weekday
|
|
1050
|
+
formatters_.push_back(details::make_unique<details::a_formatter<Padder>>(padding));
|
|
1051
|
+
need_localtime_ = true;
|
|
1052
|
+
break;
|
|
1053
|
+
|
|
1054
|
+
case ('A'): // short weekday
|
|
1055
|
+
formatters_.push_back(details::make_unique<details::A_formatter<Padder>>(padding));
|
|
1056
|
+
need_localtime_ = true;
|
|
1057
|
+
break;
|
|
1058
|
+
|
|
1059
|
+
case ('b'):
|
|
1060
|
+
case ('h'): // month
|
|
1061
|
+
formatters_.push_back(details::make_unique<details::b_formatter<Padder>>(padding));
|
|
1062
|
+
need_localtime_ = true;
|
|
1063
|
+
break;
|
|
1064
|
+
|
|
1065
|
+
case ('B'): // short month
|
|
1066
|
+
formatters_.push_back(details::make_unique<details::B_formatter<Padder>>(padding));
|
|
1067
|
+
need_localtime_ = true;
|
|
1068
|
+
break;
|
|
1069
|
+
|
|
1070
|
+
case ('c'): // datetime
|
|
1071
|
+
formatters_.push_back(details::make_unique<details::c_formatter<Padder>>(padding));
|
|
1072
|
+
need_localtime_ = true;
|
|
1073
|
+
break;
|
|
1074
|
+
|
|
1075
|
+
case ('C'): // year 2 digits
|
|
1076
|
+
formatters_.push_back(details::make_unique<details::C_formatter<Padder>>(padding));
|
|
1077
|
+
need_localtime_ = true;
|
|
1078
|
+
break;
|
|
1079
|
+
|
|
1080
|
+
case ('Y'): // year 4 digits
|
|
1081
|
+
formatters_.push_back(details::make_unique<details::Y_formatter<Padder>>(padding));
|
|
1082
|
+
need_localtime_ = true;
|
|
1083
|
+
break;
|
|
1084
|
+
|
|
1085
|
+
case ('D'):
|
|
1086
|
+
case ('x'): // datetime MM/DD/YY
|
|
1087
|
+
formatters_.push_back(details::make_unique<details::D_formatter<Padder>>(padding));
|
|
1088
|
+
need_localtime_ = true;
|
|
1089
|
+
break;
|
|
1090
|
+
|
|
1091
|
+
case ('m'): // month 1-12
|
|
1092
|
+
formatters_.push_back(details::make_unique<details::m_formatter<Padder>>(padding));
|
|
1093
|
+
need_localtime_ = true;
|
|
1094
|
+
break;
|
|
1095
|
+
|
|
1096
|
+
case ('d'): // day of month 1-31
|
|
1097
|
+
formatters_.push_back(details::make_unique<details::d_formatter<Padder>>(padding));
|
|
1098
|
+
need_localtime_ = true;
|
|
1099
|
+
break;
|
|
1100
|
+
|
|
1101
|
+
case ('H'): // hours 24
|
|
1102
|
+
formatters_.push_back(details::make_unique<details::H_formatter<Padder>>(padding));
|
|
1103
|
+
need_localtime_ = true;
|
|
1104
|
+
break;
|
|
1105
|
+
|
|
1106
|
+
case ('I'): // hours 12
|
|
1107
|
+
formatters_.push_back(details::make_unique<details::I_formatter<Padder>>(padding));
|
|
1108
|
+
need_localtime_ = true;
|
|
1109
|
+
break;
|
|
1110
|
+
|
|
1111
|
+
case ('M'): // minutes
|
|
1112
|
+
formatters_.push_back(details::make_unique<details::M_formatter<Padder>>(padding));
|
|
1113
|
+
need_localtime_ = true;
|
|
1114
|
+
break;
|
|
1115
|
+
|
|
1116
|
+
case ('S'): // seconds
|
|
1117
|
+
formatters_.push_back(details::make_unique<details::S_formatter<Padder>>(padding));
|
|
1118
|
+
need_localtime_ = true;
|
|
1119
|
+
break;
|
|
1120
|
+
|
|
1121
|
+
case ('e'): // milliseconds
|
|
1122
|
+
formatters_.push_back(details::make_unique<details::e_formatter<Padder>>(padding));
|
|
1123
|
+
break;
|
|
1124
|
+
|
|
1125
|
+
case ('f'): // microseconds
|
|
1126
|
+
formatters_.push_back(details::make_unique<details::f_formatter<Padder>>(padding));
|
|
1127
|
+
break;
|
|
1128
|
+
|
|
1129
|
+
case ('F'): // nanoseconds
|
|
1130
|
+
formatters_.push_back(details::make_unique<details::F_formatter<Padder>>(padding));
|
|
1131
|
+
break;
|
|
1132
|
+
|
|
1133
|
+
case ('E'): // seconds since epoch
|
|
1134
|
+
formatters_.push_back(details::make_unique<details::E_formatter<Padder>>(padding));
|
|
1135
|
+
break;
|
|
1136
|
+
|
|
1137
|
+
case ('p'): // am/pm
|
|
1138
|
+
formatters_.push_back(details::make_unique<details::p_formatter<Padder>>(padding));
|
|
1139
|
+
need_localtime_ = true;
|
|
1140
|
+
break;
|
|
1141
|
+
|
|
1142
|
+
case ('r'): // 12 hour clock 02:55:02 pm
|
|
1143
|
+
formatters_.push_back(details::make_unique<details::r_formatter<Padder>>(padding));
|
|
1144
|
+
need_localtime_ = true;
|
|
1145
|
+
break;
|
|
1146
|
+
|
|
1147
|
+
case ('R'): // 24-hour HH:MM time
|
|
1148
|
+
formatters_.push_back(details::make_unique<details::R_formatter<Padder>>(padding));
|
|
1149
|
+
need_localtime_ = true;
|
|
1150
|
+
break;
|
|
1151
|
+
|
|
1152
|
+
case ('T'):
|
|
1153
|
+
case ('X'): // ISO 8601 time format (HH:MM:SS)
|
|
1154
|
+
formatters_.push_back(details::make_unique<details::T_formatter<Padder>>(padding));
|
|
1155
|
+
need_localtime_ = true;
|
|
1156
|
+
break;
|
|
1157
|
+
|
|
1158
|
+
case ('z'): // timezone
|
|
1159
|
+
formatters_.push_back(details::make_unique<details::z_formatter<Padder>>(padding));
|
|
1160
|
+
need_localtime_ = true;
|
|
1161
|
+
break;
|
|
1162
|
+
|
|
1163
|
+
case ('P'): // pid
|
|
1164
|
+
formatters_.push_back(details::make_unique<details::pid_formatter<Padder>>(padding));
|
|
1165
|
+
break;
|
|
1166
|
+
|
|
1167
|
+
case ('^'): // color range start
|
|
1168
|
+
formatters_.push_back(details::make_unique<details::color_start_formatter>(padding));
|
|
1169
|
+
break;
|
|
1170
|
+
|
|
1171
|
+
case ('$'): // color range end
|
|
1172
|
+
formatters_.push_back(details::make_unique<details::color_stop_formatter>(padding));
|
|
1173
|
+
break;
|
|
1174
|
+
|
|
1175
|
+
case ('@'): // source location (filename:filenumber)
|
|
1176
|
+
formatters_.push_back(
|
|
1177
|
+
details::make_unique<details::source_location_formatter<Padder>>(padding));
|
|
1178
|
+
break;
|
|
1179
|
+
|
|
1180
|
+
case ('s'): // short source filename - without directory name
|
|
1181
|
+
formatters_.push_back(
|
|
1182
|
+
details::make_unique<details::short_filename_formatter<Padder>>(padding));
|
|
1183
|
+
break;
|
|
1184
|
+
|
|
1185
|
+
case ('g'): // full source filename
|
|
1186
|
+
formatters_.push_back(
|
|
1187
|
+
details::make_unique<details::source_filename_formatter<Padder>>(padding));
|
|
1188
|
+
break;
|
|
1189
|
+
|
|
1190
|
+
case ('#'): // source line number
|
|
1191
|
+
formatters_.push_back(
|
|
1192
|
+
details::make_unique<details::source_linenum_formatter<Padder>>(padding));
|
|
1193
|
+
break;
|
|
1194
|
+
|
|
1195
|
+
case ('!'): // source funcname
|
|
1196
|
+
formatters_.push_back(
|
|
1197
|
+
details::make_unique<details::source_funcname_formatter<Padder>>(padding));
|
|
1198
|
+
break;
|
|
1199
|
+
|
|
1200
|
+
case ('%'): // % char
|
|
1201
|
+
formatters_.push_back(details::make_unique<details::ch_formatter>('%'));
|
|
1202
|
+
break;
|
|
1203
|
+
|
|
1204
|
+
case ('u'): // elapsed time since last log message in nanos
|
|
1205
|
+
formatters_.push_back(
|
|
1206
|
+
details::make_unique<details::elapsed_formatter<Padder, std::chrono::nanoseconds>>(
|
|
1207
|
+
padding));
|
|
1208
|
+
break;
|
|
1209
|
+
|
|
1210
|
+
case ('i'): // elapsed time since last log message in micros
|
|
1211
|
+
formatters_.push_back(
|
|
1212
|
+
details::make_unique<details::elapsed_formatter<Padder, std::chrono::microseconds>>(
|
|
1213
|
+
padding));
|
|
1214
|
+
break;
|
|
1215
|
+
|
|
1216
|
+
case ('o'): // elapsed time since last log message in millis
|
|
1217
|
+
formatters_.push_back(
|
|
1218
|
+
details::make_unique<details::elapsed_formatter<Padder, std::chrono::milliseconds>>(
|
|
1219
|
+
padding));
|
|
1220
|
+
break;
|
|
1221
|
+
|
|
1222
|
+
case ('O'): // elapsed time since last log message in seconds
|
|
1223
|
+
formatters_.push_back(
|
|
1224
|
+
details::make_unique<details::elapsed_formatter<Padder, std::chrono::seconds>>(
|
|
1225
|
+
padding));
|
|
1226
|
+
break;
|
|
1227
|
+
|
|
1228
|
+
#ifndef SPDLOG_NO_TLS // mdc formatter requires TLS support
|
|
1229
|
+
case ('&'):
|
|
1230
|
+
formatters_.push_back(details::make_unique<details::mdc_formatter<Padder>>(padding));
|
|
1231
|
+
break;
|
|
1232
|
+
#endif
|
|
1233
|
+
|
|
1234
|
+
default: // Unknown flag appears as is
|
|
1235
|
+
auto unknown_flag = details::make_unique<details::aggregate_formatter>();
|
|
1236
|
+
|
|
1237
|
+
if (!padding.truncate_) {
|
|
1238
|
+
unknown_flag->add_ch('%');
|
|
1239
|
+
unknown_flag->add_ch(flag);
|
|
1240
|
+
formatters_.push_back((std::move(unknown_flag)));
|
|
1241
|
+
}
|
|
1242
|
+
// fix issue #1617 (prev char was '!' and should have been treated as funcname flag
|
|
1243
|
+
// instead of truncating flag) spdlog::set_pattern("[%10!] %v") => "[ main] some
|
|
1244
|
+
// message" spdlog::set_pattern("[%3!!] %v") => "[mai] some message"
|
|
1245
|
+
else {
|
|
1246
|
+
padding.truncate_ = false;
|
|
1247
|
+
formatters_.push_back(
|
|
1248
|
+
details::make_unique<details::source_funcname_formatter<Padder>>(padding));
|
|
1249
|
+
unknown_flag->add_ch(flag);
|
|
1250
|
+
formatters_.push_back((std::move(unknown_flag)));
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
break;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// Extract given pad spec (e.g. %8X, %=8X, %-8!X, %8!X, %=8!X, %-8!X, %+8!X)
|
|
1258
|
+
// Advance the given it pass the end of the padding spec found (if any)
|
|
1259
|
+
// Return padding.
|
|
1260
|
+
SPDLOG_INLINE details::padding_info pattern_formatter::handle_padspec_(
|
|
1261
|
+
std::string::const_iterator &it, std::string::const_iterator end) {
|
|
1262
|
+
using details::padding_info;
|
|
1263
|
+
using details::scoped_padder;
|
|
1264
|
+
const size_t max_width = 64;
|
|
1265
|
+
if (it == end) {
|
|
1266
|
+
return padding_info{};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
padding_info::pad_side side;
|
|
1270
|
+
switch (*it) {
|
|
1271
|
+
case '-':
|
|
1272
|
+
side = padding_info::pad_side::right;
|
|
1273
|
+
++it;
|
|
1274
|
+
break;
|
|
1275
|
+
case '=':
|
|
1276
|
+
side = padding_info::pad_side::center;
|
|
1277
|
+
++it;
|
|
1278
|
+
break;
|
|
1279
|
+
default:
|
|
1280
|
+
side = details::padding_info::pad_side::left;
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
if (it == end || !std::isdigit(static_cast<unsigned char>(*it))) {
|
|
1285
|
+
return padding_info{}; // no padding if no digit found here
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
auto width = static_cast<size_t>(*it) - '0';
|
|
1289
|
+
for (++it; it != end && std::isdigit(static_cast<unsigned char>(*it)); ++it) {
|
|
1290
|
+
auto digit = static_cast<size_t>(*it) - '0';
|
|
1291
|
+
width = width * 10 + digit;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// search for the optional truncate marker '!'
|
|
1295
|
+
bool truncate;
|
|
1296
|
+
if (it != end && *it == '!') {
|
|
1297
|
+
truncate = true;
|
|
1298
|
+
++it;
|
|
1299
|
+
} else {
|
|
1300
|
+
truncate = false;
|
|
1301
|
+
}
|
|
1302
|
+
return details::padding_info{std::min<size_t>(width, max_width), side, truncate};
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &pattern) {
|
|
1306
|
+
auto end = pattern.end();
|
|
1307
|
+
std::unique_ptr<details::aggregate_formatter> user_chars;
|
|
1308
|
+
formatters_.clear();
|
|
1309
|
+
for (auto it = pattern.begin(); it != end; ++it) {
|
|
1310
|
+
if (*it == '%') {
|
|
1311
|
+
if (user_chars) // append user chars found so far
|
|
1312
|
+
{
|
|
1313
|
+
formatters_.push_back(std::move(user_chars));
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
auto padding = handle_padspec_(++it, end);
|
|
1317
|
+
|
|
1318
|
+
if (it != end) {
|
|
1319
|
+
if (padding.enabled()) {
|
|
1320
|
+
handle_flag_<details::scoped_padder>(*it, padding);
|
|
1321
|
+
} else {
|
|
1322
|
+
handle_flag_<details::null_scoped_padder>(*it, padding);
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
} else // chars not following the % sign should be displayed as is
|
|
1328
|
+
{
|
|
1329
|
+
if (!user_chars) {
|
|
1330
|
+
user_chars = details::make_unique<details::aggregate_formatter>();
|
|
1331
|
+
}
|
|
1332
|
+
user_chars->add_ch(*it);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
if (user_chars) // append raw chars found so far
|
|
1336
|
+
{
|
|
1337
|
+
formatters_.push_back(std::move(user_chars));
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
} // namespace spdlog
|