Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filterx: add parse_xml() #4863

Closed
wants to merge 18 commits into from
Closed

Conversation

alltilla
Copy link
Collaborator

@alltilla alltilla commented Mar 19, 2024

Depends on #4860, #4861, #4862 and #4866

TODO: unit tests

@kira-syslogng
Copy link
Contributor

Build FAILURE

@kira-syslogng
Copy link
Contributor

Build FAILURE

@alltilla alltilla force-pushed the filterx-xml-parser branch 5 times, most recently from 05e8b46 to 66a61b3 Compare March 21, 2024 10:11
@alltilla alltilla changed the title filterx: add parse_xml() [5/5] filterx: add parse_xml() Mar 21, 2024
@alltilla alltilla force-pushed the filterx-xml-parser branch 3 times, most recently from 58674bd to 7270683 Compare March 25, 2024 08:40
@alltilla alltilla changed the title [5/5] filterx: add parse_xml() [5/6] filterx: add parse_xml() Mar 25, 2024
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
They will be useful later for the generator logic.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
We don't have generic dicts or lists in filterx. We have dict and a list
interface, which can be implemented by anyone.

Literal dicts and lists do not make sense in this case, however with
a bit of trickery we can make them "generator"s, which use the dict
and list interfaces and operate on an actual implementation.

For this we introduce the merge "<<" operator, which on the left hand
side expects an object that is a dict or list implementation, and a
"generator" on the right hand side (in the form of literal dict and
list for now, but functions will be added soon). The merge operator
passes the "fillable" to the generator, which then fills it
appropriatery.

Please note that this is a shallow merge:
  * lists are always appended
  * dict merging works like python's dict update() function

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
We should be able to create a json_array like these:

$arr = $json_array();
$arr = $json_array("[\"foo\", \"bar\"]");
$arr = $json("[\"foo\", \"bar\"]");

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
E.g.:

    $js = json_array();
    $js << [1, 2, 3];
    $otel_arr = otel_array();
    $otel_arr << [4, 5, 6];
    $js << $otel_arr;

    $js_obj = json();
    $js_obj << {"foo": 1};
    $otel_kvl = otel_kvlist();
    $otel_kvl << {"bar": 2};
    $js_obj << $otel_kvl;

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
In continuation of the previous commit, with this we can implement
generator functions, that only use the dict and list interfaces and
fill the left hand side with data.

Useful for parsers that return a dict or a list.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
@alltilla alltilla changed the title [5/6] filterx: add parse_xml() filterx: add parse_xml() Apr 4, 2024
@alltilla
Copy link
Collaborator Author

Closing as it is really far behind the current framework.

@alltilla alltilla closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants