tizen 2.3 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  * @addtogroup DB_UTIL
33  * @{
34  */
35
36 /*
37  * @brief Collations Types
38  *
39  * These types are intended for use in the
40  * 2nd parameter to the [db_util_create_collation()] interface.
41  * The meanings of the various types is shown below.
42  *
43  * [DB_UTIL_COL_UCA]
44  * Unicode Collation Algorithm / Locale InSensitive / Accent Sensitive / Case Insensitive
45  * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
46  *
47  * [DB_UTIL_COL_LS_AS_CI]
48  * Locale Sensitive / Accent Sensitive / Case Insensitive
49  * This type will be mostly used in 'ORDER BY' clause of sql for sorted list.
50  *
51  * [DB_UTIL_COL_LS_AI_CI]
52  * Locale Sensitive / Accent Insensitive / Case Insensitive
53  * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
54
55  * [DB_UTIL_COL_LS_AI_CI_LC]
56  * Locale Sensitive / Accent Insensitive / Loop Comparison
57  * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
58  *
59  * [DB_UTIL_COL_KR_IC]  ##deprecated
60  * Locale Sensitive / Korea / Initial(leading) Consonant
61  * Compares string data using initial(leading) consonant for korea locale.
62  * This type will be mostly used for '=' operator comparison in 'WHERE' clause.
63  *
64  * [DB_UTIL_COL_KR_IC_LC] ##deprecated
65  * Locale Sensitive / Korea / Initial(leading) Consonant / Loop Comparison
66  * Compares string data using initial(leading) consonant for korea locale.
67  * This type will be mostly used for 'LIKE' operator comparison in 'WHERE' clause.
68  */
69
70 typedef enum {
71         DB_UTIL_COL_UCA,    /**< */
72         DB_UTIL_COL_LS_AS_CI,   /**< */
73         DB_UTIL_COL_LS_AI_CI,   /**< */
74         DB_UTIL_COL_LS_AI_CI_LC,    /**< */
75         DB_UTIL_COL_KO_IC,  //deprecated
76         DB_UTIL_COL_KO_IC_LC    //deprecated
77 } db_util_collate_type;
78
79 /*
80  * @brief Text Encodings
81  *
82  * These encodings are intended for use in the
83  * 3rd parameter to the [db_util_create_collation()] interface.
84  */
85 typedef enum {
86         DB_UTIL_COL_UTF8 = SQLITE_UTF8, /**< */
87         DB_UTIL_COL_UTF16 = SQLITE_UTF16    /**< */
88 } db_util_collate_textrep;
89
90 /**
91  * @brief This function defines a new collating sequences with the database connection specified as the firtst argument.
92  * @remarks This function is needed to be invoked after [db_util_open()].
93  * @param [in] Db connection handle to create collation with
94  * @param [in] Collation type. This value must be one of the [db_util_collate_type]
95  * @param [in] Encoding of text passed to the collating function callback
96  * @param [in] The name of collation(UTF-8 string)
97  * @return This function returns #DB_UTIL_OK or error code on failure
98  * @pre       Database connected
99  * @post      None
100  */
101 EXPORT_API int db_util_create_collation(
102         PARAM_IN sqlite3 *db_handle,
103         PARAM_IN db_util_collate_type type,
104         PARAM_IN db_util_collate_textrep text_type,
105         PARAM_IN char* col_name
106 );
107
108 /**
109  * @}
110  */
111
112 #ifdef __cplusplus
113 }
114 #endif
115 #endif  /*      __DBUTIL_COLLATION_H__  */