OSDN Git Service

C++ wrapper: Add overload of update() that processes a sequence of elements specified...
[mhash384/mhash384.git] / libmhash384 / include / mhash384.h
index a221a82..d12ecec 100644 (file)
@@ -1,6 +1,6 @@
 /* ---------------------------------------------------------------------------------------------- */
 /* MHash-384 - Simple fast portable secure hashing library                                        */
-/* Copyright(c) 2016-2019 LoRd_MuldeR <mulder2@gmx.de>                                            */
+/* Copyright(c) 2016-2020 LoRd_MuldeR <mulder2@gmx.de>                                            */
 /*                                                                                                */
 /* Permission is hereby granted, free of charge, to any person obtaining a copy of this software  */
 /* and associated documentation files (the "Software"), to deal in the Software without           */
@@ -100,6 +100,16 @@ public:
                update(reinterpret_cast<const std::uint8_t*>(text.c_str()), text.length());
        }
 
+       template<typename iterator_type>
+       void update(const iterator_type &first, const iterator_type &last)
+       {
+               typedef typename std::iterator_traits<iterator_type>::value_type value_type;
+               for (iterator_type iter = first; iter != last; ++iter)
+               {
+                       update(reinterpret_cast<const std::uint8_t*>(&(*iter)), sizeof(value_type));
+               }
+       }
+
        const std::uint8_t *finish(void)
        {
                if(!finished)