데이터베이스 관리 헤더 파일 더 자세히 ...
#include <SQLiteCpp/SQLiteCpp.h>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "hash.hpp"
클래스 | |
struct | Detection |
감지 이미지와 타임스탬프를 저장하는 구조체 더 자세히 ... | |
struct | CrossLine |
감지선 정보를 저장하는 구조체 더 자세히 ... | |
struct | BaseLine |
기준선 좌표 정보를 저장하는 구조체 더 자세히 ... | |
struct | VerticalLineEquation |
수직선 방정식(ax+b=0) 정보를 저장하는 구조체 더 자세히 ... | |
struct | Account |
사용자 계정 정보를 저장하는 구조체 더 자세히 ... | |
struct | RecoveryCode |
복구 코드 정보를 저장하는 구조체 더 자세히 ... | |
함수 | |
void | create_table_detections (SQLite::Database &db) |
Detections 테이블을 생성합니다. | |
bool | insert_data_detections (SQLite::Database &db, Detection detection) |
Detections 테이블에 데이터를 삽입합니다. | |
std::vector< Detection > | select_data_for_timestamp_range_detections (SQLite::Database &db, std::string startTimestamp, std::string endTimestamp) |
주어진 시간 범위 내의 Detection 데이터를 조회합니다. | |
void | delete_all_data_detections (SQLite::Database &db) |
Detections 테이블의 모든 데이터를 삭제합니다. | |
void | create_table_lines (SQLite::Database &db) |
Lines 테이블을 생성합니다. | |
bool | insert_data_lines (SQLite::Database &db, CrossLine crossLine) |
Lines 테이블에 데이터를 삽입합니다. | |
std::vector< CrossLine > | select_all_data_lines (SQLite::Database &db) |
Lines 테이블의 모든 데이터를 조회합니다. | |
bool | delete_data_lines (SQLite::Database &db, int indexNum) |
Lines 테이블에서 특정 인덱스의 데이터를 삭제합니다. | |
bool | delete_all_data_lines (SQLite::Database &db) |
Lines 테이블의 모든 데이터를 삭제합니다. | |
void | create_table_baseLines (SQLite::Database &db) |
baseLines 테이블을 생성합니다. | |
std::vector< BaseLine > | select_all_data_baseLines (SQLite::Database &db) |
baseLines 테이블의 모든 데이터를 조회합니다. | |
bool | insert_data_baseLines (SQLite::Database &db, BaseLine baseline) |
baseLines 테이블에 데이터를 삽입합니다. | |
bool | update_data_baseLines (SQLite::Database &db, BaseLine baseline) |
baseLines 테이블의 데이터를 수정합니다. | |
bool | delete_all_data_baseLines (SQLite::Database &db) |
baseLines 테이블의 모든 데이터를 삭제합니다. | |
void | create_table_verticalLineEquations (SQLite::Database &db) |
verticalLineEquations 테이블을 생성합니다. | |
VerticalLineEquation | select_data_verticalLineEquations (SQLite::Database &db, int index) |
verticalLineEquations 테이블에서 특정 인덱스의 데이터를 조회합니다. | |
bool | insert_data_verticalLineEquations (SQLite::Database &db, VerticalLineEquation verticalLineEquation) |
verticalLineEquations 테이블에 데이터를 삽입합니다. | |
bool | delete_all_data_verticalLineEquations (SQLite::Database &db) |
verticalLineEquations 테이블의 모든 데이터를 삭제합니다. | |
void | create_table_accounts (SQLite::Database &db) |
accounts 테이블을 생성합니다. | |
Account * | select_data_accounts (SQLite::Database &db, std::string id, std::string passwd) |
accounts 테이블에서 id와 passwd로 계정 정보를 조회합니다. | |
bool | insert_data_accounts (SQLite::Database &db, Account account) |
accounts 테이블에 계정 정보를 삽입합니다. | |
Account * | get_account_by_id (SQLite::Database &db, const std::string &id) |
accounts 테이블에서 id로 계정 정보를 조회합니다. | |
void | create_table_recovery_codes (SQLite::Database &db) |
recovery_codes 테이블을 생성합니다. | |
bool | store_otp_secret (SQLite::Database &db, const std::string &id, const std::string &secret) |
accounts 테이블에 OTP 시크릿을 저장합니다. | |
bool | store_recovery_codes (SQLite::Database &db, const std::string &id, const std::vector< std::string > &codes) |
recovery_codes 테이블에 복구 코드를 저장합니다. | |
bool | verify_recovery_code (SQLite::Database &db, const std::string &id, const std::string &code) |
입력한 복구 코드가 DB에 저장된 해시와 일치하는지 검증합니다. | |
bool | invalidate_recovery_code (SQLite::Database &db, const std::string &id, const std::string &code) |
입력한 복구 코드가 일치하면 해당 코드를 used=1로 무효화합니다. | |
std::vector< std::string > | get_hashed_recovery_codes (SQLite::Database &db, const std::string &id) |
recovery_codes 테이블에서 사용되지 않은 해시 복구 코드 목록을 조회합니다. | |
데이터베이스 관리 헤더 파일
이 파일은 SQLite 데이터베이스와 상호작용하는 함수와 구조체의 선언을 포함합니다.
void create_table_accounts | ( | SQLite::Database & | db | ) |
accounts 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
void create_table_baseLines | ( | SQLite::Database & | db | ) |
baseLines 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
void create_table_detections | ( | SQLite::Database & | db | ) |
Detections 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
void create_table_lines | ( | SQLite::Database & | db | ) |
Lines 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
이 함수는 Lines 테이블을 생성하며, 테이블이 이미 존재하면 아무 작업도 수행하지 않습니다.
db | SQLite 데이터베이스 참조 |
void create_table_recovery_codes | ( | SQLite::Database & | db | ) |
recovery_codes 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
void create_table_verticalLineEquations | ( | SQLite::Database & | db | ) |
verticalLineEquations 테이블을 생성합니다.
db | SQLite 데이터베이스 참조 |
bool delete_all_data_baseLines | ( | SQLite::Database & | db | ) |
baseLines 테이블의 모든 데이터를 삭제합니다.
db | SQLite 데이터베이스 참조 |
void delete_all_data_detections | ( | SQLite::Database & | db | ) |
Detections 테이블의 모든 데이터를 삭제합니다.
db | SQLite 데이터베이스 참조 |
bool delete_all_data_lines | ( | SQLite::Database & | db | ) |
Lines 테이블의 모든 데이터를 삭제합니다.
db | SQLite 데이터베이스 참조 |
bool delete_all_data_verticalLineEquations | ( | SQLite::Database & | db | ) |
verticalLineEquations 테이블의 모든 데이터를 삭제합니다.
db | SQLite 데이터베이스 참조 |
bool delete_data_lines | ( | SQLite::Database & | db, |
int | indexNum | ||
) |
Lines 테이블에서 특정 인덱스의 데이터를 삭제합니다.
db | SQLite 데이터베이스 참조 |
indexNum | 삭제할 인덱스 번호 |
Account * get_account_by_id | ( | SQLite::Database & | db, |
const std::string & | id | ||
) |
std::vector< std::string > get_hashed_recovery_codes | ( | SQLite::Database & | db, |
const std::string & | id | ||
) |
recovery_codes 테이블에서 사용되지 않은 해시 복구 코드 목록을 조회합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
bool insert_data_accounts | ( | SQLite::Database & | db, |
Account | account | ||
) |
bool insert_data_baseLines | ( | SQLite::Database & | db, |
BaseLine | baseLine | ||
) |
bool insert_data_detections | ( | SQLite::Database & | db, |
Detection | detection | ||
) |
bool insert_data_lines | ( | SQLite::Database & | db, |
CrossLine | crossLine | ||
) |
bool insert_data_verticalLineEquations | ( | SQLite::Database & | db, |
VerticalLineEquation | verticalLineEquation | ||
) |
verticalLineEquations 테이블에 데이터를 삽입합니다.
db | SQLite 데이터베이스 참조 |
verticalLineEquation | 삽입할 VerticalLineEquation 구조체 |
bool invalidate_recovery_code | ( | SQLite::Database & | db, |
const std::string & | id, | ||
const std::string & | code | ||
) |
입력한 복구 코드가 일치하면 해당 코드를 used=1로 무효화합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
code | 입력한 복구 코드 |
std::vector< BaseLine > select_all_data_baseLines | ( | SQLite::Database & | db | ) |
std::vector< CrossLine > select_all_data_lines | ( | SQLite::Database & | db | ) |
Account * select_data_accounts | ( | SQLite::Database & | db, |
std::string | id, | ||
std::string | passwd | ||
) |
accounts 테이블에서 id와 passwd로 계정 정보를 조회합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
passwd | 사용자 비밀번호 |
std::vector< Detection > select_data_for_timestamp_range_detections | ( | SQLite::Database & | db, |
std::string | startTimestamp, | ||
std::string | endTimestamp | ||
) |
VerticalLineEquation select_data_verticalLineEquations | ( | SQLite::Database & | db, |
int | index | ||
) |
verticalLineEquations 테이블에서 특정 인덱스의 데이터를 조회합니다.
db | SQLite 데이터베이스 참조 |
index | 조회할 인덱스 |
bool store_otp_secret | ( | SQLite::Database & | db, |
const std::string & | id, | ||
const std::string & | secret | ||
) |
accounts 테이블에 OTP 시크릿을 저장합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
secret | 저장할 OTP 시크릿 |
bool store_recovery_codes | ( | SQLite::Database & | db, |
const std::string & | id, | ||
const std::vector< std::string > & | codes | ||
) |
recovery_codes 테이블에 복구 코드를 저장합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
codes | 저장할 복구 코드 벡터 |
bool update_data_baseLines | ( | SQLite::Database & | db, |
BaseLine | baseLine | ||
) |
bool verify_recovery_code | ( | SQLite::Database & | db, |
const std::string & | id, | ||
const std::string & | input | ||
) |
입력한 복구 코드가 DB에 저장된 해시와 일치하는지 검증합니다.
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
code | 입력한 복구 코드 |
db | SQLite 데이터베이스 참조 |
id | 사용자 ID |
input | 입력한 복구 코드 |