Compare commits
No commits in common. "v0.5" and "dev" have entirely different histories.
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1 @@
|
|||||||
build
|
*.o
|
||||||
.vscode
|
|
||||||
example
|
|
61
.vscode/settings.json
vendored
Normal file
61
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"string": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
@ -1,69 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
|
||||||
project(SqliteCppWrapper LANGUAGES CXX)
|
|
||||||
|
|
||||||
# Postavi standard za C++
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
# Dodaj glavnu biblioteku
|
|
||||||
add_library(sqlitecpp STATIC
|
|
||||||
src/sqlite3.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Uključi zaglavlja
|
|
||||||
target_include_directories(sqlitecpp
|
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
|
|
||||||
$<INSTALL_INTERFACE:include>
|
|
||||||
)
|
|
||||||
|
|
||||||
# Poveži sa SQLite3
|
|
||||||
find_package(SQLite3 REQUIRED)
|
|
||||||
target_link_libraries(sqlitecpp PRIVATE SQLite::SQLite3)
|
|
||||||
|
|
||||||
# Generiši export fajl za lokalnu upotrebu
|
|
||||||
export(TARGETS sqlitecpp
|
|
||||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/sqlitecppTargets.cmake
|
|
||||||
NAMESPACE sqlitecpp::
|
|
||||||
)
|
|
||||||
|
|
||||||
# Generiši sqlitecppConfig.cmake
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlitecppConfig.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/sqlitecppConfig.cmake
|
|
||||||
INSTALL_DESTINATION lib/cmake/sqlitecpp
|
|
||||||
)
|
|
||||||
|
|
||||||
write_basic_package_version_file(
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/sqlitecppConfigVersion.cmake
|
|
||||||
VERSION 1.0.0
|
|
||||||
COMPATIBILITY SameMajorVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
# Instalacija za lokalnu upotrebu
|
|
||||||
install(TARGETS sqlitecpp
|
|
||||||
EXPORT sqlitecppTargets
|
|
||||||
ARCHIVE DESTINATION lib
|
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
RUNTIME DESTINATION bin
|
|
||||||
)
|
|
||||||
|
|
||||||
install(EXPORT sqlitecppTargets
|
|
||||||
FILE sqlitecppTargets.cmake
|
|
||||||
NAMESPACE sqlitecpp::
|
|
||||||
DESTINATION lib/cmake/sqlitecpp
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/sqlitecppConfig.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/sqlitecppConfigVersion.cmake
|
|
||||||
DESTINATION lib/cmake/sqlitecpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Opcionalno dodaj testove
|
|
||||||
# enable_testing()
|
|
||||||
# add_subdirectory(test)
|
|
||||||
|
|
||||||
add_subdirectory(test)
|
|
@ -54,11 +54,6 @@ And compile your code
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
g++ test.cpp ../src/* -o test.o -l sqlite3
|
g++ test.cpp ../src/* -o test.o -l sqlite3
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(external/sqlitecpp)
|
|
||||||
target_link_libraries(my_project PRIVATE sqlitecpp)
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/sqlitecppTargets.cmake")
|
|
BIN
example/example.db
Normal file
BIN
example/example.db
Normal file
Binary file not shown.
@ -1,6 +0,0 @@
|
|||||||
add_executable(sqlitecpp_test main.cpp)
|
|
||||||
|
|
||||||
target_link_libraries(sqlitecpp_test PRIVATE sqlitecpp SQLite::SQLite3)
|
|
||||||
|
|
||||||
# Dodaj direktorijum za zaglavlja
|
|
||||||
target_include_directories(sqlitecpp_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
|
1
test/compile.sh
Normal file
1
test/compile.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
g++ test.cpp ../src/* -o test.o -l sqlite3
|
@ -1,35 +0,0 @@
|
|||||||
#include "sqlite3.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
try {
|
|
||||||
// Kreiraj instancu SQLite wrapper klase
|
|
||||||
marcelb::SQlite3::SQLite3 db("test.db"); // test.db je naziv baze podataka
|
|
||||||
|
|
||||||
// Izvrši SQL upit za kreiranje tabele
|
|
||||||
db.query("CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT);");
|
|
||||||
|
|
||||||
// Ubaci podatke u tabelu
|
|
||||||
db.query("INSERT INTO test (name) VALUES ('John Doe');");
|
|
||||||
|
|
||||||
// Izvrši SELECT upit i pročitaj podatke
|
|
||||||
auto results = db.query("SELECT id, name FROM test;");
|
|
||||||
|
|
||||||
// Prikaži rezultate
|
|
||||||
for (const auto& row : results) {
|
|
||||||
std::string id = row.first;
|
|
||||||
std::string name = row.second[0];
|
|
||||||
std::cout << "ID: " << id << ", Name: " << name << std::endl;
|
|
||||||
}
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// cmake .. -DCMAKE_BUILD_TYPE=Release
|
|
||||||
// cmake --build . --target sqlitecpp_test
|
|
||||||
// ./test/sqlitecpp_test
|
|
28
test/test.cpp
Normal file
28
test/test.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#include "../lib/sqlite3.hpp"
|
||||||
|
using namespace marcelb::SQlite3;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
SQLite3 mydb("../example/example.db", false);
|
||||||
|
|
||||||
|
auto res = mydb.query("Select * from Tab1");
|
||||||
|
// cout << endl << res["NAME"][1];
|
||||||
|
|
||||||
|
// cout << endl << res["MAIL"][1];
|
||||||
|
|
||||||
|
for (auto i : res) {
|
||||||
|
for (auto j: i.second) {
|
||||||
|
cout << i.first << " : " << j << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (const string err) {
|
||||||
|
cout << err << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user