MCPcopy Create free account
hub / github.com/acl-dev/acl / next

Method next

lib_acl_cpp/src/db/db_sqlite.cpp:933–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931}
932
933bool db_sqlite::next(sqlite_cursor& cursor, bool* done)
934{
935 cursor.clear();
936
937 if (done) {
938 *done = false;
939 }
940
941 int ret = __sqlite3_step(cursor.stmt_);
942 switch (ret) {
943 case SQLITE_DONE:
944 if (done) {
945 *done = true;
946 }
947 return true;
948 case SQLITE_BUSY:
949 logger_error("SQLITE_BUSY now, error=%s", get_error());
950 return false;
951 case SQLITE_ERROR:
952 logger_error("SQLITE_BUSY now, error=%s", get_error());
953 return false;
954 case SQLITE_ROW:
955 break;
956 default:
957 logger_error("unknown type=%d, error=%s", ret, get_error());
958 return false;
959 }
960
961 int columns = __sqlite3_data_count(cursor.stmt_);
962 if (columns != (int) cursor.names_.size()) {
963 logger_error("invalid columns=%d, names count=%d",
964 columns, (int) cursor.names_.size());
965 return false;
966 }
967
968 for (int i = 0; i < columns; i++) {
969 int type = __sqlite3_column_type(cursor.stmt_, i);
970 long long i64;
971 double ifloat;
972 const unsigned char* itxt;
973
974 switch (type) {
975 case SQLITE_INTEGER:
976 i64 = __sqlite3_column_int64(cursor.stmt_, i);
977 cursor.add_column_value(i64);
978 break;
979 case SQLITE_FLOAT:
980 ifloat = __sqlite3_column_double(cursor.stmt_, i);
981 cursor.add_column_value(ifloat);
982 break;
983 case SQLITE_TEXT:
984 itxt = __sqlite3_column_text(cursor.stmt_, i);
985 cursor.add_column_value((const char*) itxt);
986 break;
987 default:
988 logger_warn("not support type=%d", type);
989 break;
990 }

Callers 4

scan_rmdirFunction · 0.45
ls_allFunction · 0.45
do_cmpFunction · 0.45
do_copyFunction · 0.45

Calls 4

add_column_valueMethod · 0.80
get_errorFunction · 0.50
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected