1 // Generated by gtkmmproc -- DO NOT MODIFY!
4 #include <glibmm/checksum.h>
5 #include <glibmm/private/checksum_p.h>
9 /* Copyright (C) 2002 The gtkmm Development Team
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <glibmm/utility.h>
27 #include <glibmm/checksum.h>
32 Checksum::Checksum(ChecksumType type)
33 : gobject_(g_checksum_new((GChecksumType)type))
37 Checksum::operator bool() const
42 gssize Checksum::get_length(ChecksumType checksum_type)
44 return g_checksum_type_get_length((GChecksumType)checksum_type);
47 std::string Checksum::compute_checksum(ChecksumType type, const std::string& data)
49 return Glib::convert_return_gchar_ptr_to_ustring(g_compute_checksum_for_string(((GChecksumType)type), data.c_str(), data.size()));
52 void Checksum::update(const std::string& data)
54 g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size());
62 } // anonymous namespace
68 Glib::Checksum wrap(GChecksum* object, bool take_copy /* = false */)
70 return Glib::Checksum(object, take_copy);
82 gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
85 Checksum::Checksum(const Checksum& src)
87 gobject_ ((src.gobject_) ? g_checksum_copy(src.gobject_) : 0)
90 Checksum::Checksum(GChecksum* castitem, bool make_a_copy /* = false */)
94 // It was given to us by a function which has already made a copy for us to keep.
99 // We are probably getting it via direct access to a struct,
100 // so we can not just take it - we have to take a copy of it.
102 gobject_ = g_checksum_copy(castitem);
108 Checksum& Checksum::operator=(const Checksum& src)
110 GChecksum *const new_gobject = (src.gobject_) ? g_checksum_copy(src.gobject_) : 0;
113 g_checksum_free(gobject_);
115 gobject_ = new_gobject;
120 Checksum::~Checksum()
123 g_checksum_free(gobject_);
126 GChecksum* Checksum::gobj_copy() const
128 return g_checksum_copy(gobject_);
132 void Checksum::reset()
134 g_checksum_reset(gobj());
137 void Checksum::update(const guchar* data, gsize length)
139 g_checksum_update(gobj(), data, length);
142 void Checksum::get_digest(guint8 * buffer, gsize * digest_len) const
144 g_checksum_get_digest(const_cast<GChecksum*>(gobj()), buffer, digest_len);
147 std::string Checksum::get_string() const
149 return Glib::convert_const_gchar_ptr_to_stdstring(g_checksum_get_string(const_cast<GChecksum*>(gobj())));
152 std::string Checksum::compute_checksum(ChecksumType type, const guchar* data, gsize length)
154 return Glib::convert_return_gchar_ptr_to_stdstring(g_compute_checksum_for_data(((GChecksumType)type), data, length));