diff options
author | David Tardon <dtardon@redhat.com> | 2015-05-24 19:01:01 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2015-05-24 19:08:30 +0200 |
commit | a4f9eb15bb0d9d2e9b127be0d371b25d0fe39892 (patch) | |
tree | 6765c38e4e21447c7c65cf34de16ec045af4144d /HACKING | |
parent | 4d9c13619fedc122a390b4a48d76b5087e3c9968 (diff) |
add some hacking notes
Change-Id: Ib0fd2ae0eae1e83ec9f4de961148ab0506c96cb5
Diffstat (limited to 'HACKING')
-rw-r--r-- | HACKING | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -78,3 +78,46 @@ problem and is even encouraged. Remember, the important thing is to have fun. :-) These rules are a means, not an end. Happy hacking! + += Hacking notes = + +== Main entities == + +* *Parser: a parser :-) Passes raw data to collector for further processing. +* *Collector: an output producer; uses the data passed to it from parser. +* IWORKPropertyMap: a type-safe property map. A property map is + typically not used directly, except in the parser. Instead, it is + wrapped in an IWORKStyle. +* IWORKStyleStack: a hierarchy of currently applied styles. It allows + lookup of properties without checking multiple styles explicitly. +* IWORKDocumentInterface: an amalgamation of librevenge document interfaces, + to allow common handling of some parts of the file format. + +See the documentation for concrete classes for more details. + +== Tokenizer == + +We use gperf to generate lookup maps for XML tokens. These are split by +namespace: names in 'sf' and 'sfa' namespaces are in IWORKToken, 'key' +in in KEYToken, 'ls' in NUMToken and 'sl' in PAGToken. To add a new +token, add it into the enum in appropriate *Token.h and define it in +*Token.gperf. + +== Type-safe property map == + +To add a new property, declare it in IWORKProperties.h and define in +IWORKProperties.cpp. + +== XML Parser == + +Parsing is done by parser context classes. These handle a specific XML +element or a class of elements (e.g., references or styles). The +contexts have access to a global state (which is format-specific), but +most of the results are passed either to the collector or up to the +parent context. In the later case, the output is saved through +references to boost::optional<Foo> passed in the constructor. + +The context classes employ various suffixes for better orientation. +'Context' is common for several elements, 'Element' is for a single +element, 'Base' is a base class adding a common functionality, which is +not supposed to be used directly. |