Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 1 addition & 11 deletions _gen/generate-components/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,14 @@ func collectGroups(parent string, part datadictionary.MessagePart, groups []grou
return groups
}

func genGroupDeclaration(field *datadictionary.FieldDef, parent string) (fileOut string) {
fileOut += fmt.Sprintf("//%v is a repeating group in %v\n", field.Name(), parent)
fileOut += fmt.Sprintf("type %v struct {\n", field.Name())
fileOut += gen.WriteFieldDeclarations(fixSpec.Major, fixSpec.Minor, field.Parts, field.Name())

fileOut += "}\n"

return
}

func genGroupDeclarations(name string, fields []datadictionary.MessagePart) (fileOut string) {
groups := []group{}
for _, field := range fields {
groups = collectGroups(name, field, groups)
}

for _, group := range groups {
fileOut += genGroupDeclaration(group.field, group.parent)
fileOut += gen.WriteGroupDeclaration(fixSpec.Major, fixSpec.Minor, group.field, group.parent)
}

return
Expand Down
19 changes: 1 addition & 18 deletions _gen/generate-messages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,6 @@ func genMessages() {
}
}

func genGroupDeclaration(field *datadictionary.FieldDef, parent string) (fileOut string) {
fileOut += fmt.Sprintf("//%v is a repeating group in %v\n", field.Name(), parent)
fileOut += fmt.Sprintf("type %v struct {\n", field.Name())
fileOut += gen.WriteFieldDeclarations(fixSpec.Major, fixSpec.Minor, field.Parts, field.Name())

fileOut += "}\n"

writer := new(bytes.Buffer)
if err := gen.WriteFieldSetters(writer, field.Name(), field.Parts); err != nil {
panic(err)
}
fileOut += writer.String()
fileOut += "\n"

return
}

