bookloupe/counters.h
author ali <ali@juiblex.co.uk>
Sun Oct 20 21:31:51 2013 +0100 (2013-10-20)
changeset 188 a4658f2df227
parent 103 adc06e9e8470
permissions -rw-r--r--
Bugs #13+14: charsets in configuration files
     1 #ifndef COUNTERS_H
     2 #define COUNTERS_H
     3 
     4 #include <glib.h>
     5 
     6 #define COUNTERS_ERROR counters_error_quark()
     7 
     8 typedef enum
     9 {
    10     COUNTERS_ERROR_FAILED,                 /* Generic failure */
    11 } CountersError;
    12 
    13 /* Special counters live in the private use area */
    14 enum {
    15     COUNTER_ILLUSTRATION=0xE000,
    16     NO_SPECIAL_COUNTERS
    17 };
    18 
    19 typedef enum {
    20     OPENING_QUOTE,
    21     CLOSING_QUOTE,
    22     NEUTRAL_QUOTE,
    23     INVALID_QUOTE
    24 } QuoteClass;
    25 
    26 #define QUOTE_CLASS(c) \
    27     (((c)==CHAR_RD_QUOTE || (c)==CHAR_RS_QUOTE)?CLOSING_QUOTE: \
    28      ((c)==CHAR_LD_QUOTE || (c)==CHAR_LS_QUOTE || (c)==CHAR_OPEN_SQUOTE)?\
    29      OPENING_QUOTE:((c)==CHAR_DQUOTE || (c)==CHAR_SQUOTE)?NEUTRAL_QUOTE:\
    30      INVALID_QUOTE)
    31 
    32 struct counters {
    33     GTree *matching;
    34     int c_unders;
    35     GSList *open_quotes;
    36 };
    37 
    38 GQuark counters_error_quark(void);
    39 gboolean innermost_quote_matches(struct counters *counters,gunichar ch);
    40 gboolean count_quote(struct counters *counters,gunichar ch,QuoteClass klass,
    41   GError **err);
    42 void increment_matching(struct counters *counters,gunichar ch,gboolean open);
    43 int matching_count(const struct counters *counters,gunichar ch,gboolean open);
    44 int matching_difference(const struct counters *counters,gunichar ch);
    45 void counters_reset(struct counters *counters);
    46 void counters_destroy(struct counters *counters);
    47 
    48 #endif /* COUNTERS_H */