diff options
author | B Stack <bgstack15@gmail.com> | 2018-09-10 02:46:25 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-09-10 02:46:25 +0000 |
commit | 728d32e6da9ce66968f8eef47a59505d613e2c1b (patch) | |
tree | 0f0441755ff0e6d65e12222d4502c648bffd6a7c /zenXml/zenxml | |
parent | 10.3 (diff) | |
parent | pull in latest 10.4 from upstream (diff) | |
download | FreeFileSync-728d32e6da9ce66968f8eef47a59505d613e2c1b.tar.gz FreeFileSync-728d32e6da9ce66968f8eef47a59505d613e2c1b.tar.bz2 FreeFileSync-728d32e6da9ce66968f8eef47a59505d613e2c1b.zip |
Merge branch '10.4' into 'master'10.4
pull in latest 10.4 from upstream
See merge request opensource-tracking/FreeFileSync!1
Diffstat (limited to 'zenXml/zenxml')
-rwxr-xr-x | zenXml/zenxml/cvrt_struc.h | 26 | ||||
-rwxr-xr-x | zenXml/zenxml/cvrt_text.h | 37 | ||||
-rwxr-xr-x | zenXml/zenxml/dom.h | 8 |
3 files changed, 50 insertions, 21 deletions
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 <T>::value>; -namespace impl_2384343 +template <class T> +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 <typename T> -using IsStlPair = std::bool_constant< - impl_2384343::HasMemberType_first_type <T>::value && - impl_2384343::HasMemberType_second_type<T>::value && - impl_2384343::HasMember_first <T>::value && - impl_2384343::HasMember_second <T>::value>; +private: + using Yes = char[1]; + using No = char[2]; + + template <class T1, class T2> + static Yes& isPair(const std::pair<T1, T2>&); + static No& isPair(...); +public: + enum { value = sizeof(isPair(std::declval<T>())) == 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 <chrono> #include <zen/utf.h> #include <zen/string_tools.h> @@ -101,21 +102,37 @@ template <class T> void writeText(const T& value, std::string& output); //------------------------------ implementation ------------------------------------- +template <class T> +struct IsChronoDuration +{ +private: + using Yes = char[1]; + using No = char[2]; + + template <class Rep, class Period> + static Yes& isDuration(std::chrono::duration<Rep, Period>); + static No& isDuration(...); +public: + enum { value = sizeof(isDuration(std::declval<T>())) == 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 <class T> struct GetTextType : std::integral_constant<TextType, - std::is_same_v<T, bool> ? TEXT_TYPE_BOOL : - IsStringLikeV<T> ? TEXT_TYPE_STRING : //string before number to correctly handle char/wchar_t -> this was an issue with Loki only! - IsArithmetic<T>::value ? TEXT_TYPE_NUMBER : // + std::is_same_v<T, bool> ? TEXT_TYPE_BOOL : + IsStringLikeV<T> ? TEXT_TYPE_STRING : //string before number to correctly handle char/wchar_t -> this was an issue with Loki only! + IsArithmetic<T>::value ? TEXT_TYPE_NUMBER : // + IsChronoDuration<T>::value ? TEXT_TYPE_CHRONO : TEXT_TYPE_OTHER> {}; //###################################################################################### @@ -165,6 +182,20 @@ struct ConvertText<T, TEXT_TYPE_NUMBER> } }; +template <class T> +struct ConvertText<T, TEXT_TYPE_CHRONO> +{ + void writeText(const T& value, std::string& output) const + { + output = numberTo<std::string>(value.count()); + } + bool readText(const std::string& input, T& value) const + { + value = T(stringTo<typename T::rep>(input)); + return true; + } +}; + //partial specialization: handle conversion for all string-like types! template <class T> struct ConvertText<T, TEXT_TYPE_STRING> 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<AttrIter, AttrIter> 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: <?xml version="1.0" encoding="utf-8" ?> 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<std::string>(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_); |