| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Typesafe composition of SQL query strings. | 5 // Typesafe composition of SQL query strings. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ | 7 #ifndef CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ |
| 8 #define CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ | 8 #define CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void GetColumn(sqlite3_stmt*, int index, double* value); | 42 void GetColumn(sqlite3_stmt*, int index, double* value); |
| 43 void GetColumn(sqlite3_stmt*, int index, bool* value); | 43 void GetColumn(sqlite3_stmt*, int index, bool* value); |
| 44 void GetColumn(sqlite3_stmt*, int index, std::vector<uint8>* value); | 44 void GetColumn(sqlite3_stmt*, int index, std::vector<uint8>* value); |
| 45 | 45 |
| 46 bool DoesTableExist(sqlite3* dbhandle, const std::string& tablename); | 46 bool DoesTableExist(sqlite3* dbhandle, const std::string& tablename); |
| 47 | 47 |
| 48 // Prepares a query with a WHERE clause that filters the values by the items | 48 // Prepares a query with a WHERE clause that filters the values by the items |
| 49 // passed inside of the Vector. | 49 // passed inside of the Vector. |
| 50 // Example: | 50 // Example: |
| 51 // | 51 // |
| 52 // vector<PathString> v; | 52 // vector<std::string> v; |
| 53 // v.push_back("abc"); | 53 // v.push_back("abc"); |
| 54 // v.push_back("123"); | 54 // v.push_back("123"); |
| 55 // PrepareQuery(dbhandle, "SELECT * FROM table", "column_name", v.begin(), | 55 // PrepareQuery(dbhandle, "SELECT * FROM table", "column_name", v.begin(), |
| 56 // v.end(), "ORDER BY id"); | 56 // v.end(), "ORDER BY id"); |
| 57 // | 57 // |
| 58 // will produce the following query. | 58 // will produce the following query. |
| 59 // | 59 // |
| 60 // SELECT * FROM table WHERE column_name = 'abc' OR column_name = '123' ORDER BY | 60 // SELECT * FROM table WHERE column_name = 'abc' OR column_name = '123' ORDER BY |
| 61 // id. | 61 // id. |
| 62 // | 62 // |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 680 |
| 681 DISALLOW_COPY_AND_ASSIGN(ScopedStatementResetter); | 681 DISALLOW_COPY_AND_ASSIGN(ScopedStatementResetter); |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 // Useful for encoding any sequence of bytes into a string that can be used in | 684 // Useful for encoding any sequence of bytes into a string that can be used in |
| 685 // a table name. Kind of like hex encoding, except that A is zero and P is 15. | 685 // a table name. Kind of like hex encoding, except that A is zero and P is 15. |
| 686 std::string APEncode(const std::string& in); | 686 std::string APEncode(const std::string& in); |
| 687 std::string APDecode(const std::string& in); | 687 std::string APDecode(const std::string& in); |
| 688 | 688 |
| 689 #endif // CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ | 689 #endif // CHROME_BROWSER_SYNC_UTIL_QUERY_HELPERS_H_ |
| OLD | NEW |