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