Fix crash on startup if an LV2 plugin has a bad .ttl file.
[ardour.git] / libs / glibmm2 / glib / src / checksum.ccg
1 /* $Id$ */
2
3 /* Copyright (C) 2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <glibmm/utility.h>
21 #include <glibmm/checksum.h>
22
23 namespace Glib
24 {
25
26 Checksum::Checksum(ChecksumType type)
27 : gobject_(g_checksum_new((GChecksumType)type))
28 {
29 }
30
31 Checksum::operator bool() const
32 {
33   return gobject_ != 0;
34 }
35
36 gssize Checksum::get_length(ChecksumType checksum_type)
37 {
38   return g_checksum_type_get_length((GChecksumType)checksum_type);
39 }
40
41 std::string Checksum::compute_checksum(ChecksumType type, const std::string& data)
42 {
43   return Glib::convert_return_gchar_ptr_to_ustring(g_compute_checksum_for_string(((GChecksumType)type), data.c_str(), data.size()));
44 }
45
46 void Checksum::update(const std::string& data)
47 {
48   g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size()); 
49 }
50
51 } // Glib namespace
52
53