StructOp Handbook
Contents Examples Commands

Lib sqlite function

Console program80 lines of .st200 lines of generated C
Program output
root row
root row
module row, SQLITE_OK is 0
On this page

The .st files#

intent.st
structop {
    type_app {
        exec = {
            lang     = "C"
            standard = "c11"
        }
    }

    lib_provider {
        C_lang = {
            source  = "StructOp/c"
            version = "@latest"
        }
        Db = {
            source  = "C/sqlite3"
            version = "@latest"
        }
    }
}

Input, plan and generated C#

bind/sqlite3.bind.st · hints for structop bind
bind/sqlite3.bind.st · hints for structop bind
bind "sqlite3" {
    header  = "sqlite3.h"
    package = "sqlite3"
    prefix  = ["sqlite3_", "SQLITE_"]
}

function "sqlite3_exec" {
    names     = ["db"]
    out_text  = { errmsg = "sqlite3_free" }
    arg_names = { callback = ["", "count", "values", "columns"] }
}

function "sqlite3_close" {
    names = ["db"]
}
structop plan
structop plan
  # program.app will be created
  + program.app (.structop/build/app)
      + ability.value.db
      + ability.sqlite3_open.Open
      + ability.function.list_rows
      + ability.sqlite3_exec.List
      + ability.print.Row
      + ability.call.Run
      + module.m.ability.value.db
      + module.m.ability.sqlite3_open.Open
      + module.m.ability.function.list_rows
      + module.m.ability.sqlite3_exec.List
      + module.m.ability.print.Row
      + module.m.ability.call.Run

Plan: 1 to add, 0 to change, 0 to destroy.
Generated main.c

To inspect this generated file, select C in intent.st, initialize the project and export its source.

Export locally
structop init
structop apply -source -no-run
Try it
structop bind bind/sqlite3.bind.st    # from the repository root
cd lib-sqlite-function    # a folder holding the .st files above
structop init
structop plan
structop apply