1
/* ipuz-guesses.h
2
 *
3
 * Copyright 2022 Jonathan Blandford <jrb@gnome.org>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 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
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 * SPDX-License-Identifier: (LGPL-2.1-or-later OR MIT)
20
 */
21

            
22
#pragma once
23

            
24
#include <glib-object.h>
25
#include <json-glib/json-glib.h>
26
#include <libipuz/ipuz-board.h>
27

            
28
G_BEGIN_DECLS
29

            
30

            
31
typedef struct _IPuzGuesses IPuzGuesses;
32

            
33

            
34
#define IPUZ_TYPE_GUESSES (ipuz_guesses_get_type ())
35

            
36

            
37
GType             ipuz_guesses_get_type        (void) G_GNUC_CONST;
38
IPuzGuesses      *ipuz_guesses_new_from_board  (IPuzBoard      *board,
39
                                                gboolean        copy_guesses);
40
IPuzGuesses      *ipuz_guesses_new_from_json   (JsonNode       *root,
41
                                                GError        **error);
42
IPuzGuesses      *ipuz_guesses_new_from_file   (const gchar    *filename,
43
                                                GError        **error);
44
IPuzGuesses      *ipuz_guesses_new_from_stream (GInputStream   *stream,
45
                                                GCancellable   *cancellable,
46
                                                GError        **error);
47
gboolean          ipuz_guesses_save_to_file    (IPuzGuesses    *guesses,
48
                                                const gchar    *filename,
49
                                                GError        **error);
50

            
51
IPuzGuesses      *ipuz_guesses_ref             (IPuzGuesses    *guesses);
52
void              ipuz_guesses_unref           (IPuzGuesses    *guesses);
53
IPuzGuesses      *ipuz_guesses_copy            (IPuzGuesses    *src);
54
gboolean          ipuz_guesses_equal           (IPuzGuesses    *a,
55
                                                IPuzGuesses    *b);
56

            
57
guint             ipuz_guesses_get_width       (IPuzGuesses    *guesses);
58
guint             ipuz_guesses_get_height      (IPuzGuesses    *guesses);
59
const gchar      *ipuz_guesses_get_guess       (IPuzGuesses    *guesses,
60
                                                IPuzCellCoord   coord);
61
void              ipuz_guesses_set_guess       (IPuzGuesses    *guesses,
62
                                                IPuzCellCoord   coord,
63
                                                const gchar    *guess);
64
IPuzCellCellType  ipuz_guesses_get_cell_type   (IPuzGuesses    *guesses,
65
                                                IPuzCellCoord   coord);
66
gfloat            ipuz_guesses_get_percent     (IPuzGuesses    *guesses);
67
gchar            *ipuz_guesses_get_checksum    (IPuzGuesses    *guesses,
68
                                                const gchar    *salt);
69

            
70

            
71
/* Public functions */
72
void              ipuz_guesses_print           (IPuzGuesses    *guesses);
73

            
74

            
75
2
G_DEFINE_AUTOPTR_CLEANUP_FUNC(IPuzGuesses, ipuz_guesses_unref)
76

            
77

            
78
G_END_DECLS
79