github.com/cyverse/go-irodsclient@v0.13.2/irods/message/keyval_pair.go (about)

     1  package message
     2  
     3  import "encoding/xml"
     4  
     5  // IRODSMessageRawString ...
     6  type IRODSMessageRawString struct {
     7  	Value string `xml:",innerxml"`
     8  }
     9  
    10  // IRODSMessageSSKeyVal ..
    11  type IRODSMessageSSKeyVal struct {
    12  	XMLName xml.Name                `xml:"KeyValPair_PI"`
    13  	Length  int                     `xml:"ssLen"`
    14  	Keys    []string                `xml:"keyWord,omitempty"`
    15  	Values  []IRODSMessageRawString `xml:"svalue,omitempty"`
    16  }
    17  
    18  // IRODSMessageIIKeyVal ..
    19  type IRODSMessageIIKeyVal struct {
    20  	XMLName xml.Name `xml:"InxIvalPair_PI"`
    21  	Length  int      `xml:"iiLen"`
    22  	Keys    []int    `xml:"inx,omitempty"`
    23  	Values  []int    `xml:"ivalue,omitempty"`
    24  }
    25  
    26  // IRODSMessageISKeyVal ..
    27  type IRODSMessageISKeyVal struct {
    28  	XMLName xml.Name                `xml:"InxValPair_PI"`
    29  	Length  int                     `xml:"isLen"`
    30  	Keys    []int                   `xml:"inx,omitempty"`
    31  	Values  []IRODSMessageRawString `xml:"svalue,omitempty"`
    32  }
    33  
    34  // NewIRODSMessageSSKeyVal creates a new IRODSMessageSSKeyVal
    35  func NewIRODSMessageSSKeyVal() *IRODSMessageSSKeyVal {
    36  	return &IRODSMessageSSKeyVal{
    37  		Length: 0,
    38  	}
    39  }
    40  
    41  // Add adds a key-val pair
    42  func (kv *IRODSMessageSSKeyVal) Add(key string, val string) {
    43  	kv.Keys = append(kv.Keys, key)
    44  	kv.Values = append(kv.Values, IRODSMessageRawString{
    45  		Value: val,
    46  	})
    47  	kv.Length = len(kv.Keys)
    48  }
    49  
    50  // NewIRODSMessageIIKeyVal creates a new IRODSMessageIIKeyVal
    51  func NewIRODSMessageIIKeyVal() *IRODSMessageIIKeyVal {
    52  	return &IRODSMessageIIKeyVal{
    53  		Length: 0,
    54  	}
    55  }
    56  
    57  // Add adds a key-val pair
    58  func (kv *IRODSMessageIIKeyVal) Add(key int, val int) {
    59  	kv.Keys = append(kv.Keys, key)
    60  	kv.Values = append(kv.Values, val)
    61  	kv.Length = len(kv.Keys)
    62  }
    63  
    64  // NewIRODSMessageISKeyVal creates a new IRODSMessageISKeyVal
    65  func NewIRODSMessageISKeyVal() *IRODSMessageISKeyVal {
    66  	return &IRODSMessageISKeyVal{
    67  		Length: 0,
    68  	}
    69  }
    70  
    71  // Add adds a key-val pair
    72  func (kv *IRODSMessageISKeyVal) Add(key int, val string) {
    73  	kv.Keys = append(kv.Keys, key)
    74  	kv.Values = append(kv.Values, IRODSMessageRawString{
    75  		Value: val,
    76  	})
    77  	kv.Length = len(kv.Keys)
    78  }