type group struct {
parent string
field *datadictionary.FieldDef
Expand Down Expand Up @@ -85,7 +68,7 @@ func genGroupDeclarations(msg *datadictionary.MessageDef) (fileOut string) {
}

for _, group := range groups {
fileOut += genGroupDeclaration(group.field, group.parent)
fileOut += gen.WriteGroupDeclaration(fixSpec.Major, fixSpec.Minor, group.field, group.parent)
}

return
Expand Down
18 changes: 18 additions & 0 deletions _gen/helpers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gen

import (
"bytes"
"fmt"
"io"
"strconv"
Expand Down Expand Up @@ -163,6 +164,23 @@ func WriteFieldDeclarations(fixSpecMajor int, fixSpecMinor int, parts []datadict
return
}

func WriteGroupDeclaration(fixSpecMajor, fixSpecMinor int, field *datadictionary.FieldDef, parent string) (fileOut string) {
fileOut += fmt.Sprintf("//%v is a repeating group in %v\n", field.Name(), parent)
fileOut += fmt.Sprintf("type %v struct {\n", field.Name())
fileOut += WriteFieldDeclarations(fixSpecMajor, fixSpecMinor, field.Parts, field.Name())

fileOut += "}\n"

writer := new(bytes.Buffer)
if err := WriteFieldSetters(writer, field.Name(), field.Parts); err != nil {
panic(err)
}
fileOut += writer.String()
fileOut += "\n"

return
}

func writeFieldDeclaration(fixSpecMajor int, fixSpecMinor int, part datadictionary.MessagePart, componentName string) (s string) {
switch field := part.(type) {
case datadictionary.Component:
Expand Down
7 changes: 2 additions & 5 deletions datadictionary/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func (b builder) buildMessageDef(xmlMessage *XMLComponent) (*MessageDef, error)

func (b builder) buildGroupFieldDef(xmlField *XMLComponentMember, groupFieldType *FieldType) (*FieldDef, error) {
var parts []MessagePart
var fields []*FieldDef

for _, member := range xmlField.Members {
if member.XMLName.Local == "component" {
Expand All @@ -190,19 +189,17 @@ func (b builder) buildGroupFieldDef(xmlField *XMLComponentMember, groupFieldType
}

parts = append(parts, comp)
fields = append(fields, comp.Fields()...)
} else {
var f *FieldDef
var err error
if f, err = b.buildFieldDef(member); err != nil {
return nil, err
}
parts = append(parts, f)
fields = append(fields, f)
}
}

return &FieldDef{FieldType: groupFieldType, required: (xmlField.Required == "Y"), Parts: parts, ChildFields: fields}, nil
return NewGroupFieldDef(groupFieldType, (xmlField.Required == "Y"), parts), nil
}

func (b builder) buildFieldDef(xmlField *XMLComponentMember) (*FieldDef, error) {
Expand All @@ -218,7 +215,7 @@ func (b builder) buildFieldDef(xmlField *XMLComponentMember) (*FieldDef, error)
return f, err
}

return &FieldDef{FieldType: fieldType, required: (xmlField.Required == "Y")}, nil
return NewFieldDef(fieldType, (xmlField.Required == "Y")), nil
}

func (b builder) buildFieldTypes() {
Expand Down
31 changes: 31 additions & 0 deletions datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,37 @@ type FieldDef struct {
ChildFields []*FieldDef
}

//NewFieldDef returns an initialized FieldDef
func NewFieldDef(fieldType *FieldType, required bool) *FieldDef {
return &FieldDef{
FieldType: fieldType,
required: required,
}
}

//NewGroupFieldDef returns an initialized FieldDef for a repeating group
func NewGroupFieldDef(fieldType *FieldType, required bool, parts []MessagePart) *FieldDef {
field := FieldDef{
FieldType: fieldType,
required: required,
Parts: parts,
}

for _, part := range parts {
if comp, ok := part.(Component); ok {
field.ChildFields = append(field.ChildFields, comp.Fields()...)
} else {
if child, ok := part.(*FieldDef); ok {
field.ChildFields = append(field.ChildFields, child)
} else {
panic("unknown part")
}
}
}

return &field
}

//Required returns true if this FieldDef is required for the containing
//MessageDef
func (f FieldDef) Required() bool { return f.required }
Expand Down
4 changes: 4 additions & 0 deletions fix43/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type NoHops struct {
HopRefID *int `fix:"630"`
}

func (m *NoHops) SetHopCompID(v string) { m.HopCompID = &v }
func (m *NoHops) SetHopSendingTime(v time.Time) { m.HopSendingTime = &v }
func (m *NoHops) SetHopRefID(v int) { m.HopRefID = &v }

//Header is the fix43 Header type
type Header struct {
//BeginString is a required field for Header.
Expand Down
3 changes: 3 additions & 0 deletions fix43/instrument/Instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoSecurityAltID struct {
SecurityAltIDSource *string `fix:"456"`
}

func (m *NoSecurityAltID) SetSecurityAltID(v string) { m.SecurityAltID = &v }
func (m *NoSecurityAltID) SetSecurityAltIDSource(v string) { m.SecurityAltIDSource = &v }

//Instrument is a fix43 Component
type Instrument struct {
//Symbol is a non-required field for Instrument.
Expand Down
3 changes: 3 additions & 0 deletions fix43/instrumentleg/InstrumentLeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoLegSecurityAltID struct {
LegSecurityAltIDSource *string `fix:"606"`
}

func (m *NoLegSecurityAltID) SetLegSecurityAltID(v string) { m.LegSecurityAltID = &v }
func (m *NoLegSecurityAltID) SetLegSecurityAltIDSource(v string) { m.LegSecurityAltIDSource = &v }

//InstrumentLeg is a fix43 Component
type InstrumentLeg struct {
//LegSymbol is a non-required field for InstrumentLeg.
Expand Down
5 changes: 5 additions & 0 deletions fix43/nestedparties/NestedParties.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type NoNestedPartyIDs struct {
NestedPartySubID *string `fix:"545"`
}

func (m *NoNestedPartyIDs) SetNestedPartyID(v string) { m.NestedPartyID = &v }
func (m *NoNestedPartyIDs) SetNestedPartyIDSource(v string) { m.NestedPartyIDSource = &v }
func (m *NoNestedPartyIDs) SetNestedPartyRole(v int) { m.NestedPartyRole = &v }
func (m *NoNestedPartyIDs) SetNestedPartySubID(v string) { m.NestedPartySubID = &v }

//NestedParties is a fix43 Component
type NestedParties struct {
//NoNestedPartyIDs is a non-required field for NestedParties.
Expand Down
5 changes: 5 additions & 0 deletions fix43/parties/Parties.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type NoPartyIDs struct {
PartySubID *string `fix:"523"`
}

func (m *NoPartyIDs) SetPartyID(v string) { m.PartyID = &v }
func (m *NoPartyIDs) SetPartyIDSource(v string) { m.PartyIDSource = &v }
func (m *NoPartyIDs) SetPartyRole(v int) { m.PartyRole = &v }
func (m *NoPartyIDs) SetPartySubID(v string) { m.PartySubID = &v }

//Parties is a fix43 Component
type Parties struct {
//NoPartyIDs is a non-required field for Parties.
Expand Down
3 changes: 3 additions & 0 deletions fix43/stipulations/Stipulations.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoStipulations struct {
StipulationValue *string `fix:"234"`
}

func (m *NoStipulations) SetStipulationType(v string) { m.StipulationType = &v }
func (m *NoStipulations) SetStipulationValue(v string) { m.StipulationValue = &v }

//Stipulations is a fix43 Component
type Stipulations struct {
//NoStipulations is a non-required field for Stipulations.
Expand Down
7 changes: 7 additions & 0 deletions fix43/underlyinginstrument/UnderlyingInstrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ type NoUnderlyingSecurityAltID struct {
UnderlyingSecurityAltIDSource *string `fix:"459"`
}

func (m *NoUnderlyingSecurityAltID) SetUnderlyingSecurityAltID(v string) {
m.UnderlyingSecurityAltID = &v
}
func (m *NoUnderlyingSecurityAltID) SetUnderlyingSecurityAltIDSource(v string) {
m.UnderlyingSecurityAltIDSource = &v
}

//UnderlyingInstrument is a fix43 Component
type UnderlyingInstrument struct {
//UnderlyingSymbol is a non-required field for UnderlyingInstrument.
Expand Down
4 changes: 4 additions & 0 deletions fix44/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type NoHops struct {
HopRefID *int `fix:"630"`
}

func (m *NoHops) SetHopCompID(v string) { m.HopCompID = &v }
func (m *NoHops) SetHopSendingTime(v time.Time) { m.HopSendingTime = &v }
func (m *NoHops) SetHopRefID(v int) { m.HopRefID = &v }

//Header is the fix44 Header type
type Header struct {
//BeginString is a required field for Header.
Expand Down
8 changes: 8 additions & 0 deletions fix44/instrument/Instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoSecurityAltID struct {
SecurityAltIDSource *string `fix:"456"`
}

func (m *NoSecurityAltID) SetSecurityAltID(v string) { m.SecurityAltID = &v }
func (m *NoSecurityAltID) SetSecurityAltIDSource(v string) { m.SecurityAltIDSource = &v }

//NoEvents is a repeating group in Instrument
type NoEvents struct {
//EventType is a non-required field for NoEvents.
Expand All @@ -25,6 +28,11 @@ type NoEvents struct {
EventText *string `fix:"868"`
}

func (m *NoEvents) SetEventType(v int) { m.EventType = &v }
func (m *NoEvents) SetEventDate(v string) { m.EventDate = &v }
func (m *NoEvents) SetEventPx(v float64) { m.EventPx = &v }
func (m *NoEvents) SetEventText(v string) { m.EventText = &v }

//Instrument is a fix44 Component
type Instrument struct {
//Symbol is a non-required field for Instrument.
Expand Down
3 changes: 3 additions & 0 deletions fix44/instrumentextension/InstrumentExtension.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoInstrAttrib struct {
InstrAttribValue *string `fix:"872"`
}

func (m *NoInstrAttrib) SetInstrAttribType(v int) { m.InstrAttribType = &v }
func (m *NoInstrAttrib) SetInstrAttribValue(v string) { m.InstrAttribValue = &v }

//InstrumentExtension is a fix44 Component
type InstrumentExtension struct {
//DeliveryForm is a non-required field for InstrumentExtension.
Expand Down
3 changes: 3 additions & 0 deletions fix44/instrumentleg/InstrumentLeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoLegSecurityAltID struct {
LegSecurityAltIDSource *string `fix:"606"`
}

func (m *NoLegSecurityAltID) SetLegSecurityAltID(v string) { m.LegSecurityAltID = &v }
func (m *NoLegSecurityAltID) SetLegSecurityAltIDSource(v string) { m.LegSecurityAltIDSource = &v }

//InstrumentLeg is a fix44 Component
type InstrumentLeg struct {
//LegSymbol is a non-required field for InstrumentLeg.
Expand Down
3 changes: 3 additions & 0 deletions fix44/legstipulations/LegStipulations.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type NoLegStipulations struct {
LegStipulationValue *string `fix:"689"`
}

func (m *NoLegStipulations) SetLegStipulationType(v string) { m.LegStipulationType = &v }
func (m *NoLegStipulations) SetLegStipulationValue(v string) { m.LegStipulationValue = &v }

//LegStipulations is a fix44 Component
type LegStipulations struct {
//NoLegStipulations is a non-required field for LegStipulations.
Expand Down
8 changes: 8 additions & 0 deletions fix44/nestedparties/NestedParties.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type NoNestedPartyIDs struct {
NoNestedPartySubIDs []NoNestedPartySubIDs `fix:"804,omitempty"`
}

func (m *NoNestedPartyIDs) SetNestedPartyID(v string) { m.NestedPartyID = &v }
func (m *NoNestedPartyIDs) SetNestedPartyIDSource(v string) { m.NestedPartyIDSource = &v }
func (m *NoNestedPartyIDs) SetNestedPartyRole(v int) { m.NestedPartyRole = &v }
func (m *NoNestedPartyIDs) SetNoNestedPartySubIDs(v []NoNestedPartySubIDs) { m.NoNestedPartySubIDs = v }

//NoNestedPartySubIDs is a repeating group in NoNestedPartyIDs
type NoNestedPartySubIDs struct {
//NestedPartySubID is a non-required field for NoNestedPartySubIDs.
Expand All @@ -25,6 +30,9 @@ type NoNestedPartySubIDs struct {
NestedPartySubIDType *int `fix:"805"`
}

func (m *NoNestedPartySubIDs) SetNestedPartySubID(v string) { m.NestedPartySubID = &v }
func (m *NoNestedPartySubIDs) SetNestedPartySubIDType(v int) { m.NestedPartySubIDType = &v }

//NestedParties is a fix44 Component
type NestedParties struct {
//NoNestedPartyIDs is a non-required field for NestedParties.
Expand Down
10 changes: 10 additions & 0 deletions fix44/nestedparties2/NestedParties2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ type NoNested2PartyIDs struct {
NoNested2PartySubIDs []NoNested2PartySubIDs `fix:"806,omitempty"`
}

func (m *NoNested2PartyIDs) SetNested2PartyID(v string) { m.Nested2PartyID = &v }
func (m *NoNested2PartyIDs) SetNested2PartyIDSource(v string) { m.Nested2PartyIDSource = &v }
func (m *NoNested2PartyIDs) SetNested2PartyRole(v int) { m.Nested2PartyRole = &v }
func (m *NoNested2PartyIDs) SetNoNested2PartySubIDs(v []NoNested2PartySubIDs) {
m.NoNested2PartySubIDs = v
}

//NoNested2PartySubIDs is a repeating group in NoNested2PartyIDs
type NoNested2PartySubIDs struct {
//Nested2PartySubID is a non-required field for NoNested2PartySubIDs.
Expand All @@ -25,6 +32,9 @@ type NoNested2PartySubIDs struct {
Nested2PartySubIDType *int `fix:"807"`
}

func (m *NoNested2PartySubIDs) SetNested2PartySubID(v string) { m.Nested2PartySubID = &v }
func (m *NoNested2PartySubIDs) SetNested2PartySubIDType(v int) { m.Nested2PartySubIDType = &v }

//NestedParties2 is a fix44 Component
type NestedParties2 struct {
//NoNested2PartyIDs is a non-required field for NestedParties2.
Expand Down
10 changes: 10 additions & 0 deletions fix44/nestedparties3/NestedParties3.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ type NoNested3PartyIDs struct {
NoNested3PartySubIDs []NoNested3PartySubIDs `fix:"952,omitempty"`
}

func (m *NoNested3PartyIDs) SetNested3PartyID(v string) { m.Nested3PartyID = &v }
func (m *NoNested3PartyIDs) SetNested3PartyIDSource(v string) { m.Nested3PartyIDSource = &v }
func (m *NoNested3PartyIDs) SetNested3PartyRole(v int) { m.Nested3PartyRole = &v }
func (m *NoNested3PartyIDs) SetNoNested3PartySubIDs(v []NoNested3PartySubIDs) {
m.NoNested3PartySubIDs = v
}

//NoNested3PartySubIDs is a repeating group in NoNested3PartyIDs
type NoNested3PartySubIDs struct {
//Nested3PartySubID is a non-required field for NoNested3PartySubIDs.
Expand All @@ -25,6 +32,9 @@ type NoNested3PartySubIDs struct {
Nested3PartySubIDType *int `fix:"954"`
}

func (m *NoNested3PartySubIDs) SetNested3PartySubID(v string) { m.Nested3PartySubID = &v }
func (m *NoNested3PartySubIDs) SetNested3PartySubIDType(v int) { m.Nested3PartySubIDType = &v }

//NestedParties3 is a fix44 Component
type NestedParties3 struct {
//NoNested3PartyIDs is a non-required field for NestedParties3.
Expand Down
Loading