vn/code/vn_config.cpp

48 lines
1.2 KiB
C++
Raw Normal View History

2023-06-18 10:09:36 +00:00
static config_entry *Config_FindEntryByName(config *Config, string Name)
{
config_entry *Result = 0;
u32 BucketSlot = HashString(Name) % ArrayCount(Config->EntryBuckets);
config_entry_bucket *Bucket = Config->EntryBuckets + BucketSlot;
for(config_entry *Entry = Bucket->First;
Entry != 0;
Entry = Entry->Next)
{
if(AreEqual(Entry->Name, Name))
{
Result = Entry;
break;
}
}
return(Result);
}
static void Config_ReadFile(config *Config, string Path)
{
}
static void Config_WriteFile(config *Config)
{
}
static void Config_BindEntry(config *Config, string Name, config_entry_type Type, void *Target)
{
config_entry *Entry = Config_FindEntryByName(Config, Name);
if(!Entry)
{
Entry = PushStruct(&Config->Arena, config_entry);
Entry->Name = Name;
Entry->Type = Type;
u32 BucketSlot = HashString(Name) % ArrayCount(Config->EntryBuckets);
config_entry_bucket *Bucket = Config->EntryBuckets + BucketSlot;
DLLInsertLast(Bucket->First, Bucket->Last, Entry);
}
Assert(Entry->Type == Type);
Entry->Target = Target;
}