Changeset 194 for trunk/markup_stats.cxx


Ignore:
Timestamp:
Aug 18, 2008, 8:26:27 AM (11 years ago)
Author:
cameron
Message:

Leaf/Interior? node counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/markup_stats.cxx

    r185 r194  
    118118
    119119
     120#ifdef LEAF_COUNTING
     121int at_start = 1;
     122int leaf_count = 0;
     123int interior_count = 0;
     124#endif
     125
    120126/* Action routine for an XML comment in "<!--"  "-->" brackets. */
    121127template <class B>
     
    159165inline void ParsingEngine<B>::EmptyElement_action(unsigned char * item, int lgth) {
    160166        empty_elem_count +=1;
    161        
     167#ifdef LEAF_COUNTING
     168        int at_start = 0;
     169        leaf_count++;
     170#endif
     171
    162172        #if defined(CALC_AVG)
    163173                empty_elem_length += lgth;
     
    169179inline void ParsingEngine<B>::StartTag_action(unsigned char * item, int lgth) {
    170180        start_tag_count +=1;
     181#ifdef LEAF_COUNTING
     182        at_start = 1;
     183#endif
    171184       
    172185        #if defined(CALC_AVG)
     
    183196inline void ParsingEngine<B>::EndTag_action(unsigned char * item, int lgth) {
    184197        end_tag_count +=1;
     198#ifdef LEAF_COUNTING
     199        leaf_count += at_start;
     200        interior_count += (1 - at_start);
     201        at_start = 0;
     202#endif
    185203       
    186204        #if defined(CALC_AVG)
     
    538556        print_stats("error item", error_item_count, error_item_length);
    539557        printf("Maximum nesting depth = %i\n", max_nesting_depth);
     558#ifdef LEAF_COUNTING
     559        printf("%i leaf nodes, %i interior nodes.\n", leaf_count, interior_count);
     560#endif
    540561       
    541562        return(0);
Note: See TracChangeset for help on using the changeset viewer.