libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
operator.h
1 /* Copyright (C) 2018 Chris Piker <chris-piker@uiowa.edu>
2  *
3  * This file is part of libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _das_operator_h_
19 #define _das_operator_h_
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
29 /* Invalid Operator */
30 #define D2OP_INVALID 0
31 
32 /* Unary operators, before */
33 #define D2UOP_SIGN 1
34 #define D2UOP_SQRT 7
35 #define D2UOP_CURT 8
36 #define D2UOP_LOG10 9
37 #define D2UOP_LN 10
38 #define D2UOP_COS 11
39 #define D2UOP_SIN 12
40 #define D2UOP_TAN 13
41 
42 /* Unary operators after */
43 #define D2UOP_SQUARE 101
44 #define D2UOP_CUBE 102
45 #define D2UOP_INV 103
46 #define D2UOP_INVSQ 104
47 #define D2UOP_INVCUBE 105
48 
49 /* Binary operators */
50 #define D2BOP_ADD 201
51 #define D2BOP_SUB 202
52 #define D2BOP_MUL 203
53 #define D2BOP_DIV 204
54 #define D2BOP_POW 205
55 
56 /* Operator positions */
57 #define D2OP_BEFORE 1
58 #define D2OP_BETWEEN 2
59 #define D2OP_AFTER 3
60 
68 int das_op_unary(const char* sOp);
69 
77 int das_op_binary(const char* sOp);
78 
91 const char* das_op_toStr(int nOp, int* pos);
92 
94 bool das_op_isBinary(int nOp);
95 
97 bool das_op_isUnary(int nOp);
98 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* _das_operator_h_ */
107 
int das_op_unary(const char *sOp)
Convert a string into a unary operator token.
int das_op_binary(const char *sOp)
Convert a string into a binary operator token.
bool das_op_isUnary(int nOp)
Return true if op is a unary operation, false otherwise.
const char * das_op_toStr(int nOp, int *pos)
Provide a string representation of an operator token and an indication of where the operator normally...
bool das_op_isBinary(int nOp)
Return true if this is a binary operation, false otherwise.