diff options
Diffstat (limited to 'src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h')
-rw-r--r-- | src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h index ef92cc4035..210b1ec974 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/emitter.h @@ -7,16 +7,18 @@ #pragma once #endif +#include <cmath> #include <cstddef> +#include <limits> #include <memory> #include <sstream> #include <string> +#include <type_traits> #include "yaml-cpp/binary.h" #include "yaml-cpp/dll.h" #include "yaml-cpp/emitterdef.h" #include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/noncopyable.h" #include "yaml-cpp/null.h" #include "yaml-cpp/ostream_wrapper.h" @@ -28,10 +30,12 @@ struct _Null; namespace YAML { class EmitterState; -class YAML_CPP_API Emitter : private noncopyable { +class YAML_CPP_API Emitter { public: Emitter(); explicit Emitter(std::ostream& stream); + Emitter(const Emitter&) = delete; + Emitter& operator=(const Emitter&) = delete; ~Emitter(); // output @@ -46,6 +50,7 @@ class YAML_CPP_API Emitter : private noncopyable { bool SetOutputCharset(EMITTER_MANIP value); bool SetStringFormat(EMITTER_MANIP value); bool SetBoolFormat(EMITTER_MANIP value); + bool SetNullFormat(EMITTER_MANIP value); bool SetIntBase(EMITTER_MANIP value); bool SetSeqFormat(EMITTER_MANIP value); bool SetMapFormat(EMITTER_MANIP value); @@ -54,6 +59,7 @@ class YAML_CPP_API Emitter : private noncopyable { bool SetPostCommentIndent(std::size_t n); bool SetFloatPrecision(std::size_t n); bool SetDoublePrecision(std::size_t n); + void RestoreGlobalModifiedSettings(); // local setters Emitter& SetLocalValue(EMITTER_MANIP value); @@ -119,6 +125,7 @@ class YAML_CPP_API Emitter : private noncopyable { void SpaceOrIndentTo(bool requireSpace, std::size_t indent); const char* ComputeFullBoolName(bool b) const; + const char* ComputeNullName() const; bool CanEmitNewline() const; private: @@ -152,7 +159,27 @@ inline Emitter& Emitter::WriteStreamable(T value) { std::stringstream stream; SetStreamablePrecision<T>(stream); - stream << value; + + bool special = false; + if (std::is_floating_point<T>::value) { + if ((std::numeric_limits<T>::has_quiet_NaN || + std::numeric_limits<T>::has_signaling_NaN) && + std::isnan(value)) { + special = true; + stream << ".nan"; + } else if (std::numeric_limits<T>::has_infinity && std::isinf(value)) { + special = true; + if (std::signbit(value)) { + stream << "-.inf"; + } else { + stream << ".inf"; + } + } + } + + if (!special) { + stream << value; + } m_stream << stream.str(); StartedScalar(); @@ -249,6 +276,6 @@ inline Emitter& operator<<(Emitter& emitter, _Indent indent) { inline Emitter& operator<<(Emitter& emitter, _Precision precision) { return emitter.SetLocalPrecision(precision); } -} +} // namespace YAML #endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |