Create needed functions for common attributes and their extensions

This commit is contained in:
2024-10-17 20:48:32 +02:00
parent 3b3f1f7e41
commit 3172a4865a
3 changed files with 25 additions and 6 deletions

View File

@@ -8,6 +8,22 @@ type CommonAttributes struct {
UndefinedAttributes []*ExtensionAttribute `xml:",any"`
}
// NewCommonAttributes creates a new set of CommonAttributes. It returns a
// *CommonAttributes.
func NewCommonAttributes() *CommonAttributes {
return new(CommonAttributes)
}
// AddExtensionAttribute adds the ExtensionAttribute to the CommonAttributes.
func (c *CommonAttributes) AddExtensionAttribute(e *ExtensionAttribute) {
if c.UndefinedAttributes == nil {
c.UndefinedAttributes = make([]*ExtensionAttribute, 1)
c.UndefinedAttributes[0] = e
} else {
c.UndefinedAttributes = append(c.UndefinedAttributes, e)
}
}
// Check checks the CommonAttributes for incompatibilities with RFC4287. It
// returns an error.
func (c *CommonAttributes) Check() error {