Lines Matching refs:field

41 // the field (or vector element) is a struct.
61 // Get a field, if you know it's an integer, and its exact type.
63 const reflection::Field &field) {
64 assert(sizeof(T) == GetTypeSize(field.type()->base_type()));
65 return table.GetField<T>(field.offset(),
66 static_cast<T>(field.default_integer()));
69 // Get a field, if you know it's floating point and its exact type.
71 const reflection::Field &field) {
72 assert(sizeof(T) == GetTypeSize(field.type()->base_type()));
73 return table.GetField<T>(field.offset(),
74 static_cast<T>(field.default_real()));
77 // Get a field, if you know it's a string.
79 const reflection::Field &field) {
80 assert(field.type()->base_type() == reflection::String);
81 return table.GetPointer<const String *>(field.offset());
84 // Get a field, if you know it's a vector.
86 const reflection::Field &field) {
87 assert(field.type()->base_type() == reflection::Vector &&
88 sizeof(T) == GetTypeSize(field.type()->element()));
89 return table.GetPointer<Vector<T> *>(field.offset());
92 // Get a field, if you know it's a vector, generically.
94 // field.type()->element() in any of GetAnyVectorElemI below etc.
96 const reflection::Field &field) {
97 return table.GetPointer<VectorOfAny *>(field.offset());
100 // Get a field, if you know it's a table.
102 const reflection::Field &field) {
103 assert(field.type()->base_type() == reflection::Obj ||
104 field.type()->base_type() == reflection::Union);
105 return table.GetPointer<Table *>(field.offset());
108 // Get a field, if you know it's a struct.
110 const reflection::Field &field) {
111 // TODO: This does NOT check if the field is a table or struct, but we'd need
113 assert(field.type()->base_type() == reflection::Obj);
114 return table.GetStruct<const Struct *>(field.offset());
117 // Get a structure's field, if you know it's a struct.
119 const reflection::Field &field) {
120 assert(field.type()->base_type() == reflection::Obj);
121 return structure.GetStruct<const Struct *>(field.offset());
138 // Get any table field as a 64bit int, regardless of what type it is.
140 const reflection::Field &field) {
141 auto field_ptr = table.GetAddressOf(field.offset());
142 return field_ptr ? GetAnyValueI(field.type()->base_type(), field_ptr)
143 : field.default_integer();
146 // Get any table field as a double, regardless of what type it is.
148 const reflection::Field &field) {
149 auto field_ptr = table.GetAddressOf(field.offset());
150 return field_ptr ? GetAnyValueF(field.type()->base_type(), field_ptr)
151 : field.default_real();
155 // Get any table field as a string, regardless of what type it is.
159 const reflection::Field &field,
161 auto field_ptr = table.GetAddressOf(field.offset());
162 return field_ptr ? GetAnyValueS(field.type()->base_type(), field_ptr, schema,
163 field.type()->index())
167 // Get any struct field as a 64bit int, regardless of what type it is.
169 const reflection::Field &field) {
170 return GetAnyValueI(field.type()->base_type(),
171 st.GetAddressOf(field.offset()));
174 // Get any struct field as a double, regardless of what type it is.
176 const reflection::Field &field) {
177 return GetAnyValueF(field.type()->base_type(),
178 st.GetAddressOf(field.offset()));
181 // Get any struct field as a string, regardless of what type it is.
183 const reflection::Field &field) {
184 return GetAnyValueS(field.type()->base_type(),
185 st.GetAddressOf(field.offset()), nullptr, -1);
230 const reflection::Field &field) {
231 return (T *)table.GetAddressOf(field.offset());
236 const reflection::Field &field) {
237 return (T *)st.GetAddressOf(field.offset());
242 // Set any scalar field, if you know its exact type.
243 template<typename T> bool SetField(Table *table, const reflection::Field &field,
245 assert(sizeof(T) == GetTypeSize(field.type()->base_type()));
246 return table->SetField(field.offset(), val);
257 // Set any table field as a 64bit int, regardless of type what it is.
258 inline bool SetAnyFieldI(Table *table, const reflection::Field &field,
260 auto field_ptr = table->GetAddressOf(field.offset());
262 SetAnyValueI(field.type()->base_type(), field_ptr, val);
266 // Set any table field as a double, regardless of what type it is.
267 inline bool SetAnyFieldF(Table *table, const reflection::Field &field,
269 auto field_ptr = table->GetAddressOf(field.offset());
271 SetAnyValueF(field.type()->base_type(), field_ptr, val);
275 // Set any table field as a string, regardless of what type it is.
276 inline bool SetAnyFieldS(Table *table, const reflection::Field &field,
278 auto field_ptr = table->GetAddressOf(field.offset());
280 SetAnyValueS(field.type()->base_type(), field_ptr, val);
284 // Set any struct field as a 64bit int, regardless of type what it is.
285 inline void SetAnyFieldI(Struct *st, const reflection::Field &field,
287 SetAnyValueI(field.type()->base_type(), st->GetAddressOf(field.offset()),
291 // Set any struct field as a double, regardless of type what it is.
292 inline void SetAnyFieldF(Struct *st, const reflection::Field &field,
294 SetAnyValueF(field.type()->base_type(), st->GetAddressOf(field.offset()),
298 // Set any struct field as a string, regardless of type what it is.
299 inline void SetAnyFieldS(Struct *st, const reflection::Field &field,
301 SetAnyValueS(field.type()->base_type(), st->GetAddressOf(field.offset()),
424 inline bool SetFieldT(Table *table, const reflection::Field &field,
426 assert(sizeof(uoffset_t) == GetTypeSize(field.type()->base_type()));
427 return table->SetPointer(field.offset(), val);