Changeset 197 for trunk/src/engine.h


Ignore:
Timestamp:
Oct 2, 2008, 11:15:25 AM (11 years ago)
Author:
cameron
Message:

Rearchitecting for WorkingCharacterSet?, Document Characet Set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine.h

    r188 r197  
    88#ifndef ENGINE_H
    99#define ENGINE_H
     10
     11/*  Parabix provides strings to the application using the WorkingCharacterSet.
     12    This parameter is set by template instantiation; normally only one
     13    WorkingCharacterSet parameter is chosen.  However, it is possible
     14    to compile different parsers having different WorkingCharacterSet
     15    parameters within one run-time code base.
     16*/
     17
     18enum WorkingCharacterSet {UTF_8, UTF_16, UTF_32};
    1019
    1120#include "xmlmodel.h"
     
    2130data.  */
    2231
     32template <WorkingCharacterSet W>
    2333class Parser_Interface {
    2434public:
     
    4454        Model_Info * model_info;
    4555        Entity_Info * entity_Info;
    46 protected:
    47         /* Co-classes */
    48 
    49         Byteplex * byteplex;   
    50         Bitplex * bitplex;
    51         Lexer_Interface * lexer;
    52         /* Parallel data streams for current buffer full of XML data. */
    53         BytePack * x8data;
    54         LexicalStreamSet * buf;
    55                
    56         int buffer_base_pos;
    57         int buffer_rel_pos;
    58         int buffer_limit_pos;
     56
     57
     58        /* Action routine for document start. */
     59        void DocumentStart_action();   
     60       
     61        /* Action routine for document end. */
     62        void DocumentEnd_action();
     63       
     64        /* Action routine for an XML comment in "<!--"  "-->" brackets. */
     65        void Comment_action(unsigned char * item, int lgth);
     66       
     67        /* Action routine called upon recognizing "<![CDATA[" to start a CDATA section. */
     68        void CDATA_start_action(unsigned char * CDATA_ptr);
     69
     70        /* Action routine called upon recognizing "]]>" to end a CDATA section. */
     71        void CDATA_end_action(unsigned char * CDATA_end_ptr);
     72       
     73        /* Action routine for an XML processing instruction enclosed in "<?" and "?>" brackets. */
     74        void PI_action(unsigned char * item, int lgth);
     75       
     76        /* Action routine for an empty element enclosed in "<" and "/>" brackets. */
     77        void EmptyElement_action(unsigned char * item, int lgth);
     78       
     79        /* Action routine for a start tag enclosed in "<" and ">" brackets. */
     80        void StartTag_action(unsigned char * item, int lgth);
     81       
     82        /* Action routine for an end tag enclosed in "</" and ">" brackets. */
     83        void EndTag_action(unsigned char * item, int lgth);
     84       
     85        /* Action routine for an error item */
     86        void Error_action(unsigned char * item, int lgth);
     87       
     88        /* Action routine for a text item */
     89        void Text_action(unsigned char * item, int lgth, bool more);
     90       
     91        /* Action routine for a character or entity reference.*/
     92        void Reference_action(unsigned char * item, int lgth);
     93       
     94        /* Action routine for an element name occurring immediately after the
     95        opening "<" of a start tag or empty element tag. */
     96        void ElementName_action(unsigned char * item, int lgth);
     97       
     98        /* Action routine for a processing instruction target name occurring immediately
     99        after the opening "<?" of a processing instruction. */
     100        void PI_Target_action(unsigned char * item, int lgth);
     101       
     102        /* Action routine for an individual attribute/value pair occurring in
     103        a element start tag or an empty element tag. */
     104        void AttributeValue_action(unsigned char * name, int name_lgth,
     105                                   unsigned char * val, int val_lgth);
     106       
     107        /* Action routine for an individual namespace binding occurring in
     108        a element start tag or an empty element tag. */
     109        void Namespace_action(unsigned char * name, int name_end,
     110                              unsigned char * URI, int URI_end);
     111       
     112        /*Action routine for end of buffer events. */
     113        void FinalizeBuffer_action();
     114       
     115        /*Document Type actions.*/
     116        void Doctype_action(unsigned char * item, int lgth);
     117        void PEReference_action(unsigned char * item, int lgth);
     118       
     119        void Prolog_action(unsigned char * item, int lgth);
     120       
     121        void ExtSubsetDecl_action(unsigned char * item, int lgth);
    59122       
    60123};
    61124
    62 template <class B>
    63 class ParsingEngine : public Parser_Interface {
     125template <class B, WorkingCharacterSet W>
     126class ParsingEngine : public Parser_Interface<W> {
    64127public:
    65128        ParsingEngine(Entity_Info * e, Model_Info * m, Byteplex * b, bool is_external);
     
    150213        void Parse_ExtSubsetDecl ();
    151214       
    152         /* Action routine for document start. */
    153         void DocumentStart_action();   
    154        
    155         /* Action routine for document end. */
    156         void DocumentEnd_action();
    157        
    158         /* Action routine for an XML comment in "<!--"  "-->" brackets. */
    159         void Comment_action(unsigned char * item, int lgth);
    160        
    161         /* Action routine called upon recognizing "<![CDATA[" to start a CDATA section. */
    162         void CDATA_start_action(unsigned char * CDATA_ptr);
    163 
    164         /* Action routine called upon recognizing "]]>" to end a CDATA section. */
    165         void CDATA_end_action(unsigned char * CDATA_end_ptr);
    166        
    167         /* Action routine for an XML processing instruction enclosed in "<?" and "?>" brackets. */
    168         void PI_action(unsigned char * item, int lgth);
    169        
    170         /* Action routine for an empty element enclosed in "<" and "/>" brackets. */
    171         void EmptyElement_action(unsigned char * item, int lgth);
    172        
    173         /* Action routine for a start tag enclosed in "<" and ">" brackets. */
    174         void StartTag_action(unsigned char * item, int lgth);
    175        
    176         /* Action routine for an end tag enclosed in "</" and ">" brackets. */
    177         void EndTag_action(unsigned char * item, int lgth);
    178        
    179         /* Action routine for an error item */
    180         void Error_action(unsigned char * item, int lgth);
    181        
    182         /* Action routine for a text item */
    183         void Text_action(unsigned char * item, int lgth, bool more);
    184        
    185         /* Action routine for a character or entity reference.*/
    186         void Reference_action(unsigned char * item, int lgth);
    187        
    188         /* Action routine for an element name occurring immediately after the
    189         opening "<" of a start tag or empty element tag. */
    190         void ElementName_action(unsigned char * item, int lgth);
    191        
    192         /* Action routine for a processing instruction target name occurring immediately
    193         after the opening "<?" of a processing instruction. */
    194         void PI_Target_action(unsigned char * item, int lgth);
    195        
    196         /* Action routine for an individual attribute/value pair occurring in
    197         a element start tag or an empty element tag. */
    198         void AttributeValue_action(unsigned char * name, int name_lgth,
    199                                    unsigned char * val, int val_lgth);
    200        
    201         /* Action routine for an individual namespace binding occurring in
    202         a element start tag or an empty element tag. */
    203         void Namespace_action(unsigned char * name, int name_end,
    204                               unsigned char * URI, int URI_end);
    205        
    206         /*Action routine for end of buffer events. */
    207         void FinalizeBuffer_action();
    208        
    209         /*Document Type actions.*/
    210         void Doctype_action(unsigned char * item, int lgth);
    211         void PEReference_action(unsigned char * item, int lgth);
    212        
    213         void Prolog_action(unsigned char * item, int lgth);
    214        
    215         void ExtSubsetDecl_action(unsigned char * item, int lgth);
     215protected:
     216        /* Co-classes */
     217
     218        Byteplex * byteplex;   
     219        Bitplex * bitplex;
     220        Lexer_Interface * lexer;
     221        /* Parallel data streams for current buffer full of XML data. */
     222        BytePack * x8data;
     223        LexicalStreamSet * buf;
     224               
     225        int buffer_base_pos;
     226        int buffer_rel_pos;
     227        int buffer_limit_pos;
    216228};
    217229
Note: See TracChangeset for help on using the changeset viewer.