From 15f2a2cd828c71b1a1913d24ea63a2d1948a7347 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 23 Mar 2014 09:14:43 +0100 Subject: [PATCH] Adding more properties to XmlCdrFields config --- config/xmlconfig.go | 15 ++++++++++----- config/xmlconfig_test.go | 40 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/config/xmlconfig.go b/config/xmlconfig.go index a46d7b2e8..a0b54dd1b 100644 --- a/config/xmlconfig.go +++ b/config/xmlconfig.go @@ -79,10 +79,15 @@ type CgrXmlCfgCdrTrailer struct { // CDR field type CgrXmlCfgCdrField struct { - XMLName xml.Name `xml:"field"` - Name string `xml:"name,attr"` - Type string `xml:"type,attr"` - Width string `xml:"width,attr"` + XMLName xml.Name `xml:"field"` + Name string `xml:"name,attr"` + Type string `xml:"type,attr"` + Value string `xml:"value,attr"` + Width string `xml:"width,attr"` + Strip string `xml:"strip,attr"` + Padding string `xml:"padding,attr"` + PaddingChar string `xml:"padding_char,attr"` + Layout string `xml:"layout,attr"` // Eg. time format layout } // Avoid building from raw config string always, so build cache here @@ -91,7 +96,7 @@ func (xmlCfg *CgrXmlCfgDocument) cacheCdreFWCfgs() error { for _, cfgInst := range xmlCfg.Configurations { if cfgInst.Section == utils.CDRE || cfgInst.Type == utils.FIXED_WIDTH { cdrefwCfg := new(CgrXmlCdreFwCfg) - rawConfig := append([]byte(""), cfgInst.RawConfig...) // Encapsulate the rawConfig in one element so we can Unmarshall + rawConfig := append([]byte(""), cfgInst.RawConfig...) // Encapsulate the rawConfig in one element so we can Unmarshall into one struct rawConfig = append(rawConfig, []byte("")...) if err := xml.Unmarshal(rawConfig, cdrefwCfg); err != nil { return err diff --git a/config/xmlconfig_test.go b/config/xmlconfig_test.go index 59ba58c37..c22ef6af6 100644 --- a/config/xmlconfig_test.go +++ b/config/xmlconfig_test.go @@ -34,9 +34,9 @@ func TestParseXmlConfig(t *testing.T) { - - - + + + @@ -44,25 +44,25 @@ func TestParseXmlConfig(t *testing.T) { - - - - + + + + - - + + - - + + - + - - - + + + @@ -70,11 +70,11 @@ func TestParseXmlConfig(t *testing.T) { - - - - - + + + + +