StructOp Handbook
Contents Examples Commands

Lib sqlite

Console program88 lines of .st193 lines of generated C
Program output
name=apple n=1 (2 columns)
name=fig n=2 (2 columns)
name=pear n=3 (2 columns)
error 1: no such column: nope
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.value.rc
      + ability.value.err
      + ability.sqlite3_open.Open
      + ability.sqlite3_exec.Fill
      + ability.sqlite3_exec.List
      + ability.print.Row
      + ability.sqlite3_exec.Broken
      + ability.if.Failed
      + ability.print.Error
      + ability.sqlite3_close.Close

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    # a folder holding the .st files above
structop init
structop plan
structop apply