mozStorageSQLFunctions.h (2859B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozStorageSQLFunctions_h 8 #define mozStorageSQLFunctions_h 9 10 #include "sqlite3.h" 11 #include "nscore.h" 12 13 namespace mozilla { 14 namespace storage { 15 16 /** 17 * Registers the functions declared here with the specified database. 18 * 19 * @param aDB 20 * The database we'll be registering the functions with. 21 * @return the SQLite status code indicating success or failure. 22 */ 23 int registerFunctions(sqlite3* aDB); 24 25 //////////////////////////////////////////////////////////////////////////////// 26 //// Predefined Functions 27 28 /** 29 * Overridden function to perform the SQL functions UPPER and LOWER. These 30 * support unicode, which the default implementations do not do. 31 * 32 * @param aCtx 33 * The sqlite_context that this function is being called on. 34 * @param aArgc 35 * The number of arguments the function is being called with. 36 * @param aArgv 37 * An array of the arguments the functions is being called with. 38 */ 39 void caseFunction(sqlite3_context* aCtx, int aArgc, sqlite3_value** aArgv); 40 41 /** 42 * Overridden function to perform the SQL function LIKE. This supports unicode, 43 * which the default implementation does not do. 44 * 45 * @param aCtx 46 * The sqlite_context that this function is being called on. 47 * @param aArgc 48 * The number of arguments the function is being called with. 49 * @param aArgv 50 * An array of the arguments the functions is being called with. 51 */ 52 void likeFunction(sqlite3_context* aCtx, int aArgc, sqlite3_value** aArgv); 53 54 /** 55 * An implementation of the Levenshtein Edit Distance algorithm for use in 56 * Sqlite queries. 57 * 58 * @param aCtx 59 * The sqlite_context that this function is being called on. 60 * @param aArgc 61 * The number of arguments the function is being called with. 62 * @param aArgv 63 * An array of the arguments the functions is being called with. 64 */ 65 void levenshteinDistanceFunction(sqlite3_context* aCtx, int aArgc, 66 sqlite3_value** aArgv); 67 68 /** 69 * An alternative string length function that uses XPCOM string classes for 70 * string length calculation. 71 * 72 * @param aCtx 73 * The sqlite_context that this function is being called on. 74 * @param aArgc 75 * The number of arguments the function is being called with. 76 * @param aArgv 77 * An array of the arguments the functions is being called with. 78 */ 79 void utf16LengthFunction(sqlite3_context* aCtx, int aArgc, 80 sqlite3_value** aArgv); 81 82 } // namespace storage 83 } // namespace mozilla 84 85 #endif // mozStorageSQLFunctions_h