diff --git a/include/Vutils.h b/include/Vutils.h index e9cacbf..75be219 100644 --- a/include/Vutils.h +++ b/include/Vutils.h @@ -1065,6 +1065,71 @@ class Buffer size_t m_size; }; +/** + * Variant + */ + +template +class VariantT +{ +public: + VariantT(); + VariantT(VariantT& right); + virtual ~VariantT(); + + VariantT& operator=(VariantT& right); + + T& data() + { + return *m_data; + } + + template + friend VariantT& operator<<(VariantT& stream, T v) + { + stream.data() << v; + return stream; + } + + bool empty() const; + + int to_int() const; + unsigned int to_uint() const; + __int64 to_int64() const; + unsigned __int64 to_uint64() const; + bool to_bool() const; + float to_float() const; + double to_double() const; + std::unique_ptr to_bytes() const; + +protected: + std::unique_ptr m_data; +}; + +#define VariantTA VariantT + +class VariantA : public VariantTA +{ +public: + VariantA(); + VariantA(VariantA& right); + virtual ~VariantA(); + + std::string to_string() const; +}; + +#define VariantTW VariantT + +class VariantW : public VariantTW +{ +public: + VariantW(); + VariantW(VariantW& right); + virtual ~VariantW(); + + std::wstring to_string() const; +}; + /** * Library */ @@ -2747,71 +2812,6 @@ class PEFileTW : public PEFileTX FileMappingW m_file_map; }; -/** - * Variant - */ - -template -class VariantT -{ -public: - VariantT(); - VariantT(VariantT& right); - virtual ~VariantT(); - - VariantT& operator=(VariantT& right); - - T& data() - { - return *m_data; - } - - template - friend VariantT& operator<<(VariantT& stream, T v) - { - stream.data() << v; - return stream; - } - - bool empty() const; - - int to_int() const; - unsigned int to_uint() const; - __int64 to_int64() const; - unsigned __int64 to_uint64() const; - bool to_bool() const; - float to_float() const; - double to_double() const; - std::unique_ptr to_bytes() const; - -protected: - std::unique_ptr m_data; -}; - -#define VariantTA VariantT - -class VariantA : public VariantTA -{ -public: - VariantA(); - VariantA(VariantA& right); - virtual ~VariantA(); - - std::string to_string() const; -}; - -#define VariantTW VariantT - -class VariantW : public VariantTW -{ -public: - VariantW(); - VariantW(VariantW& right); - virtual ~VariantW(); - - std::wstring to_string() const; -}; - /** * WDTControl */