1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/storage/src/mozStorageSQLFunctions.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozStorageSQLFunctions_h 1.11 +#define mozStorageSQLFunctions_h 1.12 + 1.13 +#include "sqlite3.h" 1.14 +#include "nscore.h" 1.15 + 1.16 +namespace mozilla { 1.17 +namespace storage { 1.18 + 1.19 +/** 1.20 + * Registers the functions declared here with the specified database. 1.21 + * 1.22 + * @param aDB 1.23 + * The database we'll be registering the functions with. 1.24 + * @return the SQLite status code indicating success or failure. 1.25 + */ 1.26 +NS_HIDDEN_(int) registerFunctions(sqlite3 *aDB); 1.27 + 1.28 +//////////////////////////////////////////////////////////////////////////////// 1.29 +//// Predefined Functions 1.30 + 1.31 +/** 1.32 + * Overridden function to perform the SQL functions UPPER and LOWER. These 1.33 + * support unicode, which the default implementations do not do. 1.34 + * 1.35 + * @param aCtx 1.36 + * The sqlite_context that this function is being called on. 1.37 + * @param aArgc 1.38 + * The number of arguments the function is being called with. 1.39 + * @param aArgv 1.40 + * An array of the arguments the functions is being called with. 1.41 + */ 1.42 +NS_HIDDEN_(void) caseFunction(sqlite3_context *aCtx, 1.43 + int aArgc, 1.44 + sqlite3_value **aArgv); 1.45 + 1.46 +/** 1.47 + * Overridden function to perform the SQL function LIKE. This supports unicode, 1.48 + * which the default implementation does not do. 1.49 + * 1.50 + * @param aCtx 1.51 + * The sqlite_context that this function is being called on. 1.52 + * @param aArgc 1.53 + * The number of arguments the function is being called with. 1.54 + * @param aArgv 1.55 + * An array of the arguments the functions is being called with. 1.56 + */ 1.57 +NS_HIDDEN_(void) likeFunction(sqlite3_context *aCtx, 1.58 + int aArgc, 1.59 + sqlite3_value **aArgv); 1.60 + 1.61 +/** 1.62 + * An implementation of the Levenshtein Edit Distance algorithm for use in 1.63 + * Sqlite queries. 1.64 + * 1.65 + * @param aCtx 1.66 + * The sqlite_context that this function is being called on. 1.67 + * @param aArgc 1.68 + * The number of arguments the function is being called with. 1.69 + * @param aArgv 1.70 + * An array of the arguments the functions is being called with. 1.71 + */ 1.72 +NS_HIDDEN_(void) levenshteinDistanceFunction(sqlite3_context *aCtx, 1.73 + int aArgc, 1.74 + sqlite3_value **aArgv); 1.75 + 1.76 +} // namespace storage 1.77 +} // namespace mozilla 1.78 + 1.79 +#endif // mozStorageSQLFunctions_h