github.com/coveo/gotemplate@v2.7.7+incompatible/hcl/generated_impl.go (about) 1 // This file was automatically generated by genny. 2 // Any changes will be lost if this file is regenerated. 3 // see https://github.com/cheekybits/genny 4 5 package hcl 6 7 import "github.com/coveo/gotemplate/collections" 8 9 // List implementation of IGenericList for hclList 10 type List = hclList 11 type hclIList = collections.IGenericList 12 type hclList []interface{} 13 14 func (l hclList) AsArray() []interface{} { return []interface{}(l) } 15 func (l hclList) Cap() int { return cap(l) } 16 func (l hclList) Capacity() int { return cap(l) } 17 func (l hclList) Clone() hclIList { return hclListHelper.Clone(l) } 18 func (l hclList) Contains(values ...interface{}) bool { 19 return hclListHelper.Contains(l, values...) 20 } 21 func (l hclList) Count() int { return len(l) } 22 func (l hclList) Create(args ...int) hclIList { return hclListHelper.CreateList(args...) } 23 func (l hclList) CreateDict(args ...int) hclIDict { 24 return hclListHelper.CreateDictionary(args...) 25 } 26 func (l hclList) First() interface{} { return hclListHelper.GetIndexes(l, 0) } 27 func (l hclList) Get(indexes ...int) interface{} { 28 return hclListHelper.GetIndexes(l, indexes...) 29 } 30 func (l hclList) Has(values ...interface{}) bool { return l.Contains(values...) } 31 func (l hclList) Join(sep interface{}) str { return l.StringArray().Join(sep) } 32 func (l hclList) Last() interface{} { return hclListHelper.GetIndexes(l, len(l)-1) } 33 func (l hclList) Len() int { return len(l) } 34 func (l hclList) New(args ...interface{}) hclIList { return hclListHelper.NewList(args...) } 35 func (l hclList) Reverse() hclIList { return hclListHelper.Reverse(l) } 36 func (l hclList) StringArray() strArray { return hclListHelper.GetStringArray(l) } 37 func (l hclList) Strings() []string { return hclListHelper.GetStrings(l) } 38 func (l hclList) TypeName() str { return "Hcl" } 39 func (l hclList) Unique() hclIList { return hclListHelper.Unique(l) } 40 41 func (l hclList) GetHelpers() (collections.IDictionaryHelper, collections.IListHelper) { 42 return hclDictHelper, hclListHelper 43 } 44 45 func (l hclList) Append(values ...interface{}) hclIList { 46 return hclListHelper.Add(l, false, values...) 47 } 48 49 func (l hclList) Intersect(values ...interface{}) hclIList { 50 return hclListHelper.Intersect(l, values...) 51 } 52 53 func (l hclList) Pop(indexes ...int) (interface{}, hclIList) { 54 if len(indexes) == 0 { 55 indexes = []int{len(l) - 1} 56 } 57 return l.Get(indexes...), l.Remove(indexes...) 58 } 59 60 func (l hclList) Prepend(values ...interface{}) hclIList { 61 return hclListHelper.Add(l, true, values...) 62 } 63 64 func (l hclList) Remove(indexes ...int) hclIList { 65 return hclListHelper.Remove(l, indexes...) 66 } 67 68 func (l hclList) Set(i int, v interface{}) (hclIList, error) { 69 return hclListHelper.SetIndex(l, i, v) 70 } 71 72 func (l hclList) Union(values ...interface{}) hclIList { 73 return hclListHelper.Add(l, false, values...).Unique() 74 } 75 76 func (l hclList) Without(values ...interface{}) hclIList { 77 return hclListHelper.Without(l, values...) 78 } 79 80 // Dictionary implementation of IDictionary for hclDict 81 type Dictionary = hclDict 82 type hclIDict = collections.IDictionary 83 type hclDict map[string]interface{} 84 85 func (d hclDict) Add(key, v interface{}) hclIDict { return hclDictHelper.Add(d, key, v) } 86 func (d hclDict) AsMap() map[string]interface{} { return (map[string]interface{})(d) } 87 func (d hclDict) Clone(keys ...interface{}) hclIDict { return hclDictHelper.Clone(d, keys) } 88 func (d hclDict) Count() int { return len(d) } 89 func (d hclDict) Create(args ...int) hclIDict { return hclListHelper.CreateDictionary(args...) } 90 func (d hclDict) CreateList(args ...int) hclIList { return hclHelper.CreateList(args...) } 91 func (d hclDict) Flush(keys ...interface{}) hclIDict { return hclDictHelper.Flush(d, keys) } 92 func (d hclDict) Get(keys ...interface{}) interface{} { return hclDictHelper.Get(d, keys) } 93 func (d hclDict) GetKeys() hclIList { return hclDictHelper.GetKeys(d) } 94 func (d hclDict) GetValues() hclIList { return hclDictHelper.GetValues(d) } 95 func (d hclDict) Has(keys ...interface{}) bool { return hclDictHelper.Has(d, keys) } 96 func (d hclDict) KeysAsString() strArray { return hclDictHelper.KeysAsString(d) } 97 func (d hclDict) Len() int { return len(d) } 98 func (d hclDict) Native() interface{} { return collections.ToNativeRepresentation(d) } 99 func (d hclDict) Pop(keys ...interface{}) interface{} { return hclDictHelper.Pop(d, keys) } 100 func (d hclDict) Set(key, v interface{}) hclIDict { return hclDictHelper.Set(d, key, v) } 101 func (d hclDict) Transpose() hclIDict { return hclDictHelper.Transpose(d) } 102 func (d hclDict) TypeName() str { return "Hcl" } 103 104 func (d hclDict) GetHelpers() (collections.IDictionaryHelper, collections.IListHelper) { 105 return hclDictHelper, hclListHelper 106 } 107 108 func (d hclDict) Default(key, defVal interface{}) interface{} { 109 return hclDictHelper.Default(d, key, defVal) 110 } 111 112 func (d hclDict) Delete(key interface{}, otherKeys ...interface{}) (hclIDict, error) { 113 return hclDictHelper.Delete(d, append([]interface{}{key}, otherKeys...)) 114 } 115 116 func (d hclDict) Merge(dict hclIDict, otherDicts ...hclIDict) hclIDict { 117 return hclDictHelper.Merge(d, append([]hclIDict{dict}, otherDicts...)) 118 } 119 120 func (d hclDict) Omit(key interface{}, otherKeys ...interface{}) hclIDict { 121 return hclDictHelper.Omit(d, append([]interface{}{key}, otherKeys...)) 122 } 123 124 // Generic helpers to simplify physical implementation 125 func hclListConvert(list hclIList) hclIList { return hclList(list.AsArray()) } 126 func hclDictConvert(dict hclIDict) hclIDict { return hclDict(dict.AsMap()) } 127 func needConversion(object interface{}, strict bool) bool { 128 return needConversionImpl(object, strict, "Hcl") 129 } 130 131 var hclHelper = helperBase{ConvertList: hclListConvert, ConvertDict: hclDictConvert, NeedConversion: needConversion} 132 var hclListHelper = helperList{BaseHelper: hclHelper} 133 var hclDictHelper = helperDict{BaseHelper: hclHelper} 134 135 // DictionaryHelper gives public access to the basic dictionary functions 136 var DictionaryHelper collections.IDictionaryHelper = hclDictHelper 137 138 // GenericListHelper gives public access to the basic list functions 139 var GenericListHelper collections.IListHelper = hclListHelper 140 141 type ( 142 str = collections.String 143 strArray = collections.StringArray 144 ) 145 146 var iif = collections.IIf