Added utility ECollator to libedataserver.
[platform/upstream/evolution-data-server.git] / libedataserver / e-collator.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2013 Intel Corporation
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU Lesser General Public
7  * License as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  * Author: Tristan Van Berkom <tristanvb@openismus.com>
20  */
21 #if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
22 #error "Only <libedataserver/libedataserver.h> should be included directly."
23 #endif
24
25 #include <glib.h>
26 #include <libedataserver/e-source-enumtypes.h>
27 #include <libedataserver/e-data-server-util.h>
28
29 #ifndef E_COLLATOR_H
30 #define E_COLLATOR_H
31
32 /**
33  * E_COLLATOR_ERROR:
34  *
35  * An error domain for collation errors
36  *
37  * Since: 3.10
38  */
39 #define E_COLLATOR_ERROR (e_collator_error_quark ())
40
41 #define E_TYPE_COLLATOR (e_collator_get_type ())
42
43 G_BEGIN_DECLS
44
45 /**
46  * ECollatorError:
47  * @E_COLLATOR_ERROR_OPEN: An error occured trying to open a collator and access collation data.
48  * @E_COLLATOR_ERROR_CONVERSION: An error occurred converting character encodings
49  * @E_COLLATOR_ERROR_INVALID_LOCALE: A malformed locale name was given to e_collator_new()
50  *
51  * Errors from the #E_COLLATOR_ERROR domain.
52  */
53 typedef enum {
54         E_COLLATOR_ERROR_OPEN,
55         E_COLLATOR_ERROR_CONVERSION,
56         E_COLLATOR_ERROR_INVALID_LOCALE
57 } ECollatorError;
58
59 /**
60  * ECollator:
61  *
62  * An opaque object used for locale specific string comparisons
63  * and sort ordering.
64  *
65  * Since: 3.10
66  */
67 typedef struct _ECollator ECollator;
68
69 GType           e_collator_get_type        (void);
70 GQuark          e_collator_error_quark     (void);
71 ECollator      *e_collator_new             (const gchar     *locale,
72                                             const gchar     *collation_type,
73                                             GError         **error);
74 ECollator      *e_collator_ref             (ECollator       *collator);
75 void            e_collator_unref           (ECollator       *collator);
76 gchar          *e_collator_generate_key    (ECollator       *collator,
77                                             const gchar     *str,
78                                             GError         **error);
79 gboolean        e_collator_collate         (ECollator       *collator,
80                                             const gchar     *str_a,
81                                             const gchar     *str_b,
82                                             gint            *result,
83                                             GError         **error);
84
85 G_END_DECLS
86
87 #endif /* E_COLLATOR_H */