github.com/tobgu/qframe@v0.4.0/qframe_gen.go (about) 1 package qframe 2 3 import ( 4 "github.com/tobgu/qframe/internal/bcolumn" 5 "github.com/tobgu/qframe/internal/ecolumn" 6 "github.com/tobgu/qframe/internal/fcolumn" 7 "github.com/tobgu/qframe/internal/icolumn" 8 "github.com/tobgu/qframe/internal/scolumn" 9 "github.com/tobgu/qframe/qerrors" 10 ) 11 12 // Code generated from template/... DO NOT EDIT 13 14 // IntView provides a "view" into an int column and can be used for access to individual elements. 15 type IntView struct { 16 icolumn.View 17 } 18 19 // IntView returns a view into an int column identified by name. 20 // 21 // colName - Name of the column. 22 // 23 // Returns an error if the column is missing or of wrong type. 24 // Time complexity O(1). 25 func (qf QFrame) IntView(colName string) (IntView, error) { 26 namedColumn, ok := qf.columnsByName[colName] 27 if !ok { 28 return IntView{}, qerrors.New("IntView", "unknown column: %s", colName) 29 } 30 31 col, ok := namedColumn.Column.(icolumn.Column) 32 if !ok { 33 return IntView{}, qerrors.New( 34 "IntView", 35 "invalid column type, expected: %s, was: %s", "int", namedColumn.DataType()) 36 } 37 38 return IntView{View: col.View(qf.index)}, nil 39 } 40 41 // MustIntView returns a view into an int column identified by name. 42 // 43 // colName - Name of the column. 44 // 45 // Panics if the column is missing or of wrong type. 46 // Time complexity O(1). 47 func (qf QFrame) MustIntView(colName string) IntView { 48 view, err := qf.IntView(colName) 49 if err != nil { 50 panic(qerrors.Propagate("MustIntView", err)) 51 } 52 return view 53 } 54 55 // FloatView provides a "view" into an float column and can be used for access to individual elements. 56 type FloatView struct { 57 fcolumn.View 58 } 59 60 // FloatView returns a view into an float column identified by name. 61 // 62 // colName - Name of the column. 63 // 64 // Returns an error if the column is missing or of wrong type. 65 // Time complexity O(1). 66 func (qf QFrame) FloatView(colName string) (FloatView, error) { 67 namedColumn, ok := qf.columnsByName[colName] 68 if !ok { 69 return FloatView{}, qerrors.New("FloatView", "unknown column: %s", colName) 70 } 71 72 col, ok := namedColumn.Column.(fcolumn.Column) 73 if !ok { 74 return FloatView{}, qerrors.New( 75 "FloatView", 76 "invalid column type, expected: %s, was: %s", "float", namedColumn.DataType()) 77 } 78 79 return FloatView{View: col.View(qf.index)}, nil 80 } 81 82 // MustFloatView returns a view into an float column identified by name. 83 // 84 // colName - Name of the column. 85 // 86 // Panics if the column is missing or of wrong type. 87 // Time complexity O(1). 88 func (qf QFrame) MustFloatView(colName string) FloatView { 89 view, err := qf.FloatView(colName) 90 if err != nil { 91 panic(qerrors.Propagate("MustFloatView", err)) 92 } 93 return view 94 } 95 96 // BoolView provides a "view" into an bool column and can be used for access to individual elements. 97 type BoolView struct { 98 bcolumn.View 99 } 100 101 // BoolView returns a view into an bool column identified by name. 102 // 103 // colName - Name of the column. 104 // 105 // Returns an error if the column is missing or of wrong type. 106 // Time complexity O(1). 107 func (qf QFrame) BoolView(colName string) (BoolView, error) { 108 namedColumn, ok := qf.columnsByName[colName] 109 if !ok { 110 return BoolView{}, qerrors.New("BoolView", "unknown column: %s", colName) 111 } 112 113 col, ok := namedColumn.Column.(bcolumn.Column) 114 if !ok { 115 return BoolView{}, qerrors.New( 116 "BoolView", 117 "invalid column type, expected: %s, was: %s", "bool", namedColumn.DataType()) 118 } 119 120 return BoolView{View: col.View(qf.index)}, nil 121 } 122 123 // MustBoolView returns a view into an bool column identified by name. 124 // 125 // colName - Name of the column. 126 // 127 // Panics if the column is missing or of wrong type. 128 // Time complexity O(1). 129 func (qf QFrame) MustBoolView(colName string) BoolView { 130 view, err := qf.BoolView(colName) 131 if err != nil { 132 panic(qerrors.Propagate("MustBoolView", err)) 133 } 134 return view 135 } 136 137 // StringView provides a "view" into an string column and can be used for access to individual elements. 138 type StringView struct { 139 scolumn.View 140 } 141 142 // StringView returns a view into an string column identified by name. 143 // 144 // colName - Name of the column. 145 // 146 // Returns an error if the column is missing or of wrong type. 147 // Time complexity O(1). 148 func (qf QFrame) StringView(colName string) (StringView, error) { 149 namedColumn, ok := qf.columnsByName[colName] 150 if !ok { 151 return StringView{}, qerrors.New("StringView", "unknown column: %s", colName) 152 } 153 154 col, ok := namedColumn.Column.(scolumn.Column) 155 if !ok { 156 return StringView{}, qerrors.New( 157 "StringView", 158 "invalid column type, expected: %s, was: %s", "string", namedColumn.DataType()) 159 } 160 161 return StringView{View: col.View(qf.index)}, nil 162 } 163 164 // MustStringView returns a view into an string column identified by name. 165 // 166 // colName - Name of the column. 167 // 168 // Panics if the column is missing or of wrong type. 169 // Time complexity O(1). 170 func (qf QFrame) MustStringView(colName string) StringView { 171 view, err := qf.StringView(colName) 172 if err != nil { 173 panic(qerrors.Propagate("MustStringView", err)) 174 } 175 return view 176 } 177 178 // EnumView provides a "view" into an enum column and can be used for access to individual elements. 179 type EnumView struct { 180 ecolumn.View 181 } 182 183 // EnumView returns a view into an enum column identified by name. 184 // 185 // colName - Name of the column. 186 // 187 // Returns an error if the column is missing or of wrong type. 188 // Time complexity O(1). 189 func (qf QFrame) EnumView(colName string) (EnumView, error) { 190 namedColumn, ok := qf.columnsByName[colName] 191 if !ok { 192 return EnumView{}, qerrors.New("EnumView", "unknown column: %s", colName) 193 } 194 195 col, ok := namedColumn.Column.(ecolumn.Column) 196 if !ok { 197 return EnumView{}, qerrors.New( 198 "EnumView", 199 "invalid column type, expected: %s, was: %s", "enum", namedColumn.DataType()) 200 } 201 202 return EnumView{View: col.View(qf.index)}, nil 203 } 204 205 // MustEnumView returns a view into an enum column identified by name. 206 // 207 // colName - Name of the column. 208 // 209 // Panics if the column is missing or of wrong type. 210 // Time complexity O(1). 211 func (qf QFrame) MustEnumView(colName string) EnumView { 212 view, err := qf.EnumView(colName) 213 if err != nil { 214 panic(qerrors.Propagate("MustEnumView", err)) 215 } 216 return view 217 }