Tizen 2.0 Release
[framework/appfw/libslp-db-util.git] / include / collation.h
1 /*
2  * libslp-db-util
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __DBUTIL_COLLATION_H__
23 #define __DBUTIL_COLLATION_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <db-util-common.h>
30
31 /*
32  * Collations Types
33  *
34  * These types are intended for use in the
35  * 2nd parameter to the [db_util_create_collation()] interface.
36  * The meanings of the various types is shown below.
37  *
38  * [DB_UTIL_COL_UCA]
39  * Unicode Collation Algorithm / Locale InSensitive / Accent Sensitive / Case Insensitive
40  * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
41  *
42  * [DB_UTIL_COL_LS_AS_CI]
43  * Locale Sensitive / Accent Sensitive / Case Insensitive
44  * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
45  *
46  * [DB_UTIL_COL_LS_AI_CI]
47  * Locale Sensitive / Accent Insensitive / Case Insensitive
48  * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
49
50  * [DB_UTIL_COL_LS_AI_CI_LC]
51  * Locale Sensitive / Accent Insensitive / Loop Comparison
52  * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
53  *
54  * [DB_UTIL_COL_KR_IC]
55  * Locale Sensitive / Korea / Initial(leading) Consonant
56  * Compares string data using initial(leading) consonant for korea locale.
57  * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
58  *
59  * [DB_UTIL_COL_KR_IC_LC]
60  * Locale Sensitive / Korea / Initial(leading) Consonant / Loop Comparison
61  * Compares string data using initial(leading) consonant for korea locale.
62  * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
63  */
64
65 typedef enum {
66         DB_UTIL_COL_UCA,
67         DB_UTIL_COL_LS_AS_CI,
68         DB_UTIL_COL_LS_AI_CI,
69         DB_UTIL_COL_LS_AI_CI_LC,
70         DB_UTIL_COL_KO_IC,
71         DB_UTIL_COL_KO_IC_LC
72 } db_util_collate_type;
73
74 /*
75  * Text Encodings
76  *
77  * These encodings are intended for use in the
78  * 3rd parameter to the [db_util_create_collation()] interface.
79  */
80 typedef enum {
81         DB_UTIL_COL_UTF8 = SQLITE_UTF8,
82         DB_UTIL_COL_UTF16 = SQLITE_UTF16
83 } db_util_collate_textrep;
84
85
86 /**
87  * @defgroup DB_UTIL
88  * @ingroup StorageFW
89  * @{
90  */
91
92 /**
93  * @fn int  db_util_create_collation(sqlite3 *db_handle, db_util_collate_type type, db_util_collate_textrep text_type, char* col_name);
94  * This function defines a new collating sequences with the database connection specified as the firtst argument.
95  * This function is needed to be invoked after [db_util_open()].
96  *
97  * @param[in] Db connection handle to create collation with
98  * @param[in] Collation type. This value must be one of the [db_util_collate_type]
99  * @param[in] Encoding of text passed to the collating function callback
100  * @param[in] The name of collation(UTF-8 string)
101  * return     This function returns DB_UTIL_OK or error code on failure
102  * @exception None
103  * @remarks   None
104  * @pre       Database connected
105  * @post      None
106  * @code
107  */
108 EXPORT_API int db_util_create_collation(
109         PARAM_IN sqlite3 *db_handle,
110         PARAM_IN db_util_collate_type type,
111         PARAM_IN db_util_collate_textrep text_type,
112         PARAM_IN char* col_name
113 );
114
115 /**
116 *@}
117 */
118
119 #ifdef __cplusplus
120 }
121 #endif
122 #endif  /*      __DBUTIL_COLLATION_H__  */