gen

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: ISC Imports: 18 Imported by: 0

Documentation

Overview

Package gen is a generation run for one project: settings.xml and sdm.xml from the sdm folder, metadata from the database <jdbc url>, the result is the texts of DTO and DAO files, in Go, Python or C++ (see LangOf).

Index

Constants

This section is empty.

Variables

View Source
var Langs = []Lang{Go, Python, Cpp}

Langs are the languages; the first is the default.

Functions

func OpenMetadata

func OpenMetadata(projectDir string, j sdmxml.DB) (meta.Metadata, error)

OpenMetadata opens the database of <db url user pwd> (or <jdbc>, for cli/genharness). $PROJECT_DIR$ and ${project_loc} are the project folder, a relative SQLite path is relative to it too.

func Select

func Select(classes []sdmxml.Class, args []string, models, daos bool) (map[string]bool, error)

Select returns class names by numbers (from 1, in the order of declaration, as in sdmc ls) and by names; one argument may hold several, separated by commas. models/daos: models only or DAO only; both or neither mean both kinds. No arguments and no models/daos: nil, all of them.

Types

type Change

type Change struct {
	Path    string // relative to the project, with '/'
	Missing bool   // no file yet
}

Change is a file that generate will write (or validate considers out of date).

func Sync

func Sync(projectDir string, res *Result, write bool) ([]Change, error)

Sync compares the result with the project files and, if write, writes the changed ones. Line endings are not compared: after git with autocrlf a file on Windows may be in CRLF.

type Entry

type Entry struct {
	N int // number, from 1, in the order of declaration
	sdmxml.Class
	Path     string    // relative to the project, with '/'
	Modified time.Time // zero: no file
}

Entry is a class of sdm.xml and its file.

func List

func List(projectDir, sdmDir string) ([]Entry, error)

List returns the classes of sdm.xml in the order of declaration, without the database.

type File

type File struct {
	Class   string
	Name    string // file name
	Content string
	Err     error // the class is not generated
}

type Lang

type Lang string

Lang is the target language of a configuration.

const (
	Go     Lang = "go"
	Python Lang = "python"
	Cpp    Lang = "cpp"
)

func LangOf

func LangOf(sdmDir string) (Lang, error)

LangOf is the language of the sdm folder by its root file, as in the IDE plug-ins: python.dal is Python, cpp.dal is C++. Without them the folder is Go: sdmc never needed go.dal.

func (Lang) OneFolder

func (l Lang) OneFolder() bool

OneFolder: the models and DAO of the language are in one folder, <folders target>.

func (Lang) RootFile

func (l Lang) RootFile() string

RootFile is the root file of the IDE plug-in in the sdm folder: go.dal, python.dal, cpp.dal.

type Progress

type Progress func(n, total int, class string)

Progress is called before generating each class: n-th of total.

type Result

type Result struct {
	DtoDir, DaoDir string // relative to the project, as scope in settings.xml
	Dto, Dao       []File
}

func Run

func Run(projectDir, sdmDir string, md meta.Metadata, only map[string]bool, progress Progress) (*Result, error)

Run generates the DTO and DAO of the project: all of them or only the classes of only (names, see Select). An error of a particular class goes to File.Err, a general error (settings, XML) to error. progress may be nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL