// @generated
// -----------------------------------------------------------------------------
// Auto-generated by tools/c_api_gen/generate_c_api.py.
// DO NOT EDIT THIS FILE DIRECTLY.
// Source: tools/c_api_gen/spec.json
// -----------------------------------------------------------------------------

// To regenerate this file:
//   python3 tools/c_api_gen/generate_c_api.py
//     --spec tools/c_api_gen/spec.json --section 'DB data operations'
//     --section 'WriteBatch' --section 'Transaction'
//     --section 'TransactionDB simple'
//     --header-out
//     c_api_gen/c_generated_subset.h.inc
//     --source-out
//     c_api_gen/c_generated_subset.cc.inc

/* DB data operations */

void rocksdb_put(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                 const char* key, size_t keylen, const char* val, size_t vallen,
                 char** errptr) {
  SaveError(errptr,
            db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen)));
}

void rocksdb_put_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                    rocksdb_column_family_handle_t* column_family,
                    const char* key, size_t keylen, const char* val,
                    size_t vallen, char** errptr) {
  SaveError(errptr, db->rep->Put(options->rep, column_family->rep,
                                 Slice(key, keylen), Slice(val, vallen)));
}

void rocksdb_delete(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                    const char* key, size_t keylen, char** errptr) {
  SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen)));
}

void rocksdb_delete_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                       rocksdb_column_family_handle_t* column_family,
                       const char* key, size_t keylen, char** errptr) {
  SaveError(errptr, db->rep->Delete(options->rep, column_family->rep,
                                    Slice(key, keylen)));
}

void rocksdb_merge(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                   const char* key, size_t keylen, const char* val,
                   size_t vallen, char** errptr) {
  SaveError(errptr, db->rep->Merge(options->rep, Slice(key, keylen),
                                   Slice(val, vallen)));
}

void rocksdb_merge_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                      rocksdb_column_family_handle_t* column_family,
                      const char* key, size_t keylen, const char* val,
                      size_t vallen, char** errptr) {
  SaveError(errptr, db->rep->Merge(options->rep, column_family->rep,
                                   Slice(key, keylen), Slice(val, vallen)));
}

void rocksdb_write(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                   rocksdb_writebatch_t* batch, char** errptr) {
  SaveError(errptr, db->rep->Write(options->rep, &batch->rep));
}

void rocksdb_put_with_ts(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                         const char* key, size_t keylen, const char* ts,
                         size_t tslen, const char* val, size_t vallen,
                         char** errptr) {
  SaveError(errptr, db->rep->Put(options->rep, Slice(key, keylen),
                                 Slice(ts, tslen), Slice(val, vallen)));
}

void rocksdb_put_cf_with_ts(rocksdb_t* db,
                            const rocksdb_writeoptions_t* options,
                            rocksdb_column_family_handle_t* column_family,
                            const char* key, size_t keylen, const char* ts,
                            size_t tslen, const char* val, size_t vallen,
                            char** errptr) {
  SaveError(errptr,
            db->rep->Put(options->rep, column_family->rep, Slice(key, keylen),
                         Slice(ts, tslen), Slice(val, vallen)));
}

void rocksdb_delete_with_ts(rocksdb_t* db,
                            const rocksdb_writeoptions_t* options,
                            const char* key, size_t keylen, const char* ts,
                            size_t tslen, char** errptr) {
  SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen),
                                    Slice(ts, tslen)));
}

void rocksdb_delete_cf_with_ts(rocksdb_t* db,
                               const rocksdb_writeoptions_t* options,
                               rocksdb_column_family_handle_t* column_family,
                               const char* key, size_t keylen, const char* ts,
                               size_t tslen, char** errptr) {
  SaveError(errptr, db->rep->Delete(options->rep, column_family->rep,
                                    Slice(key, keylen), Slice(ts, tslen)));
}

void rocksdb_singledelete(rocksdb_t* db, const rocksdb_writeoptions_t* options,
                          const char* key, size_t keylen, char** errptr) {
  SaveError(errptr, db->rep->SingleDelete(options->rep, Slice(key, keylen)));
}

void rocksdb_singledelete_cf(rocksdb_t* db,
                             const rocksdb_writeoptions_t* options,
                             rocksdb_column_family_handle_t* column_family,
                             const char* key, size_t keylen, char** errptr) {
  SaveError(errptr, db->rep->SingleDelete(options->rep, column_family->rep,
                                          Slice(key, keylen)));
}

void rocksdb_singledelete_with_ts(rocksdb_t* db,
                                  const rocksdb_writeoptions_t* options,
                                  const char* key, size_t keylen,
                                  const char* ts, size_t tslen, char** errptr) {
  SaveError(errptr, db->rep->SingleDelete(options->rep, Slice(key, keylen),
                                          Slice(ts, tslen)));
}

