Sha256: 3f588b9d714377d5d729971f032ac8e8b3d9fb1683fca54977898a902149781b

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

#ifndef EXTRALITE_H
#define EXTRALITE_H

#include "ruby.h"
#include "ruby/thread.h"

#ifdef EXTRALITE_NO_BUNDLE
#include <sqlite3.h>
#else
#include "../sqlite3/sqlite3.h"
#endif

// debug utility
#define INSPECT(str, obj) { \
  printf(str); \
  VALUE s = rb_funcall(obj, rb_intern("inspect"), 0); \
  printf(": %s\n", StringValueCStr(s)); \
}

#define SAFE(f) (VALUE (*)(VALUE))(f)

extern VALUE cDatabase;
extern VALUE cPreparedStatement;

extern VALUE cError;
extern VALUE cSQLError;
extern VALUE cBusyError;

extern ID ID_KEYS;
extern ID ID_NEW;
extern ID ID_STRIP;
extern ID ID_TO_S;

typedef struct {
  sqlite3 *sqlite3_db;
} Database_t;

typedef struct {
  VALUE db;
  VALUE sql;
  sqlite3 *sqlite3_db;
  sqlite3_stmt *stmt;
} PreparedStatement_t;

typedef struct {
  VALUE self;
  sqlite3 *sqlite3_db;
  sqlite3_stmt *stmt;
} query_ctx;

VALUE safe_query_ary(query_ctx *ctx);
VALUE safe_query_hash(query_ctx *ctx);
VALUE safe_query_single_column(query_ctx *ctx);
VALUE safe_query_single_row(query_ctx *ctx);
VALUE safe_query_single_value(query_ctx *ctx);

void prepare_single_stmt(sqlite3 *db, sqlite3_stmt **stmt, VALUE sql);
void prepare_multi_stmt(sqlite3 *db, sqlite3_stmt **stmt, VALUE sql);
void bind_all_parameters(sqlite3_stmt *stmt, int argc, VALUE *argv);
VALUE cleanup_stmt(query_ctx *ctx);

sqlite3 *Database_sqlite3_db(VALUE self);

#endif /* EXTRALITE_H */

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
extralite-bundle-1.14 ext/extralite/extralite.h
extralite-1.14 ext/extralite/extralite.h