diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
| commit | 5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch) | |
| tree | 1a81af141708b826e9c61e8a04019994fcca8298 /src/ops/comp.cc | |
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/ops/comp.cc')
| -rw-r--r-- | src/ops/comp.cc | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/src/ops/comp.cc b/src/ops/comp.cc new file mode 100644 index 0000000..aa40246 --- /dev/null +++ b/src/ops/comp.cc | |||
| @@ -0,0 +1,134 @@ | |||
| 1 | /************************************************************************* | ||
| 2 | * | ||
| 3 | * HTCd - Copyright (C) 1998-2006 Henrik Rydberg | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <ops/operator.h> | ||
| 21 | #include <ops/nnstyle.h> | ||
| 22 | |||
| 23 | OP2_IMPL(lt) {out<<(L<R);} | ||
| 24 | OP2_IMPL(le) {out<<(L<=R);} | ||
| 25 | OP2_IMPL(ge) {out<<(L>=R);} | ||
| 26 | OP2_IMPL(gt) {out<<(L>R);} | ||
| 27 | OP2_IMPL(ltn) {out<<(L.compare(R,cset_lcase)<0);} | ||
| 28 | OP2_IMPL(len) {out<<(L.compare(R,cset_lcase)<=0);} | ||
| 29 | OP2_IMPL(gen) {out<<(L.compare(R,cset_lcase)>=0);} | ||
| 30 | OP2_IMPL(gtn) {out<<(L.compare(R,cset_lcase)>0);} | ||
| 31 | OP2_IMPL(ltnn) {out<<(nncomp(L,R)<0);} | ||
| 32 | OP2_IMPL(lenn) {out<<(nncomp(L,R)<=0);} | ||
| 33 | OP2_IMPL(genn) {out<<(nncomp(L,R)>=0);} | ||
| 34 | OP2_IMPL(gtnn) {out<<(nncomp(L,R)>0);} | ||
| 35 | OP2_IMPL(ltf) {out<<(atof(L)<atof(R));} | ||
| 36 | OP2_IMPL(lef) {out<<(atof(L)<=atof(R));} | ||
| 37 | OP2_IMPL(gef) {out<<(atof(L)>=atof(R));} | ||
| 38 | OP2_IMPL(gtf) {out<<(atof(L)>atof(R));} | ||
| 39 | |||
| 40 | void opAddComp(opmap& M) | ||
| 41 | { | ||
| 42 | OP_ADD(20,lt, | ||
| 43 | "Lexicographic less than\n" | ||
| 44 | "Syntax: (string) lt (string)\n" | ||
| 45 | "Returns: (int)\n" | ||
| 46 | ); | ||
| 47 | OP_ADD(20,le, | ||
| 48 | "Lexicographic less or equal\n" | ||
| 49 | "Syntax: (string) le (string)\n" | ||
| 50 | "Returns: (int)\n" | ||
| 51 | ); | ||
| 52 | OP_ADD(20,ge, | ||
| 53 | "Lexicographic greater or equal\n" | ||
| 54 | "Syntax: (string) ge (string)\n" | ||
| 55 | "Returns: (int)\n" | ||
| 56 | ); | ||
| 57 | OP_ADD(20,gt, | ||
| 58 | "Lexicographic greater than\n" | ||
| 59 | "Syntax: (string) gt (string)\n" | ||
| 60 | "Returns: (int)\n" | ||
| 61 | ); | ||
| 62 | |||
| 63 | OP_ADD(20,ltn, | ||
| 64 | "Lexicographic less than, case insensitive\n" | ||
| 65 | "Syntax: (string) ltn (string)\n" | ||
| 66 | "Returns: (int)\n" | ||
| 67 | ); | ||
| 68 | OP_ADD(20,len, | ||
| 69 | "Lexicographic less or equal, case insensitive\n" | ||
| 70 | "Syntax: (string) len (string)\n" | ||
| 71 | "Returns: (int)\n" | ||
| 72 | ); | ||
| 73 | OP_ADD(20,gen, | ||
| 74 | "Lexicographic greater or equal, case insensitive\n" | ||
| 75 | "Syntax: (string) gen (string)\n" | ||
| 76 | "Returns: (int)\n" | ||
| 77 | ); | ||
| 78 | OP_ADD(20,gtn, | ||
| 79 | "Lexicographic greater than, case insensitive\n" | ||
| 80 | "Syntax: (string) gtn (string)\n" | ||
| 81 | "Returns: (int)\n" | ||
| 82 | ); | ||
| 83 | |||
| 84 | OP_ADD(20,ltnn, | ||
| 85 | "Lexicographic less than, NN-style\n" | ||
| 86 | "Syntax: (string) ltnn (string)\n" | ||
| 87 | "Returns: (int)\n" | ||
| 88 | "\n" | ||
| 89 | "NN-style compares names as <lastname> <initials>\n" | ||
| 90 | ); | ||
| 91 | OP_ADD(20,lenn, | ||
| 92 | "Lexicographic less or equal, NN-style\n" | ||
| 93 | "Syntax: (string) lenn (string)\n" | ||
| 94 | "Returns: (int)\n" | ||
| 95 | "\n" | ||
| 96 | "NN-style compares names as <lastname> <initials>\n" | ||
| 97 | ); | ||
| 98 | OP_ADD(20,genn, | ||
| 99 | "Lexicographic greater or equal, NN-style\n" | ||
| 100 | "Syntax: (string) genn (string)\n" | ||
| 101 | "Returns: (int)\n" | ||
| 102 | "\n" | ||
| 103 | "NN-style compares names as <lastname> <initials>\n" | ||
| 104 | ); | ||
| 105 | OP_ADD(20,gtnn, | ||
| 106 | "Lexicographic greater than, NN-style\n" | ||
| 107 | "Syntax: (string) gtnn (string)\n" | ||
| 108 | "Returns: (int)\n" | ||
| 109 | "\n" | ||
| 110 | "NN-style compares names as <lastname> <initials>\n" | ||
| 111 | ); | ||
| 112 | |||
| 113 | OP_ADDN(20,ltf,<, | ||
| 114 | "Arithmetic less than\n" | ||
| 115 | "Syntax: (real) < (real)\n" | ||
| 116 | "Returns: (int)\n" | ||
| 117 | ); | ||
| 118 | OP_ADDN(20,lef,<=, | ||
| 119 | "Arithmetic less or equal\n" | ||
| 120 | "Syntax: (real) <= (real)\n" | ||
| 121 | "Returns: (int)\n" | ||
| 122 | ); | ||
| 123 | OP_ADDN(20,gef,>=, | ||
| 124 | "Arithmetic greater or equal\n" | ||
| 125 | "Syntax: (real) >= (real)\n" | ||
| 126 | "Returns: (int)\n" | ||
| 127 | ); | ||
| 128 | OP_ADDN(20,gtf,>, | ||
| 129 | "Arithmetic greater than\n" | ||
| 130 | "Syntax: (real) > (real)\n" | ||
| 131 | "Returns: (int)\n" | ||
| 132 | ); | ||
| 133 | |||
| 134 | } | ||
