@@ -7,41 +7,41 @@ using namespace sqlite;
77
88int main () {
99
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 };
1414 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 ;
1616
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) {
1818 if (age_p == nullptr || name_p == nullptr || img_p == nullptr ) {
1919 cerr << " ERROR: values should not be null" << std::endl;
2020 exit (EXIT_FAILURE);
2121 }
2222
2323 cout << " age:" << *age_p << " name:" << *name_p << " img:" ;
2424 for (auto i : *img_p) cout << i << " ," ; cout << endl;
25- };
25+ };
2626
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) {
2828 if (age_p != nullptr || name_p != nullptr || img_p != nullptr ) {
2929 cerr << " ERROR: values should be nullptr" << std::endl;
3030 exit (EXIT_FAILURE);
3131 }
3232
3333 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);
4646 return 0 ;
4747}
0 commit comments