models

package
v0.0.0-...-be8afb0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartOfStruct = iota
	FieldDefinition
)

Line Type

Variables

This section is empty.

Functions

func IsStructStart

func IsStructStart(source string) bool

IsStructStart returns true if the line is the start of a struct.

Types

type Field

type Field struct {
	Name     string // name of the field
	Type     string // type of the field
	Required bool   // is the field required

	Tags []string
}

type Line

type Line struct {
	Raw  string // raw line
	Name string // StructName
	Type int    // Type of line

	Field Field // translated directly to go
	Tags  []string
}

Line is a line in an rx file.

func FileToLines

func FileToLines(source *os.File) []Line

FileToLines builds a slice of lines. Each line object is a breakdown of a line in the file for easier processing later.

func NewLine

func NewLine(source string) (Line, error)

NewLine return an object representing a line in an rsl file. Source can look like one of these: type 1: A struct start

[Person]

type 2: Member variables

Name:string:required|json:name,omitempty

Return an error if the line is empty.

func (*Line) GetField

func (l *Line) GetField() Field

func (*Line) IsEmpty

func (l *Line) IsEmpty() bool

func (*Line) IsStartOfStruct

func (l *Line) IsStartOfStruct() bool

func (*Line) StructName

func (l *Line) StructName() string

StructName returns the name of the struct parsed from the line.

type Rsl

type Rsl struct {
	Structs []StructDef
}

Rsl represents a *.rsl file.

func NewRsl

func NewRsl(source *os.File) Rsl

NewRsl returns a struct representing the StructDef file.

type StructDef

type StructDef struct {
	Name   string  // name of the struct
	Fields []Field // fields of the struct
}

StructDef represents the rsl file.

func LinesToStructs

func LinesToStructs(lines []Line) []StructDef

LinesToStructs builds a slice of Struct definitions from the lines we filtered earlier.

Jump to

Keyboard shortcuts

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