@@ -7,41 +7,41 @@ using namespace sqlite;
7
7
8
8
int main () {
9
9
10
- try {
11
- database db (" :memory:" );
12
- db << " CREATE TABLE tbl (id integer,age integer, name string, img blob);" ;
13
- db << " INSERT INTO tbl VALUES (?, ?, ?, ?);" << 1 << 24 << " bob" << vector<int > { 1 , 2 , 3 };
10
+ try {
11
+ database db (" :memory:" );
12
+ db << " CREATE TABLE tbl (id integer,age integer, name string, img blob);" ;
13
+ db << " INSERT INTO tbl VALUES (?, ?, ?, ?);" << 1 << 24 << " bob" << vector<int > { 1 , 2 , 3 };
14
14
unique_ptr<string> ptr_null;
15
- db << " INSERT INTO tbl VALUES (?, ?, ?, ?);" << 2 << nullptr << ptr_null << nullptr ;
15
+ db << " INSERT INTO tbl VALUES (?, ?, ?, ?);" << 2 << nullptr << ptr_null << nullptr ;
16
16
17
- db << " select age,name,img from tbl where id = 1" >> [](unique_ptr<int > age_p, unique_ptr<string> name_p, unique_ptr<vector<int >> img_p) {
17
+ db << " select age,name,img from tbl where id = 1" >> [](unique_ptr<int > age_p, unique_ptr<string> name_p, unique_ptr<vector<int >> img_p) {
18
18
if (age_p == nullptr || name_p == nullptr || img_p == nullptr ) {
19
19
cerr << " ERROR: values should not be null" << std::endl;
20
20
exit (EXIT_FAILURE);
21
21
}
22
22
23
23
cout << " age:" << *age_p << " name:" << *name_p << " img:" ;
24
24
for (auto i : *img_p) cout << i << " ," ; cout << endl;
25
- };
25
+ };
26
26
27
- db << " select age,name,img from tbl where id = 2" >> [](unique_ptr<int > age_p, unique_ptr<string> name_p, unique_ptr<vector<int >> img_p) {
27
+ db << " select age,name,img from tbl where id = 2" >> [](unique_ptr<int > age_p, unique_ptr<string> name_p, unique_ptr<vector<int >> img_p) {
28
28
if (age_p != nullptr || name_p != nullptr || img_p != nullptr ) {
29
29
cerr << " ERROR: values should be nullptr" << std::endl;
30
30
exit (EXIT_FAILURE);
31
31
}
32
32
33
33
cout << " OK all three values are nullptr" << endl;
34
- };
35
-
36
- } catch (sqlite_exception e) {
37
- cout << " Sqlite error " << e.what () << endl;
38
- exit (EXIT_FAILURE);
39
- } catch (...) {
40
- cout << " Unknown error\n " ;
41
- exit (EXIT_FAILURE);
42
- }
43
-
44
- cout << " OK\n " ;
45
- exit (EXIT_SUCCESS);
34
+ };
35
+
36
+ } catch (sqlite_exception e) {
37
+ cout << " Sqlite error " << e.what () << endl;
38
+ exit (EXIT_FAILURE);
39
+ } catch (...) {
40
+ cout << " Unknown error\n " ;
41
+ exit (EXIT_FAILURE);
42
+ }
43
+
44
+ cout << " OK\n " ;
45
+ exit (EXIT_SUCCESS);
46
46
return 0 ;
47
47
}
0 commit comments