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