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
  •  
  •  
  •  
35 changes: 29 additions & 6 deletions _gen/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ import (
var fieldSetterTemplate *template.Template

func init() {
tmplFuncs := make(template.FuncMap)
tmplFuncs["fixFieldTypeToGoType"] = FixFieldTypeToGoType
tmplFuncs := template.FuncMap{
"fixFieldTypeToGoType": FixFieldTypeToGoType,
"toLower": strings.ToLower,
}

fieldSetterTemplate = template.Must(template.New("Setters").Funcs(tmplFuncs).Parse(`
{{define "fieldSetter"}}
func (m *{{.Receiver}}) Set{{.Name}}(v {{ if .IsGroup}}[]{{.Name}}{{else}}{{fixFieldTypeToGoType .Type}}{{end}}) {
{{- if .IsGroup -}}m.{{.Name}} = v
{{- else if .Required -}}m.{{.Name}} = v
{{- else -}}m.{{.Name}} = &v
{{- end}}}`))
{{- end}}}{{end}}

{{define "compSetter"}}
func (m *{{.Receiver}}) Set{{.Name}}(v {{toLower .Name}}.{{ .Name}}) {
{{- if .Required -}}m.{{.Name}} = v
{{- else -}}m.{{.Name}} = &v
{{- end}}}{{end}}`))
}

//WriteFieldSetters generates setters appropriate for Messages, Components or Repeating Groups
Expand All @@ -31,10 +40,19 @@ func WriteFieldSetters(writer io.Writer, receiver string, parts []datadictionary
*datadictionary.FieldDef
}

type componentSetter struct {
Receiver string
datadictionary.Component
}

for _, part := range parts {
switch field := part.(type) {
case datadictionary.Component:
if err := fieldSetterTemplate.ExecuteTemplate(writer, "compSetter", componentSetter{receiver, field}); err != nil {
return err
}
case *datadictionary.FieldDef:
if err := fieldSetterTemplate.Execute(writer, setter{receiver, field}); err != nil {
if err := fieldSetterTemplate.ExecuteTemplate(writer, "fieldSetter", setter{receiver, field}); err != nil {
return err
}
}
Expand All @@ -46,8 +64,13 @@ func WriteFieldSetters(writer io.Writer, receiver string, parts []datadictionary
func WriteFieldDeclaration(fixSpecMajor int, fixSpecMinor int, part datadictionary.MessagePart, componentName string) (s string) {
switch field := part.(type) {
case datadictionary.Component:
s += fmt.Sprintf("//%v Component\n", field.Name())
s += fmt.Sprintf("%v.%v\n", strings.ToLower(field.Name()), field.Name())
if field.Required() {
s += fmt.Sprintf("//%v is a required component for %v.\n", field.Name(), componentName)
s += fmt.Sprintf("%v.%v\n", strings.ToLower(field.Name()), field.Name())
} else {
s += fmt.Sprintf("//%v is a non-required component for %v.\n", field.Name(), componentName)
s += fmt.Sprintf("%v *%v.%v\n", field.Name(), strings.ToLower(field.Name()), field.Name())
}
return

case *datadictionary.FieldDef:
Expand Down
16 changes: 7 additions & 9 deletions datadictionary/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,18 @@ func (b builder) buildGroupFieldDef(xmlField *XMLComponentMember, groupFieldType
for _, member := range xmlField.Members {
if member.XMLName.Local == "component" {
var err error
var comp *ComponentType
if comp, err = b.findOrBuildComponentType(member); err != nil {
var compType *ComponentType
if compType, err = b.findOrBuildComponentType(member); err != nil {
return nil, err
}

parts = append(parts, Component{ComponentType: comp, required: (member.Required == "Y")})
//FIXME: set fields
for _, f := range comp.Parts {
switch field := f.(type) {
case *FieldDef:
fields = append(fields, field)
}
comp := Component{
ComponentType: compType,
required: (member.Required == "Y"),
}

parts = append(parts, comp)
fields = append(fields, comp.Fields...)
} else {
var f *FieldDef
var err error
Expand Down
35 changes: 18 additions & 17 deletions fix43/advertisement/Advertisement.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Message struct {
AdvTransType string `fix:"5"`
//AdvRefID is a non-required field for Advertisement.
AdvRefID *string `fix:"3"`
//Instrument Component
//Instrument is a required component for Advertisement.
instrument.Instrument
//AdvSide is a required field for Advertisement.
AdvSide string `fix:"4"`
Expand Down Expand Up @@ -53,22 +53,23 @@ type Message struct {
//Marshal converts Message to a quickfix.Message instance
func (m Message) Marshal() quickfix.Message { return quickfix.Marshal(m) }

func (m *Message) SetAdvId(v string) { m.AdvId = v }
func (m *Message) SetAdvTransType(v string) { m.AdvTransType = v }
func (m *Message) SetAdvRefID(v string) { m.AdvRefID = &v }
func (m *Message) SetAdvSide(v string) { m.AdvSide = v }
func (m *Message) SetQuantity(v float64) { m.Quantity = v }
func (m *Message) SetPrice(v float64) { m.Price = &v }
func (m *Message) SetCurrency(v string) { m.Currency = &v }
func (m *Message) SetTradeDate(v string) { m.TradeDate = &v }
func (m *Message) SetTransactTime(v time.Time) { m.TransactTime = &v }
func (m *Message) SetText(v string) { m.Text = &v }
func (m *Message) SetEncodedTextLen(v int) { m.EncodedTextLen = &v }
func (m *Message) SetEncodedText(v string) { m.EncodedText = &v }
func (m *Message) SetURLLink(v string) { m.URLLink = &v }
func (m *Message) SetLastMkt(v string) { m.LastMkt = &v }
func (m *Message) SetTradingSessionID(v string) { m.TradingSessionID = &v }
func (m *Message) SetTradingSessionSubID(v string) { m.TradingSessionSubID = &v }
func (m *Message) SetAdvId(v string) { m.AdvId = v }
func (m *Message) SetAdvTransType(v string) { m.AdvTransType = v }
func (m *Message) SetAdvRefID(v string) { m.AdvRefID = &v }
func (m *Message) SetInstrument(v instrument.Instrument) { m.Instrument = v }
func (m *Message) SetAdvSide(v string) { m.AdvSide = v }
func (m *Message) SetQuantity(v float64) { m.Quantity = v }
func (m *Message) SetPrice(v float64) { m.Price = &v }
func (m *Message) SetCurrency(v string) { m.Currency = &v }
func (m *Message) SetTradeDate(v string) { m.TradeDate = &v }
func (m *Message) SetTransactTime(v time.Time) { m.TransactTime = &v }
func (m *Message) SetText(v string) { m.Text = &v }
func (m *Message) SetEncodedTextLen(v int) { m.EncodedTextLen = &v }
func (m *Message) SetEncodedText(v string) { m.EncodedText = &v }
func (m *Message) SetURLLink(v string) { m.URLLink = &v }
func (m *Message) SetLastMkt(v string) { m.LastMkt = &v }
func (m *Message) SetTradingSessionID(v string) { m.TradingSessionID = &v }
func (m *Message) SetTradingSessionSubID(v string) { m.TradingSessionSubID = &v }

//A RouteOut is the callback type that should be implemented for routing Message
type RouteOut func(msg Message, sessionID quickfix.SessionID) quickfix.MessageRejectError
Expand Down
128 changes: 66 additions & 62 deletions fix43/allocation/Allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type NoAllocs struct {
IndividualAllocID *string `fix:"467"`
//ProcessCode is a non-required field for NoAllocs.
ProcessCode *string `fix:"81"`
//NestedParties Component
nestedparties.NestedParties
//NestedParties is a non-required component for NoAllocs.
NestedParties *nestedparties.NestedParties
//NotifyBrokerOfCredit is a non-required field for NoAllocs.
NotifyBrokerOfCredit *bool `fix:"208"`
//AllocHandlInst is a non-required field for NoAllocs.
Expand All @@ -76,8 +76,8 @@ type NoAllocs struct {
EncodedAllocTextLen *int `fix:"360"`
//EncodedAllocText is a non-required field for NoAllocs.
EncodedAllocText *string `fix:"361"`
//CommissionData Component
commissiondata.CommissionData
//CommissionData is a non-required component for NoAllocs.
CommissionData *commissiondata.CommissionData
//AllocAvgPx is a non-required field for NoAllocs.
AllocAvgPx *float64 `fix:"153"`
//AllocNetMoney is a non-required field for NoAllocs.
Expand All @@ -98,25 +98,27 @@ type NoAllocs struct {
NoMiscFees []NoMiscFees `fix:"136,omitempty"`
}

func (m *NoAllocs) SetAllocAccount(v string) { m.AllocAccount = &v }
func (m *NoAllocs) SetAllocPrice(v float64) { m.AllocPrice = &v }
func (m *NoAllocs) SetAllocQty(v float64) { m.AllocQty = &v }
func (m *NoAllocs) SetIndividualAllocID(v string) { m.IndividualAllocID = &v }
func (m *NoAllocs) SetProcessCode(v string) { m.ProcessCode = &v }
func (m *NoAllocs) SetNotifyBrokerOfCredit(v bool) { m.NotifyBrokerOfCredit = &v }
func (m *NoAllocs) SetAllocHandlInst(v int) { m.AllocHandlInst = &v }
func (m *NoAllocs) SetAllocText(v string) { m.AllocText = &v }
func (m *NoAllocs) SetEncodedAllocTextLen(v int) { m.EncodedAllocTextLen = &v }
func (m *NoAllocs) SetEncodedAllocText(v string) { m.EncodedAllocText = &v }
func (m *NoAllocs) SetAllocAvgPx(v float64) { m.AllocAvgPx = &v }
func (m *NoAllocs) SetAllocNetMoney(v float64) { m.AllocNetMoney = &v }
func (m *NoAllocs) SetSettlCurrAmt(v float64) { m.SettlCurrAmt = &v }
func (m *NoAllocs) SetSettlCurrency(v string) { m.SettlCurrency = &v }
func (m *NoAllocs) SetSettlCurrFxRate(v float64) { m.SettlCurrFxRate = &v }
func (m *NoAllocs) SetSettlCurrFxRateCalc(v string) { m.SettlCurrFxRateCalc = &v }
func (m *NoAllocs) SetAccruedInterestAmt(v float64) { m.AccruedInterestAmt = &v }
func (m *NoAllocs) SetSettlInstMode(v string) { m.SettlInstMode = &v }
func (m *NoAllocs) SetNoMiscFees(v []NoMiscFees) { m.NoMiscFees = v }
func (m *NoAllocs) SetAllocAccount(v string) { m.AllocAccount = &v }
func (m *NoAllocs) SetAllocPrice(v float64) { m.AllocPrice = &v }
func (m *NoAllocs) SetAllocQty(v float64) { m.AllocQty = &v }
func (m *NoAllocs) SetIndividualAllocID(v string) { m.IndividualAllocID = &v }
func (m *NoAllocs) SetProcessCode(v string) { m.ProcessCode = &v }
func (m *NoAllocs) SetNestedParties(v nestedparties.NestedParties) { m.NestedParties = &v }
func (m *NoAllocs) SetNotifyBrokerOfCredit(v bool) { m.NotifyBrokerOfCredit = &v }
func (m *NoAllocs) SetAllocHandlInst(v int) { m.AllocHandlInst = &v }
func (m *NoAllocs) SetAllocText(v string) { m.AllocText = &v }
func (m *NoAllocs) SetEncodedAllocTextLen(v int) { m.EncodedAllocTextLen = &v }
func (m *NoAllocs) SetEncodedAllocText(v string) { m.EncodedAllocText = &v }
func (m *NoAllocs) SetCommissionData(v commissiondata.CommissionData) { m.CommissionData = &v }
func (m *NoAllocs) SetAllocAvgPx(v float64) { m.AllocAvgPx = &v }
func (m *NoAllocs) SetAllocNetMoney(v float64) { m.AllocNetMoney = &v }
func (m *NoAllocs) SetSettlCurrAmt(v float64) { m.SettlCurrAmt = &v }
func (m *NoAllocs) SetSettlCurrency(v string) { m.SettlCurrency = &v }
func (m *NoAllocs) SetSettlCurrFxRate(v float64) { m.SettlCurrFxRate = &v }
func (m *NoAllocs) SetSettlCurrFxRateCalc(v string) { m.SettlCurrFxRateCalc = &v }
func (m *NoAllocs) SetAccruedInterestAmt(v float64) { m.AccruedInterestAmt = &v }
func (m *NoAllocs) SetSettlInstMode(v string) { m.SettlInstMode = &v }
func (m *NoAllocs) SetNoMiscFees(v []NoMiscFees) { m.NoMiscFees = v }

//NoMiscFees is a repeating group in NoAllocs
type NoMiscFees struct {
Expand Down Expand Up @@ -156,7 +158,7 @@ type Message struct {
NoExecs []NoExecs `fix:"124,omitempty"`
//Side is a required field for Allocation.
Side string `fix:"54"`
//Instrument Component
//Instrument is a required component for Allocation.
instrument.Instrument
//Quantity is a required field for Allocation.
Quantity float64 `fix:"53"`
Expand All @@ -176,8 +178,8 @@ type Message struct {
Currency *string `fix:"15"`
//AvgPrxPrecision is a non-required field for Allocation.
AvgPrxPrecision *int `fix:"74"`
//Parties Component
parties.Parties
//Parties is a non-required component for Allocation.
Parties *parties.Parties
//TradeDate is a required field for Allocation.
TradeDate string `fix:"75"`
//TransactTime is a non-required field for Allocation.
Expand Down Expand Up @@ -218,42 +220,44 @@ type Message struct {
//Marshal converts Message to a quickfix.Message instance
func (m Message) Marshal() quickfix.Message { return quickfix.Marshal(m) }

func (m *Message) SetAllocID(v string) { m.AllocID = v }
func (m *Message) SetAllocTransType(v string) { m.AllocTransType = v }
func (m *Message) SetAllocType(v int) { m.AllocType = v }
func (m *Message) SetRefAllocID(v string) { m.RefAllocID = &v }
func (m *Message) SetAllocLinkID(v string) { m.AllocLinkID = &v }
func (m *Message) SetAllocLinkType(v int) { m.AllocLinkType = &v }
func (m *Message) SetBookingRefID(v string) { m.BookingRefID = &v }
func (m *Message) SetNoOrders(v []NoOrders) { m.NoOrders = v }
func (m *Message) SetNoExecs(v []NoExecs) { m.NoExecs = v }
func (m *Message) SetSide(v string) { m.Side = v }
func (m *Message) SetQuantity(v float64) { m.Quantity = v }
func (m *Message) SetLastMkt(v string) { m.LastMkt = &v }
func (m *Message) SetTradeOriginationDate(v string) { m.TradeOriginationDate = &v }
func (m *Message) SetTradingSessionID(v string) { m.TradingSessionID = &v }
func (m *Message) SetTradingSessionSubID(v string) { m.TradingSessionSubID = &v }
func (m *Message) SetPriceType(v int) { m.PriceType = &v }
func (m *Message) SetAvgPx(v float64) { m.AvgPx = v }
func (m *Message) SetCurrency(v string) { m.Currency = &v }
func (m *Message) SetAvgPrxPrecision(v int) { m.AvgPrxPrecision = &v }
func (m *Message) SetTradeDate(v string) { m.TradeDate = v }
func (m *Message) SetTransactTime(v time.Time) { m.TransactTime = &v }
func (m *Message) SetSettlmntTyp(v string) { m.SettlmntTyp = &v }
func (m *Message) SetFutSettDate(v string) { m.FutSettDate = &v }
func (m *Message) SetGrossTradeAmt(v float64) { m.GrossTradeAmt = &v }
func (m *Message) SetConcession(v float64) { m.Concession = &v }
func (m *Message) SetTotalTakedown(v float64) { m.TotalTakedown = &v }
func (m *Message) SetNetMoney(v float64) { m.NetMoney = &v }
func (m *Message) SetPositionEffect(v string) { m.PositionEffect = &v }
func (m *Message) SetText(v string) { m.Text = &v }
func (m *Message) SetEncodedTextLen(v int) { m.EncodedTextLen = &v }
func (m *Message) SetEncodedText(v string) { m.EncodedText = &v }
func (m *Message) SetNumDaysInterest(v int) { m.NumDaysInterest = &v }
func (m *Message) SetAccruedInterestRate(v float64) { m.AccruedInterestRate = &v }
func (m *Message) SetTotalAccruedInterestAmt(v float64) { m.TotalAccruedInterestAmt = &v }
func (m *Message) SetLegalConfirm(v bool) { m.LegalConfirm = &v }
func (m *Message) SetNoAllocs(v []NoAllocs) { m.NoAllocs = v }
func (m *Message) SetAllocID(v string) { m.AllocID = v }
func (m *Message) SetAllocTransType(v string) { m.AllocTransType = v }
func (m *Message) SetAllocType(v int) { m.AllocType = v }
func (m *Message) SetRefAllocID(v string) { m.RefAllocID = &v }
func (m *Message) SetAllocLinkID(v string) { m.AllocLinkID = &v }
func (m *Message) SetAllocLinkType(v int) { m.AllocLinkType = &v }
func (m *Message) SetBookingRefID(v string) { m.BookingRefID = &v }
func (m *Message) SetNoOrders(v []NoOrders) { m.NoOrders = v }
func (m *Message) SetNoExecs(v []NoExecs) { m.NoExecs = v }
func (m *Message) SetSide(v string) { m.Side = v }
func (m *Message) SetInstrument(v instrument.Instrument) { m.Instrument = v }
func (m *Message) SetQuantity(v float64) { m.Quantity = v }
func (m *Message) SetLastMkt(v string) { m.LastMkt = &v }
func (m *Message) SetTradeOriginationDate(v string) { m.TradeOriginationDate = &v }
func (m *Message) SetTradingSessionID(v string) { m.TradingSessionID = &v }
func (m *Message) SetTradingSessionSubID(v string) { m.TradingSessionSubID = &v }
func (m *Message) SetPriceType(v int) { m.PriceType = &v }
func (m *Message) SetAvgPx(v float64) { m.AvgPx = v }
func (m *Message) SetCurrency(v string) { m.Currency = &v }
func (m *Message) SetAvgPrxPrecision(v int) { m.AvgPrxPrecision = &v }
func (m *Message) SetParties(v parties.Parties) { m.Parties = &v }
func (m *Message) SetTradeDate(v string) { m.TradeDate = v }
func (m *Message) SetTransactTime(v time.Time) { m.TransactTime = &v }
func (m *Message) SetSettlmntTyp(v string) { m.SettlmntTyp = &v }
func (m *Message) SetFutSettDate(v string) { m.FutSettDate = &v }
func (m *Message) SetGrossTradeAmt(v float64) { m.GrossTradeAmt = &v }
func (m *Message) SetConcession(v float64) { m.Concession = &v }
func (m *Message) SetTotalTakedown(v float64) { m.TotalTakedown = &v }
func (m *Message) SetNetMoney(v float64) { m.NetMoney = &v }
func (m *Message) SetPositionEffect(v string) { m.PositionEffect = &v }
func (m *Message) SetText(v string) { m.Text = &v }
func (m *Message) SetEncodedTextLen(v int) { m.EncodedTextLen = &v }
func (m *Message) SetEncodedText(v string) { m.EncodedText = &v }
func (m *Message) SetNumDaysInterest(v int) { m.NumDaysInterest = &v }
func (m *Message) SetAccruedInterestRate(v float64) { m.AccruedInterestRate = &v }
func (m *Message) SetTotalAccruedInterestAmt(v float64) { m.TotalAccruedInterestAmt = &v }
func (m *Message) SetLegalConfirm(v bool) { m.LegalConfirm = &v }
func (m *Message) SetNoAllocs(v []NoAllocs) { m.NoAllocs = v }

//A RouteOut is the callback type that should be implemented for routing Message
type RouteOut func(msg Message, sessionID quickfix.SessionID) quickfix.MessageRejectError
Expand Down
Loading