# HG changeset patch # User Diggory Hardy # Date 1203937890 0 # Node ID 914fed025adbed6764265b6742b7f4a3e83ca4d6 # Parent bff0d802cb7d5753237819d7f0ef1610f242d7cd Fixed two little bugs. Fixed a bug preventing mergetag from saving headers it read. Fixed a bug where Input.event() would cause a segfault when no config was loaded. Now it fails silently, to avoid message spam on every single event. As a result, input config filtering via headers tag "Configs" now works (not particularly useful though). committer: Diggory Hardy diff -r bff0d802cb7d -r 914fed025adb mde/mergetag/datasection.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mde/mergetag/datasection.d Mon Feb 25 11:11:30 2008 +0000 @@ -0,0 +1,51 @@ +/** This module contains the interface DataSection used by DataSet. +* +* It has been moved from the dataset module to avoid cyclic dependancies, since defaultdata depends +* on DataSection and dataset depends on defaultdata. +* +* Also some base mergetag symbols have been moved here. +*/ +module mde.mergetag.datasection; + +/** Typedef for data & section indexes (can be changed to ulong if necessary.) */ +typedef char[] ID; + +/** + * Interface for data storage classes, which contain all data-tags loaded from a single section of a + * file. + * + * A class implementing this may implement the addTag function to do whatever it likes with the + * data passed. DefaultData is one implementation which separates this data out into supported + * types and stores it appropriately (allowing merging with existing entries by keeping whichever + * tag was last loaded), while ignoring unsupported types. A different + * implementation could filter out the tags desired and use them directly, and ignore the rest. + * + * The tango.scrapple.text.convert.parseTo module provides a useful set of templated functions to + * convert the data accordingly. It is advised to keep the type definitions as defined in the file- + * format except for user-defined types, although this isn't necessary for library operation + * (addTag and writeAll are solely responsible for using and setting the type, ID and data fields). + * + * Another idea for a DataSection class: + * Use a void*[ID] variable to store all data (may also need a type var for each item). + * addTag should call a templated function which calls parse then casts to a void* and stores the data. + * Use a templated get(T)(ID) method which checks the type and casts to T. + */ +interface DataSection +{ + /** Delegate passed to writeAll. */ + typedef void delegate (char[],ID,char[]) ItemDelg; + + /** Handles parsing of data items for all recognised types. + * + * Should ignore unsupported types/unwanted tags. + * + * TextExceptions (thrown by parseTo/parseFrom) are caught and a warning logged; execution + * then continues (so the offending tag gets dropped). */ + void addTag (char[],ID,char[]); + + /** Responsible for getting all data tags saved. + * + * writeAll should call the ItemDelg once for each tag to be saved with parameters in the same + * form as received by addTag (char[] type, ID id, char[] data). */ + void writeAll (ItemDelg); +}