Skip to content

Commit ca117be

Browse files
author
Edward Rosten
committed
Created normal autoconf based installer.
The usual method now works: ./configure && make && make install Though make doesn't actually do anything, it's still header only and you can just point your compiler at the source drectory if you wish. Also updated the documentation.
1 parent f3c99b8 commit ca117be

File tree

13 files changed

+4698
-18
lines changed

13 files changed

+4698
-18
lines changed

Makefile

Lines changed: 0 additions & 7 deletions
This file was deleted.

Makefile.in

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Standard boilerplate
2+
prefix = @prefix@
3+
exec_prefix = @exec_prefix@
4+
mandir = @mandir@
5+
includedir = @includedir@
6+
datarootdir = @datarootdir@
7+
pkgconfig = @PKGCONFIG_LIBDIR@
8+
9+
ifneq "$(DESTDIR)" ""
10+
DESTDIR+=/
11+
endif
12+
13+
CXX=@CXX@
14+
CXXFLAGS=@CXXFLAGS@ -I hdr/
15+
LDFLAGS=@LDFLAGS@ @LIBS@
16+
17+
hdr = $(DESTDIR)$(includedir)/
18+
19+
20+
.PHONY: all clean testclean
21+
22+
all:
23+
@echo There is nothing to be compiled.
24+
@echo It is now ready to be installed.
25+
26+
install:
27+
mkdir -p $(hdr)/sqlite_modern_cpp
28+
cp -r hdr/* $(hdr)/
29+
[ "$(pkgconfig)" = "" ] || mkdir -p $(DESTDIR)$(pkgconfig)
30+
[ "$(pkgconfig)" = "" ] || cp sqlite_modern_cpp.pc $(DESTDIR)$(pkgconfig)/
31+
32+
clean:
33+
rm -f src/*.o src/test
34+
35+
src/test: src/test.o
36+
$(CXX) -o $@ $^ $(LDFLAGS)

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This library is a lightweight modern wrapper around sqlite C api .
55

66
```c++
77
#include<iostream>
8-
#include "sqlite_modern_cpp.h"
8+
#include <sqlite_modern_cpp.h>
99
using namespace sqlite;
1010
using namespace std;
1111

@@ -35,13 +35,16 @@ int main() {
3535
<< 20
3636
<< u"bob"
3737
<< 83.25;
38-
39-
cout << "The new record got assigned id " << db.last_insert_rowid() << endl;
4038

39+
int age = 21;
40+
float weight = 68.5;
41+
string name = "jack";
4142
db << u"insert into user (age,name,weight) values (?,?,?);" // utf16 query string
42-
<< 21
43-
<< "jack"
44-
<< 68.5;
43+
<< age
44+
<< name
45+
<< weight;
46+
47+
cout << "The new record got assigned id " << db.last_insert_rowid() << endl;
4548

4649
// slects from user table on a condition ( age > 18 ) and executes
4750
// the lambda for each row returned .
@@ -57,6 +60,10 @@ int main() {
5760
db << "select count(*) from user" >> count;
5861
cout << "cout : " << count << endl;
5962

63+
// you can also extract multiple column rows
64+
db << "select age, name from user where _id=1;" >> tie(age, name);
65+
cout << "Age = " << age << ", name = " << name << endl;
66+
6067
// this also works and the returned value will be automatically converted to string
6168
string str_count;
6269
db << "select count(*) from user" >> str_count;
@@ -100,8 +107,8 @@ If you have databases where some rows may be null, you can use boost::optional t
100107

101108
```c++
102109

103-
#include "sqlite_modern_cpp.h"
104-
#include "extensions/boost_optional.h"
110+
#include <sqlite_modern_cpp.h>
111+
#include <sqlite_modern_cpp/extensions/boost_optional.h>
105112

106113
struct User {
107114
long long _id;
@@ -150,9 +157,26 @@ If you have databases where some rows may be null, you can use boost::optional t
150157
}
151158
```
152159
160+
Errors
161+
=====
162+
163+
On error, the library throws an error class indicating the type of error. The error classes are derived from the SQLITE3 error names, so if the error code is SQLITE_CONSTRAINT, the error class thrown is sqlite::exceptions::constraint. Note that all errors are derived from sqlite::sqlite_exception and that itself is derived from std::runtime_exception.
153164
154165
*node: for NDK use the full path to your database file : `sqlite::database db("/data/data/com.your.package/dbfile.db")`*.
155166
167+
Building and Installing
168+
=====
169+
170+
The usual way works for installing:
171+
172+
```bash
173+
./configure && make && sudo make install
174+
175+
```
176+
177+
Note, there's nothing to make, so you there's no need to run configure and you can simply point your compiler at the hdr/ directory.
178+
179+
156180
##License
157181

158182
MIT license - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)

0 commit comments

Comments
 (0)