void rocksdb_singledelete_cf_with_ts(
    rocksdb_t* db, const rocksdb_writeoptions_t* options,
    rocksdb_column_family_handle_t* column_family, const char* key,
    size_t keylen, const char* ts, size_t tslen, char** errptr) {
  SaveError(errptr,
            db->rep->SingleDelete(options->rep, column_family->rep,
                                  Slice(key, keylen), Slice(ts, tslen)));
}

void rocksdb_delete_range_cf(rocksdb_t* db,
                             const rocksdb_writeoptions_t* options,
                             rocksdb_column_family_handle_t* column_family,
                             const char* start_key, size_t start_key_len,
                             const char* end_key, size_t end_key_len,
                             char** errptr) {
  SaveError(errptr, db->rep->DeleteRange(options->rep, column_family->rep,
                                         Slice(start_key, start_key_len),
                                         Slice(end_key, end_key_len)));
}

void rocksdb_flush(rocksdb_t* db, const rocksdb_flushoptions_t* options,
                   char** errptr) {
  SaveError(errptr, db->rep->Flush(options->rep));
}

void rocksdb_flush_cf(rocksdb_t* db, const rocksdb_flushoptions_t* options,
                      rocksdb_column_family_handle_t* column_family,
                      char** errptr) {
  SaveError(errptr, db->rep->Flush(options->rep, column_family->rep));
}

void rocksdb_flush_wal(rocksdb_t* db, unsigned char sync, char** errptr) {
  SaveError(errptr, db->rep->FlushWAL(sync));
}

void rocksdb_pause_background_work(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->PauseBackgroundWork());
}

void rocksdb_continue_background_work(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->ContinueBackgroundWork());
}

void rocksdb_disable_file_deletions(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->DisableFileDeletions());
}

void rocksdb_enable_file_deletions(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->EnableFileDeletions());
}

void rocksdb_verify_checksum(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->VerifyChecksum());
}

void rocksdb_verify_file_checksums(rocksdb_t* db, char** errptr) {
  SaveError(errptr, db->rep->VerifyFileChecksums(ReadOptions()));
}

void rocksdb_destroy_db(const rocksdb_options_t* options, const char* name,
                        char** errptr) {
  SaveError(errptr, DestroyDB(name, options->rep));
}

void rocksdb_repair_db(const rocksdb_options_t* options, const char* name,
                       char** errptr) {
  SaveError(errptr, RepairDB(name, options->rep));
}

/* WriteBatch */

void rocksdb_writebatch_clear(rocksdb_writebatch_t* b) { b->rep.Clear(); }

void rocksdb_writebatch_put(rocksdb_writebatch_t* b, const char* key,
                            size_t klen, const char* val, size_t vlen) {
  b->rep.Put(Slice(key, klen), Slice(val, vlen));
}

void rocksdb_writebatch_put_cf(rocksdb_writebatch_t* b,
                               rocksdb_column_family_handle_t* column_family,
                               const char* key, size_t klen, const char* val,
                               size_t vlen) {
  b->rep.Put(column_family->rep, Slice(key, klen), Slice(val, vlen));
}

void rocksdb_writebatch_delete(rocksdb_writebatch_t* b, const char* key,
                               size_t klen) {
  b->rep.Delete(Slice(key, klen));
}

void rocksdb_writebatch_put_log_data(rocksdb_writebatch_t* b, const char* blob,
                                     size_t len) {
  b->rep.PutLogData(Slice(blob, len));
}

void rocksdb_writebatch_set_save_point(rocksdb_writebatch_t* b) {
  b->rep.SetSavePoint();
}

void rocksdb_writebatch_rollback_to_save_point(rocksdb_writebatch_t* b,
                                               char** errptr) {
  SaveError(errptr, b->rep.RollbackToSavePoint());
}

void rocksdb_writebatch_pop_save_point(rocksdb_writebatch_t* b, char** errptr) {
  SaveError(errptr, b->rep.PopSavePoint());
}

void rocksdb_writebatch_verify_checksum(rocksdb_writebatch_t* b,
                                        char** errptr) {
  SaveError(errptr, b->rep.VerifyChecksum());
}

/* Transaction */

void rocksdb_transaction_put(rocksdb_transaction_t* txn, const char* key,
                             size_t klen, const char* val, size_t vlen,
                             char** errptr) {
  SaveError(errptr, txn->rep->Put(Slice(key, klen), Slice(val, vlen)));
}

void rocksdb_transaction_put_cf(rocksdb_transaction_t* txn,
                                rocksdb_column_family_handle_t* column_family,
                                const char* key, size_t klen, const char* val,
                                size_t vlen, char** errptr) {
  SaveError(errptr, txn->rep->Put(column_family->rep, Slice(key, klen),
                                  Slice(val, vlen)));
}

void rocksdb_transaction_merge(rocksdb_transaction_t* txn, const char* key,
                               size_t klen, const char* val, size_t vlen,
                               char** errptr) {
  SaveError(errptr, txn->rep->Merge(Slice(key, klen), Slice(val, vlen)));
}

