Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_function_xpathExpression.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_function_execute_* functions for xpathExpression
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw.h"
15 
16 
17 
18 /*
19  * Adaptive function: compile<xpathExpression>
20  *
21  * afw_function_execute_compile_xpathExpression
22  *
23  * See afw_function_bindings.h for more information.
24  *
25  * Compile xpathExpression value and return either an unevaluated adaptive
26  * value or a string containing the compiler listing.
27  *
28  * This function is pure, so it will always return the same result
29  * given exactly the same parameters and has no side effects.
30  *
31  * Declaration:
32  *
33  * ```
34  * function compile<xpathExpression>(
35  * source: xpathExpression,
36  * listing?: any
37  * ): unevaluated;
38  * ```
39  *
40  * Parameters:
41  *
42  * source - (xpathExpression) xpathExpression string to compile.
43  *
44  * listing - (optional any dataType) If specified, a compiler listing is
45  * produced instead of an unevaluated expression value.
46  *
47  * This parameter can be an integer between 0 and 10 of a string that is
48  * used for indentation. If 0 is specified, no whitespace is added to the
49  * resulting string. If 1 through 10 is specified, that number of spaces
50  * is used.
51  *
52  * Returns:
53  *
54  * (unevaluated)
55  */
56 const afw_value_t *
59 {
60  const afw_value_string_t *source;
61  const afw_value_t *result;
62  const afw_utf8_t *listing;
63 
65 
66  result = afw_compile_to_value(
67  &source->internal, AFW_FUNCTION_SOURCE_LOCATION,
68  afw_compile_type_xpathExpression,
69  NULL, NULL, x->p, x->xctx);
70 
72  listing = afw_function_evaluate_whitespace_parameter(x, 2);
73  result = afw_value_create_string(
75  x->p, x->xctx),
76  x->p, x->xctx);
77  }
78 
79  return result;
80 }
81 
82 
83 
84 /*
85  * Adaptive function: evaluate<xpathExpression>
86  *
87  * afw_function_execute_evaluate_xpathExpression
88  *
89  * See afw_function_bindings.h for more information.
90  *
91  * Compile and evaluate xpathExpression value.
92  *
93  * This function is not pure, so it may return a different result
94  * given exactly the same parameters.
95  *
96  * Declaration:
97  *
98  * ```
99  * function evaluate<xpathExpression>(
100  * source: xpathExpression,
101  * additionalUntrustedQualifiedVariables?: (object _AdaptiveHybridPropertiesObjects_)
102  * ): unevaluated;
103  * ```
104  *
105  * Parameters:
106  *
107  * source - (xpathExpression) xpathExpression string to compile and evaluate.
108  *
109  * additionalUntrustedQualifiedVariables - (optional object
110  * _AdaptiveHybridPropertiesObjects_) This parameter supplies additional
111  * qualified variables that can be accessed during evaluation. These
112  * variables will not be used by anything that needs to ensure its
113  * qualified variables must come from a trusted source, such as
114  * authorization. This parameter is intended to be used for testing only
115  * and should not be used for anything running in production.
116  *
117  * Returns:
118  *
119  * (unevaluated)
120  */
121 const afw_value_t *
124 {
126  AFW_THROW_ERROR_Z(general, "Not implemented", x->xctx);
127 }
128 
129 
130 
131 /*
132  * Adaptive function: xpath_node_count
133  *
134  * afw_function_execute_xpath_node_count
135  *
136  * See afw_function_bindings.h for more information.
137  *
138  * The number of nodes in a node-set.
139  *
140  * This function is pure, so it will always return the same result
141  * given exactly the same parameters and has no side effects.
142  *
143  * Declaration:
144  *
145  * ```
146  * function xpath_node_count(
147  * nodeset: xpathExpression
148  * ): integer;
149  * ```
150  *
151  * Parameters:
152  *
153  * nodeset - (xpathExpression)
154  *
155  * Returns:
156  *
157  * (integer)
158  */
159 const afw_value_t *
162 {
164  AFW_THROW_ERROR_Z(general, "Not implemented", x->xctx);
165 }
166 
167 
168 
169 /*
170  * Adaptive function: xpath_node_match
171  *
172  * afw_function_execute_xpath_node_match
173  *
174  * See afw_function_bindings.h for more information.
175  *
176  * Returns true if any of the nodes matched by nodeset1 are equal to any of the
177  * nodes matched by nodeset2 or their corresponding children.
178  *
179  * This function is pure, so it will always return the same result
180  * given exactly the same parameters and has no side effects.
181  *
182  * Declaration:
183  *
184  * ```
185  * function xpath_node_match(
186  * nodeset2: xpathExpression,
187  * arg2: xpathExpression
188  * ): boolean;
189  * ```
190  *
191  * Parameters:
192  *
193  * nodeset2 - (xpathExpression)
194  *
195  * arg2 - (xpathExpression)
196  *
197  * Returns:
198  *
199  * (boolean)
200  */
201 const afw_value_t *
204 {
206  AFW_THROW_ERROR_Z(general, "Not implemented", x->xctx);
207 }
208 
209 
210 
211 /*
212  * Adaptive function: xpath_node_eq
213  *
214  * afw_function_execute_xpath_node_eq
215  *
216  * See afw_function_bindings.h for more information.
217  *
218  * Checks for xpathExpression arg1 is equal to xpathExpression arg2 and return
219  * the boolean result.
220  *
221  * This function is pure, so it will always return the same result
222  * given exactly the same parameters and has no side effects.
223  *
224  * Declaration:
225  *
226  * ```
227  * function xpath_node_eq(
228  * arg1: xpathExpression,
229  * arg2: xpathExpression
230  * ): boolean;
231  * ```
232  *
233  * Parameters:
234  *
235  * arg1 - (xpathExpression)
236  *
237  * arg2 - (xpathExpression)
238  *
239  * Returns:
240  *
241  * (boolean)
242  */
243 const afw_value_t *
246 {
248  AFW_THROW_ERROR_Z(general, "Not implemented", x->xctx);
249 }
Adaptive Framework Core API.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define afw_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
Compile string to adaptive value.
Definition: afw_compile.h:189
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define AFW_FUNCTION_SOURCE_LOCATION
Source location of a value.
Definition: afw_function.h:341
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
#define AFW_FUNCTION_PARAMETER_IS_PRESENT(A_N)
Determine if a specific parameter value is present.
Definition: afw_function.h:242
const afw_value_t * afw_function_execute_evaluate_xpathExpression(afw_function_execute_t *x)
Adaptive Function evaluate<xpathExpression>
const afw_value_t * afw_function_execute_compile_xpathExpression(afw_function_execute_t *x)
Adaptive Function compile<xpathExpression>
const afw_value_t * afw_function_execute_xpath_node_eq(afw_function_execute_t *x)
Adaptive Function xpath_node_eq
const afw_value_t * afw_function_execute_xpath_node_count(afw_function_execute_t *x)
Adaptive Function xpath_node_count
const afw_value_t * afw_function_execute_xpath_node_match(afw_function_execute_t *x)
Adaptive Function xpath_node_match
afw_value_compiler_listing_to_string(const afw_value_t *value, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Decompile a value to a compiler listing string.
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
struct for data type string values.