Easy...
If you understand classes and lists, really. I'm going to change from linked lists to plain lists (from C++ list to C++ vector, I think is the equivalent), if it makes it work better. But essentially, to note every NPC out of a mod, this is the code:
Datafile thatFile;
thatFile.load("yourmod.esp");
foreach ( Record cRec in thatFile.records )
if ( cRec.type == "NPC_" ) printf("Found an NPC!\n");
It doesn't do much, but it shows how simple the system can be.
To get a particular record:
datafile.records[index]
For subrecords in a record, you could use this (prints everything):
Datafile thatFile;
thatFile.load("yourmod.esp");
foreach ( Record cRec in thatFile.records )
{
printf("Type: %s\n", cRec.type);
foreach ( Subrecord sRec in cRec.sub )
{
printf(" Type: %s\n Data: %s\n", sRec.type, sRec.data);
}
}
I'm having a few issues with .Net trying to use Unicode (2-byte) characters for stuff, which ruins the files (the ESP format uses only 1-byte, as far as I've seen). That's only related to saving, though.
Loading works, except for subrecords with flags (I haven't figured out which have them and don't, so ATM they get prepended to the data).