Ignore:
Timestamp:
Nov 22, 2005 11:51:50 PM (17 years ago)
Author:
bennylp
Message:

More optimizations for msg parser etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/include/pjlib-util/scanner.h

    r73 r77  
    194194typedef struct pj_scanner 
    195195{ 
    196     char *begin;        /**< Start of input buffer. */ 
    197     char *end;          /**< End of input buffer.   */ 
    198     char *curptr;       /**< Current pointer.       */ 
    199     int  line;          /**< Current line.          */ 
    200     int  col;           /**< Current column.        */ 
    201     int  skip_ws;       /**< Skip whitespace flag.  */ 
     196    char *begin;        /**< Start of input buffer.     */ 
     197    char *end;          /**< End of input buffer.       */ 
     198    char *curptr;       /**< Current pointer.           */ 
     199    int   line;         /**< Current line.              */ 
     200    char *start_line;   /**< Where current line starts. */ 
     201    int   skip_ws;      /**< Skip whitespace flag.      */ 
    202202    pj_syn_err_func_ptr callback;   /**< Syntax error callback. */ 
    203203} pj_scanner; 
     
    211211{ 
    212212    char *curptr;       /**< Current scanner's pointer. */ 
    213     int   line;         /**< Current line.      */ 
    214     int   col;          /**< Current column.    */ 
     213    int   line;         /**< Current line.              */ 
     214    char *start_line;   /**< Start of current line.     */ 
    215215} pj_scan_state; 
    216216 
     
    326326/**  
    327327 * Get characters between quotes. If current input doesn't match begin_quote, 
    328  * syntax error will be thrown. 
     328 * syntax error will be thrown. Note that the resulting string will contain 
     329 * the enclosing quote. 
    329330 * 
    330331 * @param scanner       The scanner. 
     
    334335 */ 
    335336PJ_DECL(void) pj_scan_get_quote( pj_scanner *scanner, 
    336                                   int begin_quote, int end_quote,  
    337                                   pj_str_t *out); 
     337                                 int begin_quote, int end_quote,  
     338                                 pj_str_t *out); 
    338339 
    339340/**  
     
    356357 */ 
    357358PJ_DECL(int) pj_scan_get_char( pj_scanner *scanner ); 
    358  
    359  
    360 /**  
    361  * Get a newline from the scanner. A newline is defined as '\\n', or '\\r', or 
    362  * "\\r\\n". If current input is not newline, syntax error will be thrown. 
    363  * 
    364  * @param scanner   The scanner. 
    365  */ 
    366 PJ_DECL(void) pj_scan_get_newline( pj_scanner *scanner ); 
    367359 
    368360 
     
    439431PJ_DECL(int) pj_scan_stricmp( pj_scanner *scanner, const char *s, int len); 
    440432 
     433/** 
     434 * Perform case insensitive string comparison of string in current position, 
     435 * knowing that the string to compare only consists of alphanumeric 
     436 * characters. 
     437 * 
     438 * Note that unlike #pj_scan_stricmp, this function can only return zero or 
     439 * -1. 
     440 * 
     441 * @param scanner   The scanner. 
     442 * @param s         The string to compare with. 
     443 * @param len       Length of the string to compare with. 
     444 * 
     445 * @return          zero if equal or -1. 
     446 * 
     447 * @see strnicmp_alnum, pj_stricmp_alnum 
     448 */ 
     449PJ_DECL(int) pj_scan_stricmp_alnum( pj_scanner *scanner, const char *s,  
     450                                    int len); 
     451 
     452 
     453/**  
     454 * Get a newline from the scanner. A newline is defined as '\\n', or '\\r', or 
     455 * "\\r\\n". If current input is not newline, syntax error will be thrown. 
     456 * 
     457 * @param scanner   The scanner. 
     458 */ 
     459PJ_DECL(void) pj_scan_get_newline( pj_scanner *scanner ); 
     460 
    441461 
    442462/**  
     
    448468PJ_DECL(void) pj_scan_skip_whitespace( pj_scanner *scanner ); 
    449469 
     470 
     471/** 
     472 * Skip current line. 
     473 * 
     474 * @param scanner   The scanner. 
     475 */ 
     476PJ_DECL(void) pj_scan_skip_line( pj_scanner *scanner ); 
    450477 
    451478/**  
     
    470497 
    471498/** 
     499 * Get current column position. 
     500 * 
     501 * @param scanner   The scanner. 
     502 * 
     503 * @return          The column position. 
     504 */ 
     505PJ_INLINE(int) pj_scan_get_col( pj_scanner *scanner ) 
     506{ 
     507    return scanner->curptr - scanner->start_line; 
     508} 
     509 
     510/** 
    472511 * @} 
    473512 */ 
Note: See TracChangeset for help on using the changeset viewer.