(&self, module: &ModuleDef, table: &TableDef, schema: TableSchema)
| 41 | |
| 42 | impl Lang for UnrealCpp<'_> { |
| 43 | fn generate_table_file_from_schema(&self, module: &ModuleDef, table: &TableDef, schema: TableSchema) -> OutputFile { |
| 44 | let module_prefix = self.module_prefix; |
| 45 | let struct_name = type_ref_name(self.module_prefix, module, table.product_type_ref); |
| 46 | let table_pascal = format!("{module_prefix}{}", table.name.deref().to_case(Case::Pascal)); |
| 47 | let self_header = table_pascal.clone() + "Table"; |
| 48 | |
| 49 | let mut output = UnrealCppAutogen::new( |
| 50 | &[ |
| 51 | "Types/Builtins.h", |
| 52 | &format!("ModuleBindings/Types/{struct_name}Type.g.h"), |
| 53 | "Tables/RemoteTable.h", |
| 54 | "DBCache/WithBsatn.h", |
| 55 | "DBCache/TableHandle.h", |
| 56 | "DBCache/TableCache.h", |
| 57 | ], |
| 58 | &self_header, |
| 59 | false, |
| 60 | ); |
| 61 | |
| 62 | let row_struct = format!("F{struct_name}Type"); // e.g. "FUserType", "FMessageType" |
| 63 | let handle_cls = format!("U{table_pascal}Table"); // "UMessageTable" |
| 64 | let table_name = table.name.deref().to_string(); |
| 65 | |
| 66 | // Generate unique index classes first |
| 67 | let product_type = module.typespace_for_generate()[table.product_type_ref].as_product(); |
| 68 | |
| 69 | let mut unique_indexes = Vec::new(); |
| 70 | let mut multi_key_indexes = Vec::new(); |
| 71 | |
| 72 | for idx in iter_indexes(table) { |
| 73 | let Some(accessor_name) = idx.accessor_name.as_ref() else { |
| 74 | continue; |
| 75 | }; |
| 76 | |
| 77 | // Whatever the index algorithm on the host, |
| 78 | // the client can still use btrees. |
| 79 | let columns = idx.algorithm.columns(); |
| 80 | if schema.is_unique(&columns) { |
| 81 | if let Some(col) = columns.as_singleton() { |
| 82 | let (f_name, f_ty) = &product_type.unwrap().elements[col.idx()]; |
| 83 | let field_name = f_name.deref().to_case(Case::Pascal); |
| 84 | let field_type = |
| 85 | cpp_ty_fmt_with_module(self.module_prefix, module, f_ty, self.module_name).to_string(); |
| 86 | let index_name = accessor_name.deref().to_case(Case::Pascal); |
| 87 | let index_class_name = format!("U{table_pascal}{index_name}UniqueIndex"); |
| 88 | let key_type = field_type.clone(); |
| 89 | let field_name_lowercase = field_name.to_lowercase(); |
| 90 | |
| 91 | writeln!(output, "UCLASS(Blueprintable)"); |
| 92 | writeln!( |
| 93 | output, |
| 94 | "class {} {index_class_name} : public UObject", |
| 95 | self.get_api_macro() |
| 96 | ); |
| 97 | writeln!(output, "{{"); |
| 98 | writeln!(output, " GENERATED_BODY()"); |
| 99 | writeln!(output); |
| 100 | writeln!(output, "private:"); |
nothing calls this directly
no test coverage detected