dctx

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

DCTX Reader

Reads Clarion database dictionary (DCTX) files and extracts database schema information.

Overview

The DCTX Reader parses Clarion dictionary files (.dctx) that define database structures in the Clarion development system and converts them into RelSpec's internal database model representation.

Features

  • Parses Clarion DCTX XML format
  • Extracts file (table) and field (column) definitions
  • Supports Clarion data types
  • Handles keys (indexes) and relationships

Usage

Basic Example
package main

import (
    "fmt"
    "git.warky.dev/wdevs/relspecgo/pkg/readers"
    "git.warky.dev/wdevs/relspecgo/pkg/readers/dctx"
)

func main() {
    options := &readers.ReaderOptions{
        FilePath: "/path/to/database.dctx",
    }

    reader := dctx.NewReader(options)
    db, err := reader.ReadDatabase()
    if err != nil {
        panic(err)
    }

    fmt.Printf("Found %d schemas\n", len(db.Schemas))
}
CLI Example
# Read DCTX file and convert to JSON
relspec --input dctx --in-file legacy.dctx --output json --out-file schema.json

# Convert DCTX to GORM models for migration
relspec --input dctx --in-file app.dctx --output gorm --out-file models.go

# Export DCTX to PostgreSQL DDL
relspec --input dctx --in-file database.dctx --output pgsql --out-file schema.sql

Example DCTX Structure

DCTX files are XML-based Clarion dictionary files that define:

  • Files (equivalent to tables)
  • Fields (columns) with Clarion-specific types
  • Keys (indexes)
  • Relationships between files

Common Clarion data types:

  • STRING - Fixed-length string
  • CSTRING - C-style null-terminated string
  • LONG - 32-bit integer
  • SHORT - 16-bit integer
  • DECIMAL - Decimal number
  • REAL - Floating point
  • DATE - Date field
  • TIME - Time field

Type Mapping

The reader automatically maps Clarion data types to standard SQL types:

Clarion Type SQL Type
STRING VARCHAR
CSTRING VARCHAR
LONG INTEGER
SHORT SMALLINT
DECIMAL NUMERIC
REAL REAL
DATE DATE
TIME TIME

Notes

  • DCTX is specific to Clarion development platform
  • Useful for migrating legacy Clarion applications
  • Schema name defaults to public
  • Preserves field properties and constraints where possible

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements the readers.Reader interface for DCTX format

func NewReader

func NewReader(options *readers.ReaderOptions) *Reader

NewReader creates a new DCTX reader with the given options

func (*Reader) ReadDatabase

func (r *Reader) ReadDatabase() (*models.Database, error)

ReadDatabase reads and parses DCTX input, returning a Database model

func (*Reader) ReadSchema

func (r *Reader) ReadSchema() (*models.Schema, error)

ReadSchema reads and parses DCTX input, returning a Schema model

func (*Reader) ReadTable

func (r *Reader) ReadTable() (*models.Table, error)

ReadTable reads and parses DCTX input, returning a Table model

Jump to

Keyboard shortcuts

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