Add base implementation for media-source

This commit is contained in:
Nico0302 2022-06-05 18:33:12 +02:00
parent 95e159f96c
commit e2598db13b
2 changed files with 57 additions and 2 deletions

View file

@ -303,9 +303,62 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error {
} }
} }
default: default:
if tag != TagBeginCollection {
return fmt.Errorf("type %T is not supported", value) return fmt.Errorf("type %T is not supported", value)
} }
if err := e.encodeTag(TagBeginCollection); err != nil {
return err
}
if err := e.encodeString(attribute); err != nil {
return err
}
if err := e.writeNullByte(); err != nil {
return err
}
for member, value := range value.(map[string]interface{}) {
fmt.Println(member, value)
if err := e.encodeTag(TagMemberName); err != nil {
return err
}
if err := e.writeNullByte(); err != nil {
return err
}
if err := e.encodeString(member); err != nil {
return err
}
if err := e.encodeTag(TagKeyword); err != nil {
return err
}
if err := e.writeNullByte(); err != nil {
return err
}
if err := e.encodeString(value.(string)); err != nil {
return err
}
}
if err := e.encodeTag(TagEndCollection); err != nil {
return err
}
if err := e.writeNullByte(); err != nil {
return err
}
if err := e.writeNullByte(); err != nil {
return err
}
}
return nil return nil
} }

View file

@ -352,7 +352,8 @@ const (
AttributeJobKilobyteOctets = "job-k-octets" AttributeJobKilobyteOctets = "job-k-octets"
AttributeNumberOfDocuments = "number-of-documents" AttributeNumberOfDocuments = "number-of-documents"
AttributeJobOriginatingUserName = "job-originating-user-name" AttributeJobOriginatingUserName = "job-originating-user-name"
AttributeOutputOrder = "outputorder" AttributeOutputOrder = "outputorder",
AttributeMediaCol = "media-col",
) )
// Default attributes // Default attributes
@ -416,5 +417,6 @@ var (
AttributeStatusMessage: TagText, AttributeStatusMessage: TagText,
AttributeLimit: TagInteger, AttributeLimit: TagInteger,
AttributeOutputOrder: TagName, AttributeOutputOrder: TagName,
AttributeMediaCol: TagBeginCollection,
} }
) )