Expand description
§wow_cdbc
A library for parsing World of Warcraft DBC (Database Client) files.
§Features
- Parse DBC files from World of Warcraft
- Support for different DBC versions (WDBC, WDB2, WDB5, etc.)
- Schema-based parsing with validation
- Export to JSON and CSV formats
- Command-line interface for working with DBC files
§Example
use std::fs::File;
use std::io::BufReader;
use wow_cdbc::{DbcParser, FieldType, Schema, SchemaField, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open a DBC file
let file = File::open("SpellItemEnchantment.dbc")?;
let mut reader = BufReader::new(file);
// Parse the DBC file
let parser = DbcParser::parse(&mut reader)?;
// Print header information
let header = parser.header();
println!("Record Count: {}", header.record_count);
println!("Field Count: {}", header.field_count);
// Define a schema for SpellItemEnchantment.dbc
let mut schema = Schema::new("SpellItemEnchantment");
schema.add_field(SchemaField::new("ID", FieldType::UInt32));
schema.add_field(SchemaField::new("Charges", FieldType::UInt32));
schema.add_field(SchemaField::new("Type1", FieldType::UInt32));
schema.add_field(SchemaField::new("Type2", FieldType::UInt32));
schema.add_field(SchemaField::new("Type3", FieldType::UInt32));
schema.add_field(SchemaField::new("Amount1", FieldType::Int32));
schema.add_field(SchemaField::new("Amount2", FieldType::Int32));
schema.add_field(SchemaField::new("Amount3", FieldType::Int32));
schema.add_field(SchemaField::new("ItemID", FieldType::UInt32));
schema.add_field(SchemaField::new("Description", FieldType::String));
schema.set_key_field("ID");
// Apply the schema and parse records
let parser = parser.with_schema(schema)?;
let record_set = parser.parse_records()?;
// Access records
if let Some(record) = record_set.get_record(0) {
if let Value::UInt32(id) = record.get_value_by_name("ID").unwrap() {
println!("ID: {}", id);
}
if let Value::StringRef(desc_ref) = record.get_value_by_name("Description").unwrap() {
let desc = record_set.get_string(*desc_ref)?;
println!("Description: {}", desc);
}
}
// Look up a record by key
if let Some(record) = record_set.get_record_by_key(123) {
// Work with the record...
}
Ok(())
}Structs§
- Cached
String Block - A cached string block for efficient string lookups
- DbcHeader
- Represents a DBC file header
- DbcParser
- Parser for DBC files
- DbcWriter
- Writer for DBC files
- Discovered
Field - Represents a discovered field type with confidence level
- Discovered
Schema - Represents a complete discovered schema
- Lazy
DbcParser - A lazy-loading DBC parser
- Lazy
Record Iterator - A record iterator that loads records on-demand
- Record
- Represents a record in a DBC file
- Record
Set - Represents a collection of records from a DBC file
- Schema
- Represents a schema for a DBC file
- Schema
Discoverer - Schema discoverer for DBC files
- Schema
Field - Represents a field in a DBC schema
- String
Block - Represents a string block in a DBC file
- String
Ref - Represents a string reference in a DBC file
- Wdb2
Header - WDB2 header (Cataclysm 4.0+)
- Wdb5
Header - WDB5 header (Mists of Pandaria)
Enums§
- Confidence
- Confidence level for a field type detection
- DbcVersion
- DBC file format version
- Error
- Errors that can occur when parsing a DBC file
- Field
Type - Represents the type of a field in a DBC record
- Value
- Represents a value in a DBC record