1 /* $NetBSD: token.h,v 1.1.1.1 2016/01/13 18:41:49 christos Exp $ */ 2 3 // -*- C++ -*- 4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 5 Written by James Clark (jjc@jclark.com) 6 7 This file is part of groff. 8 9 groff is free software; you can redistribute it and/or modify it under 10 the terms of the GNU General Public License as published by the Free 11 Software Foundation; either version 2, or (at your option) any later 12 version. 13 14 groff is distributed in the hope that it will be useful, but WITHOUT ANY 15 WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 for more details. 18 19 You should have received a copy of the GNU General Public License along 20 with groff; see the file COPYING. If not, write to the Free Software 21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23 enum token_type { 24 TOKEN_OTHER, 25 TOKEN_UPPER, 26 TOKEN_LOWER, 27 TOKEN_ACCENT, 28 TOKEN_PUNCT, 29 TOKEN_HYPHEN, 30 TOKEN_RANGE_SEP 31 }; 32 33 class token_info { 34 private: 35 token_type type; 36 const char *sort_key; 37 const char *other_case; 38 public: 39 token_info(); 40 void set(token_type, const char *sk = 0, const char *oc = 0); 41 void lower_case(const char *start, const char *end, string &result) const; 42 void upper_case(const char *start, const char *end, string &result) const; 43 void sortify(const char *start, const char *end, string &result) const; 44 int sortify_non_empty(const char *start, const char *end) const; 45 int is_upper() const; 46 int is_lower() const; 47 int is_accent() const; 48 int is_other() const; 49 int is_punct() const; 50 int is_hyphen() const; 51 int is_range_sep() const; 52 }; 53 54 inline int token_info::is_upper() const 55 { 56 return type == TOKEN_UPPER; 57 } 58 59 inline int token_info::is_lower() const 60 { 61 return type == TOKEN_LOWER; 62 } 63 64 inline int token_info::is_accent() const 65 { 66 return type == TOKEN_ACCENT; 67 } 68 69 inline int token_info::is_other() const 70 { 71 return type == TOKEN_OTHER; 72 } 73 74 inline int token_info::is_punct() const 75 { 76 return type == TOKEN_PUNCT; 77 } 78 79 inline int token_info::is_hyphen() const 80 { 81 return type == TOKEN_HYPHEN; 82 } 83 84 inline int token_info::is_range_sep() const 85 { 86 return type == TOKEN_RANGE_SEP; 87 } 88 89 int get_token(const char **ptr, const char *end); 90 const token_info *lookup_token(const char *start, const char *end); 91