CAEN Utility  2.0.2
Utilities for CAEN projects
CAENExpressionEvaluator.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * CAEN SpA - Software Division
4 * Via Vetraia, 11 - 55049 - Viareggio ITALY
5 * +39 0594 388 398 - www.caen.it
6 *
7 *******************************************************************************
8 *
9 * Copyright (C) 2019-2022 CAEN SpA
10 *
11 * This file is part of the CAEN Utility.
12 *
13 * The CAEN Utility is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 3 of the License, or (at your option) any later version.
17 *
18 * The CAEN Utility is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with the CAEN Utility; if not, see
25 * https://www.gnu.org/licenses/.
26 *
27 * SPDX-License-Identifier: LGPL-3.0-or-later
28 *
29 ***************************************************************************/
37 #ifndef CAEN_INCLUDE_CAENEXPRESSIONEVALUATOR_H_
38 #define CAEN_INCLUDE_CAENEXPRESSIONEVALUATOR_H_
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
45 #include <CAENUtility.h>
46 #include <stdint.h>
47 #include <stddef.h>
48 
49 //Substitute the 'idx' keyword with an integer number (value) in a given expression
50 CAEN_UTILITY_DLLAPI void CAEN_UTILITY_API c_ee_substituteIdxExpression(const char *expression, int32_t value, char *dest, size_t maxsize);
51 
52 // Evaluates the expression given by 'expr'. Only integer expressions
53 // are supported. The integer base and formats are the ones supported
54 // by stdlib's function 'strtol(*,*,0)' (see strtol for description).
55 // Operation supported are: (+ , - , * , / , | , & , << , >>, %). Correct
56 // arithmetic order and parenthesys are supported. Return the result of
57 // expression evaluation in case of success or 0 in case of error. If the
58 // result of 'c_ee_exprEval' is 0, it is still possible that the result of the
59 // expression is 0. The user should check this with function 'c_ee_getErr()'.
60 CAEN_UTILITY_DLLAPI int64_t CAEN_UTILITY_API c_ee_exprEval(const char * expression);
61 
62 // Return the last 'c_ee_exprEval()' error code. See enum 'c_ee_err_t'.
64 
65 // Returns a pointer to the position inside 'expr' which generated the
66 // error in last 'c_ee_exprEval()' call.
68 
69 // Modifies 'expression' substituting to every entry '%i' the number 'idx' and evaluates the
70 // expression result, filling 'result' with its value.
71 // NOTE: see function 'c_ee_exprEval' in module 'CAENExpressionEvaluator.c' fo a description of
72 // supported operations and types.
73 CAEN_UTILITY_DLLAPI int32_t c_ee_modifyAndEvaluateExpression(const char *expression, int32_t idx, int64_t *result);
74 
75 #endif // CAEN_INCLUDE_CAENEXPRESSIONEVALUATOR_H_
#define CAEN_UTILITY_API
Definition: CAENUtility.h:104
Main header and generic tools.
Definitions and types for CAENExpressionEvaluator.h.
int32_t c_ee_modifyAndEvaluateExpression(const char *expression, int32_t idx, int64_t *result)
int64_t c_ee_exprEval(const char *expression)
#define CAEN_UTILITY_DLLAPI
Definition: CAENUtility.h:105
#define c_nodiscard
Definition: CAENUtility.h:245
const char * c_ee_getErrPos(void)
c_ee_err_t c_ee_getErr(void)
void c_ee_substituteIdxExpression(const char *expression, int32_t value, char *dest, size_t maxsize)