void rocksdb_transaction_merge_cf(rocksdb_transaction_t* txn,
                                  rocksdb_column_family_handle_t* column_family,
                                  const char* key, size_t klen, const char* val,
                                  size_t vlen, char** errptr) {
  SaveError(errptr, txn->rep->Merge(column_family->rep, Slice(key, klen),
                                    Slice(val, vlen)));
}

void rocksdb_transaction_delete(rocksdb_transaction_t* txn, const char* key,
                                size_t klen, char** errptr) {
  SaveError(errptr, txn->rep->Delete(Slice(key, klen)));
}

void rocksdb_transaction_delete_cf(
    rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family,
    const char* key, size_t klen, char** errptr) {
  SaveError(errptr, txn->rep->Delete(column_family->rep, Slice(key, klen)));
}

void rocksdb_transaction_commit(rocksdb_transaction_t* txn, char** errptr) {
  SaveError(errptr, txn->rep->Commit());
}

void rocksdb_transaction_rollback(rocksdb_transaction_t* txn, char** errptr) {
  SaveError(errptr, txn->rep->Rollback());
}

void rocksdb_transaction_put_log_data(rocksdb_transaction_t* txn,
                                      const char* blob, size_t len) {
  txn->rep->PutLogData(Slice(blob, len));
}

void rocksdb_transaction_set_savepoint(rocksdb_transaction_t* txn) {
  txn->rep->SetSavePoint();
}

void rocksdb_transaction_rollback_to_savepoint(rocksdb_transaction_t* txn,
                                               char** errptr) {
  SaveError(errptr, txn->rep->RollbackToSavePoint());
}

/* TransactionDB simple */

void rocksdb_transactiondb_put(rocksdb_transactiondb_t* txn_db,
                               const rocksdb_writeoptions_t* options,
                               const char* key, size_t klen, const char* val,
                               size_t vlen, char** errptr) {
  SaveError(errptr,
            txn_db->rep->Put(options->rep, Slice(key, klen), Slice(val, vlen)));
}

void rocksdb_transactiondb_put_cf(rocksdb_transactiondb_t* txn_db,
                                  const rocksdb_writeoptions_t* options,
                                  rocksdb_column_family_handle_t* column_family,
                                  const char* key, size_t keylen,
                                  const char* val, size_t vallen,
                                  char** errptr) {
  SaveError(errptr, txn_db->rep->Put(options->rep, column_family->rep,
                                     Slice(key, keylen), Slice(val, vallen)));
}

void rocksdb_transactiondb_write(rocksdb_transactiondb_t* db,
                                 const rocksdb_writeoptions_t* options,
                                 rocksdb_writebatch_t* batch, char** errptr) {
  SaveError(errptr, db->rep->Write(options->rep, &batch->rep));
}

void rocksdb_transactiondb_merge(rocksdb_transactiondb_t* txn_db,
                                 const rocksdb_writeoptions_t* options,
                                 const char* key, size_t klen, const char* val,
                                 size_t vlen, char** errptr) {
  SaveError(errptr, txn_db->rep->Merge(options->rep, Slice(key, klen),
                                       Slice(val, vlen)));
}

void rocksdb_transactiondb_merge_cf(
    rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options,
    rocksdb_column_family_handle_t* column_family, const char* key, size_t klen,
    const char* val, size_t vlen, char** errptr) {
  SaveError(errptr, txn_db->rep->Merge(options->rep, column_family->rep,
                                       Slice(key, klen), Slice(val, vlen)));
}

void rocksdb_transactiondb_delete(rocksdb_transactiondb_t* txn_db,
                                  const rocksdb_writeoptions_t* options,
                                  const char* key, size_t klen, char** errptr) {
  SaveError(errptr, txn_db->rep->Delete(options->rep, Slice(key, klen)));
}

void rocksdb_transactiondb_delete_cf(
    rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options,
    rocksdb_column_family_handle_t* column_family, const char* key,
    size_t keylen, char** errptr) {
  SaveError(errptr, txn_db->rep->Delete(options->rep, column_family->rep,
                                        Slice(key, keylen)));
}

void rocksdb_transactiondb_flush_wal(rocksdb_transactiondb_t* txn_db,
                                     unsigned char sync, char** errptr) {
  SaveError(errptr, txn_db->rep->FlushWAL(sync));
}

void rocksdb_transactiondb_flush(rocksdb_transactiondb_t* txn_db,
                                 const rocksdb_flushoptions_t* options,
                                 char** errptr) {
  SaveError(errptr, txn_db->rep->Flush(options->rep));
}

void rocksdb_transactiondb_flush_cf(
    rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options,
    rocksdb_column_family_handle_t* column_family, char** errptr) {
  SaveError(errptr, txn_db->rep->Flush(options->rep, column_family->rep));
}
