From eb5d3e5df99de2c3d8da2e8bc7b12ed427465dba Mon Sep 17 00:00:00 2001 From: B Stack Date: Sun, 9 Sep 2018 18:53:23 -0400 Subject: pull in latest 10.4 from upstream --- zenXml/zenxml/cvrt_struc.h | 26 ++++++++++++-------------- zenXml/zenxml/cvrt_text.h | 37 ++++++++++++++++++++++++++++++++++--- zenXml/zenxml/dom.h | 8 ++++---- 3 files changed, 50 insertions(+), 21 deletions(-) (limited to 'zenXml/zenxml') diff --git a/zenXml/zenxml/cvrt_struc.h b/zenXml/zenxml/cvrt_struc.h index 11795107..85c5d8d0 100755 --- a/zenXml/zenxml/cvrt_struc.h +++ b/zenXml/zenxml/cvrt_struc.h @@ -65,21 +65,19 @@ using IsStlContainer = std::bool_constant< impl_2384343::HasMember_insert ::value>; -namespace impl_2384343 +template +struct IsStlPair { -ZEN_INIT_DETECT_MEMBER_TYPE(first_type); -ZEN_INIT_DETECT_MEMBER_TYPE(second_type); - -ZEN_INIT_DETECT_MEMBER(first) //we don't know the exact declaration of the member attribute: may be in a base class! -ZEN_INIT_DETECT_MEMBER(second) // -} - -template -using IsStlPair = std::bool_constant< - impl_2384343::HasMemberType_first_type ::value && - impl_2384343::HasMemberType_second_type::value && - impl_2384343::HasMember_first ::value && - impl_2384343::HasMember_second ::value>; +private: + using Yes = char[1]; + using No = char[2]; + + template + static Yes& isPair(const std::pair&); + static No& isPair(...); +public: + enum { value = sizeof(isPair(std::declval())) == sizeof(Yes) }; +}; //###################################################################################### diff --git a/zenXml/zenxml/cvrt_text.h b/zenXml/zenxml/cvrt_text.h index 32a961b2..c6dab8c2 100755 --- a/zenXml/zenxml/cvrt_text.h +++ b/zenXml/zenxml/cvrt_text.h @@ -7,6 +7,7 @@ #ifndef CVRT_TEXT_H_018727339083427097434 #define CVRT_TEXT_H_018727339083427097434 +#include #include #include @@ -101,21 +102,37 @@ template void writeText(const T& value, std::string& output); //------------------------------ implementation ------------------------------------- +template +struct IsChronoDuration +{ +private: + using Yes = char[1]; + using No = char[2]; + + template + static Yes& isDuration(std::chrono::duration); + static No& isDuration(...); +public: + enum { value = sizeof(isDuration(std::declval())) == sizeof(Yes) }; +}; + //Conversion from arbitrary types to text (for use with XML elements and attributes) enum TextType { TEXT_TYPE_BOOL, TEXT_TYPE_NUMBER, + TEXT_TYPE_CHRONO, TEXT_TYPE_STRING, TEXT_TYPE_OTHER, }; template struct GetTextType : std::integral_constant ? TEXT_TYPE_BOOL : - IsStringLikeV ? TEXT_TYPE_STRING : //string before number to correctly handle char/wchar_t -> this was an issue with Loki only! - IsArithmetic::value ? TEXT_TYPE_NUMBER : // + std::is_same_v ? TEXT_TYPE_BOOL : + IsStringLikeV ? TEXT_TYPE_STRING : //string before number to correctly handle char/wchar_t -> this was an issue with Loki only! + IsArithmetic::value ? TEXT_TYPE_NUMBER : // + IsChronoDuration::value ? TEXT_TYPE_CHRONO : TEXT_TYPE_OTHER> {}; //###################################################################################### @@ -165,6 +182,20 @@ struct ConvertText } }; +template +struct ConvertText +{ + void writeText(const T& value, std::string& output) const + { + output = numberTo(value.count()); + } + bool readText(const std::string& input, T& value) const + { + value = T(stringTo(input)); + return true; + } +}; + //partial specialization: handle conversion for all string-like types! template struct ConvertText diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h index 8793d5bd..d95f5aa1 100755 --- a/zenXml/zenxml/dom.h +++ b/zenXml/zenxml/dom.h @@ -237,7 +237,7 @@ public: std::pair getAttributes() const { return { attributes_.begin(), attributes_.end() }; } //swap two elements while keeping references to parent. -> disabled documentation extraction - void swapSubtree(XmlElement& other) + void swapSubtree(XmlElement& other) noexcept { name_ .swap(other.name_); value_ .swap(other.value_); @@ -283,8 +283,8 @@ public: ///Default constructor setting up an empty XML document with a standard declaration: XmlDoc() {} - XmlDoc(XmlDoc&& tmp) { swap(tmp); } - XmlDoc& operator=(XmlDoc&& tmp) { swap(tmp); return *this; } + XmlDoc(XmlDoc&& tmp) noexcept { swap(tmp); } + XmlDoc& operator=(XmlDoc&& tmp) noexcept { swap(tmp); return *this; } //Setup an empty XML document /** @@ -342,7 +342,7 @@ public: void setStandalone(const String& standalone) { standalone_ = utfTo(standalone); } //Transactionally swap two elements. -> disabled documentation extraction - void swap(XmlDoc& other) + void swap(XmlDoc& other) noexcept { version_ .swap(other.version_); encoding_ .swap(other.encoding_); -- cgit