yerba 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +53 -17
- data/ext/yerba/include/yerba.h +58 -35
- data/ext/yerba/yerba.c +281 -187
- data/lib/yerba/collection.rb +4 -4
- data/lib/yerba/document.rb +134 -0
- data/lib/yerba/formatting.rb +1 -0
- data/lib/yerba/location.rb +8 -1
- data/lib/yerba/map.rb +16 -6
- data/lib/yerba/node.rb +41 -0
- data/lib/yerba/query_result.rb +33 -10
- data/lib/yerba/scalar.rb +29 -0
- data/lib/yerba/selector.rb +3 -1
- data/lib/yerba/sequence.rb +38 -33
- data/lib/yerba/version.rb +1 -1
- data/rust/Cargo.toml +1 -1
- data/rust/src/commands/get.rs +12 -12
- data/rust/src/commands/init.rs +8 -8
- data/rust/src/commands/insert.rs +4 -18
- data/rust/src/commands/location.rs +2 -0
- data/rust/src/commands/mod.rs +34 -6
- data/rust/src/commands/move_item.rs +1 -1
- data/rust/src/commands/move_key.rs +8 -8
- data/rust/src/commands/rename.rs +1 -1
- data/rust/src/commands/selectors.rs +1 -1
- data/rust/src/commands/set.rs +14 -6
- data/rust/src/commands/sort.rs +5 -1
- data/rust/src/document/condition.rs +25 -25
- data/rust/src/document/delete.rs +57 -43
- data/rust/src/document/get.rs +91 -82
- data/rust/src/document/insert.rs +77 -77
- data/rust/src/document/mod.rs +202 -76
- data/rust/src/document/nodes.rs +162 -0
- data/rust/src/document/schema.rs +8 -8
- data/rust/src/document/set.rs +49 -26
- data/rust/src/document/sort.rs +105 -60
- data/rust/src/document/style.rs +50 -49
- data/rust/src/document/unique.rs +5 -5
- data/rust/src/error.rs +8 -4
- data/rust/src/ffi.rs +234 -107
- data/rust/src/json.rs +62 -2
- data/rust/src/lib.rs +4 -2
- data/rust/src/main.rs +2 -1
- data/rust/src/selector.rs +48 -7
- data/rust/src/syntax.rs +449 -56
- data/rust/src/validation.rs +5 -3
- data/rust/src/yerbafile.rs +168 -94
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc77087eb847c22981cefa67955f831bf0764243ce53d9a81460fa94444b305d
|
|
4
|
+
data.tar.gz: 6f1cd3a0c356d1aa6bbf079a8f3e5684346865621f43adfd5126c9cf692dc8c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac53fc548c14d63e51b931f86948cf4e651b13ba25c08b931e2756709d167af7b029c996737f68068a69dfc85a2585530dc861f0ba0e20cfbdf3d5282abc11ef
|
|
7
|
+
data.tar.gz: 65195d53f93a085112077b9a2833e35b92717b4d87dc5c3369989a2b1f53b187c9cec5b59ebf34f0ce10c5011e6516456e4dd9d682313558ac4c6563c32cc847
|
data/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Use `yerba` as a library in your Rust project:
|
|
|
47
47
|
|
|
48
48
|
```toml
|
|
49
49
|
[dependencies]
|
|
50
|
-
yerba = "0.
|
|
50
|
+
yerba = "0.10"
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
```rust
|
|
@@ -93,9 +93,10 @@ Selectors let you address any node in a YAML document:
|
|
|
93
93
|
| Pattern | Meaning | Example |
|
|
94
94
|
|-------------------|---------------------|----------------------------|
|
|
95
95
|
| `key` | A single key | `"database.host"` |
|
|
96
|
-
| `key.nested` | Nested
|
|
96
|
+
| `key.nested` | Nested keys | `"database.settings.pool"` |
|
|
97
97
|
| `[]` | All items in array | `"[].title"` |
|
|
98
98
|
| `[N]` | Item at index | `"[0].title"` |
|
|
99
|
+
| `[-N]` | Item from the end | `"[-1].title"` |
|
|
99
100
|
| `*` | All values in a map | `"database.*"` |
|
|
100
101
|
| `[].key[].nested` | Nested array access | `"[].speakers[].name"` |
|
|
101
102
|
|
|
@@ -149,14 +150,14 @@ yerba get videos.yml "[]" --condition ".speakers contains Matz" --raw
|
|
|
149
150
|
|
|
150
151
|
### `set`
|
|
151
152
|
|
|
152
|
-
Update an existing value at a
|
|
153
|
+
Update an existing value at a selector. The original quote style is preserved automatically, if a value was double-quoted before, it stays double-quoted after the edit.
|
|
153
154
|
|
|
154
155
|
```bash
|
|
155
156
|
yerba set config.yml "database.host" "0.0.0.0"
|
|
156
157
|
yerba set videos.yml "[0].title" "New Title"
|
|
157
158
|
```
|
|
158
159
|
|
|
159
|
-
Use `--if-exists` to only set the value when the
|
|
160
|
+
Use `--if-exists` to only set the value when the selector already exists, or `--if-missing` to only set it when the selector does not exist:
|
|
160
161
|
|
|
161
162
|
```bash
|
|
162
163
|
yerba set config.yml "database.host" "0.0.0.0" --if-exists
|
|
@@ -189,7 +190,7 @@ Use `--all` to update all nodes matching a wildcard selector:
|
|
|
189
190
|
yerba set videos.yml "[].description" "" --all
|
|
190
191
|
```
|
|
191
192
|
|
|
192
|
-
Values are written in the quote style already at the
|
|
193
|
+
Values are written in the quote style already at the selector, which keeps string edits tidy. A value is quoted anyway when writing it plain would not read back as the string you passed, so `yes` becomes `"yes"` and `12345` becomes `"12345"` — whatever the field held before. Use `--plain` to write a YAML literal instead:
|
|
193
194
|
|
|
194
195
|
```bash
|
|
195
196
|
yerba set config.yml "database.replica" null --plain
|
|
@@ -299,6 +300,17 @@ yerba sort videos.yml --by ".date" --order desc --by ".title"
|
|
|
299
300
|
yerba sort videos.yml "[].speakers" --by ".name"
|
|
300
301
|
```
|
|
301
302
|
|
|
303
|
+
Items without a value for a sort field sort as an empty value, so they come first. Use `--missing` to decide what happens to them instead:
|
|
304
|
+
|
|
305
|
+
- `first` or `last` puts a missing value before or after the present ones, comparing one field at a time like SQL's `NULLS FIRST` and `NULLS LAST`. Sorted by `.date` and `.start_time`, a talk without a time goes first or last within its date.
|
|
306
|
+
- `keep` leaves items with a missing value where they are and sorts the other items around them.
|
|
307
|
+
- `skip` leaves the whole sequence unsorted if any item has a missing value.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
yerba sort videos.yml --by ".date" --by ".start_time" --missing keep
|
|
312
|
+
```
|
|
313
|
+
|
|
302
314
|
Use `--order` with a comma-separated list to specify an explicit custom order. All items must be listed:
|
|
303
315
|
|
|
304
316
|
```bash
|
|
@@ -469,10 +481,14 @@ Output:
|
|
|
469
481
|
"end_line": 2,
|
|
470
482
|
"end_column": 19,
|
|
471
483
|
"start_offset": 22,
|
|
472
|
-
"end_offset": 32
|
|
484
|
+
"end_offset": 32,
|
|
485
|
+
"start_character_column": 9,
|
|
486
|
+
"end_character_column": 19
|
|
473
487
|
}
|
|
474
488
|
```
|
|
475
489
|
|
|
490
|
+
Lines are 1-based and columns are 0-based, like Prism. `start_column` and `end_column` count bytes, `start_character_column` and `end_character_column` count characters, and offsets are byte offsets into the file.
|
|
491
|
+
|
|
476
492
|
### `schema`
|
|
477
493
|
|
|
478
494
|
Validate YAML files against a JSON schema:
|
|
@@ -482,7 +498,7 @@ yerba schema data/speakers.yml --schema lib/schemas/speaker_schema.json
|
|
|
482
498
|
yerba schema "data/**/videos.yml" --schema lib/schemas/video_schema.json
|
|
483
499
|
```
|
|
484
500
|
|
|
485
|
-
Use `--
|
|
501
|
+
Use `--selector` to scope validation to a specific selector (e.g. validate each item in an array):
|
|
486
502
|
|
|
487
503
|
```bash
|
|
488
504
|
yerba schema data/speakers.yml --schema speaker_schema.json --selector "[]"
|
|
@@ -577,13 +593,15 @@ pipeline:
|
|
|
577
593
|
|
|
578
594
|
rules:
|
|
579
595
|
- files: "data/**/videos.yml"
|
|
596
|
+
exclude:
|
|
597
|
+
- "data/archive/**/videos.yml"
|
|
580
598
|
pipeline:
|
|
581
599
|
- quote_style:
|
|
582
|
-
|
|
600
|
+
selector: "[].speakers"
|
|
583
601
|
value_style: plain
|
|
584
602
|
|
|
585
603
|
- sort_keys:
|
|
586
|
-
|
|
604
|
+
selector: "[]"
|
|
587
605
|
order:
|
|
588
606
|
- id
|
|
589
607
|
- title
|
|
@@ -592,7 +610,7 @@ rules:
|
|
|
592
610
|
- files: "data/speakers.yml"
|
|
593
611
|
pipeline:
|
|
594
612
|
- sort_keys:
|
|
595
|
-
|
|
613
|
+
selector: "[]"
|
|
596
614
|
order:
|
|
597
615
|
- name
|
|
598
616
|
- slug
|
|
@@ -602,13 +620,15 @@ rules:
|
|
|
602
620
|
by: name
|
|
603
621
|
```
|
|
604
622
|
|
|
623
|
+
Rules and steps take a `selector` to scope them. `path` is still accepted as the older name for it. A rule's `exclude` takes a glob or a list of globs for files the rule skips.
|
|
624
|
+
|
|
605
625
|
Available pipeline steps:
|
|
606
626
|
|
|
607
|
-
- `quote_style` Enforce quote style on keys and/or values, optionally scoped by
|
|
627
|
+
- `quote_style` Enforce quote style on keys and/or values, optionally scoped by selector
|
|
608
628
|
- `collection_style` Enforce flow or block style on collections
|
|
609
629
|
- `sequence_indent` Enforce compact or indented sequence style
|
|
610
630
|
- `sort_keys` Reorder keys to match a predefined list
|
|
611
|
-
- `sort` Sort sequence items by field(s)
|
|
631
|
+
- `sort` Sort sequence items by field(s), `by: ".date,.start_time"` or `by: ".date .start_time"` for tie-breakers, and `missing: first`, `last`, `keep` or `skip` for items without a value
|
|
612
632
|
- `blank_lines` Enforce blank lines between sequence entries, optionally limited to named map keys with `before` and to non-empty values with `skip_empty`
|
|
613
633
|
- `set` Set a value (supports conditions, and `plain: true` for YAML literals)
|
|
614
634
|
- `insert` Insert a new key or sequence item (`plain: true` for YAML literals and fragments)
|
|
@@ -617,8 +637,8 @@ Available pipeline steps:
|
|
|
617
637
|
- `remove` Remove an item from a sequence
|
|
618
638
|
- `directives` Add or remove the document start marker (`---`), with optional `max` validation
|
|
619
639
|
- `unique` Find or remove duplicate items in a sequence
|
|
620
|
-
- `schema` Validate against a JSON schema (with optional `
|
|
621
|
-
- `escapes` Spell escaped characters literally where the quote style can carry them (with optional `
|
|
640
|
+
- `schema` Validate against a JSON schema (with optional `selector` for scoping)
|
|
641
|
+
- `escapes` Spell escaped characters literally where the quote style can carry them (with optional `selector` for scoping)
|
|
622
642
|
- `final_newline` Enforce exact number of trailing newlines (`count: 1` by default, strips extras)
|
|
623
643
|
|
|
624
644
|
This makes it easy to enforce project-wide YAML conventions in CI:
|
|
@@ -747,7 +767,7 @@ document["database"]["host"].value # => "localhost"
|
|
|
747
767
|
document["database.host"].value # => "localhost" (same thing)
|
|
748
768
|
```
|
|
749
769
|
|
|
750
|
-
The returned object type depends on what's at the
|
|
770
|
+
The returned object type depends on what's at the selector:
|
|
751
771
|
|
|
752
772
|
```ruby
|
|
753
773
|
document["database"] # => Yerba::Map
|
|
@@ -900,9 +920,20 @@ document.sort(by: :name, order: ["Charlie", "Bob", "Alice"])
|
|
|
900
920
|
document.sort("tags")
|
|
901
921
|
document.sort("tags", order: :desc)
|
|
902
922
|
document.sort("tags", order: ["rust", "ruby", "go"])
|
|
923
|
+
document.sort("tags", order: "rust,ruby,go")
|
|
924
|
+
document.sort(by: [:date, :start_time])
|
|
925
|
+
document.sort(by: ".date .start_time")
|
|
903
926
|
```
|
|
904
927
|
|
|
905
|
-
The `by:` option accepts symbols, strings, or dot-prefixed strings (`:name`, `"name"`, `".name"`).
|
|
928
|
+
The `by:` option accepts symbols, strings, or dot-prefixed strings (`:name`, `"name"`, `".name"`). Several fields, separated by commas or spaces or given as an Array, sort by the first and break ties with the next.
|
|
929
|
+
|
|
930
|
+
The `order:` option is `:asc`, `:desc`, or an explicit order of values as an Array or comma-separated String.
|
|
931
|
+
|
|
932
|
+
The `missing:` option decides what happens to items without a value for a sort field: `:first` or `:last` put the missing value before or after the present ones for each field, `:keep` leaves those items in place and sorts the others into the remaining positions, and `:skip` leaves the sequence unsorted if any value is missing. Without it, a missing value sorts as an empty string.
|
|
933
|
+
|
|
934
|
+
```ruby
|
|
935
|
+
document.sort(by: [:date, :start_time], missing: :keep)
|
|
936
|
+
```
|
|
906
937
|
|
|
907
938
|
### Querying
|
|
908
939
|
|
|
@@ -1038,8 +1069,12 @@ loc.end_line # => 2
|
|
|
1038
1069
|
loc.end_column # => 19
|
|
1039
1070
|
loc.start_offset # => 22
|
|
1040
1071
|
loc.end_offset # => 32
|
|
1072
|
+
loc.start_character_column # => 9
|
|
1073
|
+
loc.end_character_column # => 19
|
|
1041
1074
|
```
|
|
1042
1075
|
|
|
1076
|
+
Lines are 1-based and columns are 0-based, matching `Prism::Location`. `start_column` and `end_column` count bytes, `start_character_column` and `end_character_column` count characters, so they differ on lines with non-ASCII text before the value.
|
|
1077
|
+
|
|
1043
1078
|
You can also get a location by selector string:
|
|
1044
1079
|
|
|
1045
1080
|
```ruby
|
|
@@ -1167,7 +1202,7 @@ scalars.first.document.save!
|
|
|
1167
1202
|
|
|
1168
1203
|
### Parsing Selectors
|
|
1169
1204
|
|
|
1170
|
-
`Yerba::Selector` splits a selector into its segments, using the same parser as the rest of Yerba. Keys are Strings, indexes Integers, `[]` is `:all_items` and `*` is `:all_keys`:
|
|
1205
|
+
`Yerba::Selector` splits a selector into its segments, using the same parser as the rest of Yerba. Keys are Strings, indexes Integers (negative from the end), `[]` is `:all_items` and `*` is `:all_keys`:
|
|
1171
1206
|
|
|
1172
1207
|
```ruby
|
|
1173
1208
|
selector = Yerba::Selector.parse("[3].talks[1]")
|
|
@@ -1178,6 +1213,7 @@ selector.join("speakers", 0).to_s # => "[3].talks[1].speakers[0]"
|
|
|
1178
1213
|
|
|
1179
1214
|
Yerba::Selector.parse("[].speakers[]").segments # => [:all_items, "speakers", :all_items]
|
|
1180
1215
|
Yerba::Selector.parse(".title").relative? # => true
|
|
1216
|
+
Yerba::Selector.parse("tags[-1]").segments # => ["tags", -1]
|
|
1181
1217
|
|
|
1182
1218
|
Yerba::Selector.build([3, "talks", 1]).to_s # => "[3].talks[1]"
|
|
1183
1219
|
```
|
data/ext/yerba/include/yerba.h
CHANGED
|
@@ -46,6 +46,8 @@ typedef struct YerbaLocation {
|
|
|
46
46
|
uintptr_t start_column;
|
|
47
47
|
uintptr_t end_line;
|
|
48
48
|
uintptr_t end_column;
|
|
49
|
+
uintptr_t start_character_column;
|
|
50
|
+
uintptr_t end_character_column;
|
|
49
51
|
} YerbaLocation;
|
|
50
52
|
|
|
51
53
|
typedef struct YerbaGetResult {
|
|
@@ -64,6 +66,22 @@ typedef struct YerbaResult {
|
|
|
64
66
|
char *error;
|
|
65
67
|
} YerbaResult;
|
|
66
68
|
|
|
69
|
+
typedef struct YerbaNodeRecord {
|
|
70
|
+
intptr_t parent;
|
|
71
|
+
enum NodeType node_type;
|
|
72
|
+
char *selector;
|
|
73
|
+
char *key_name;
|
|
74
|
+
struct YerbaTypedValue value;
|
|
75
|
+
bool has_value;
|
|
76
|
+
struct YerbaLocation location;
|
|
77
|
+
struct YerbaLocation key_location;
|
|
78
|
+
} YerbaNodeRecord;
|
|
79
|
+
|
|
80
|
+
typedef struct YerbaNodeList {
|
|
81
|
+
struct YerbaNodeRecord *records;
|
|
82
|
+
uintptr_t length;
|
|
83
|
+
} YerbaNodeList;
|
|
84
|
+
|
|
67
85
|
struct YerbaParseResult yerba_document_parse_file(const char *path);
|
|
68
86
|
|
|
69
87
|
struct YerbaParseResult yerba_document_parse(const char *content);
|
|
@@ -72,33 +90,33 @@ uint64_t yerba_document_generation(const struct Document *document);
|
|
|
72
90
|
|
|
73
91
|
void yerba_document_free(struct Document *document);
|
|
74
92
|
|
|
75
|
-
struct YerbaGetResult yerba_document_get(const struct Document *document, const char *
|
|
93
|
+
struct YerbaGetResult yerba_document_get(const struct Document *document, const char *selector);
|
|
76
94
|
|
|
77
95
|
/**
|
|
78
96
|
* Caller must free with yerba_string_free.
|
|
79
97
|
*/
|
|
80
|
-
char *yerba_document_source(const struct Document *document, const char *
|
|
98
|
+
char *yerba_document_source(const struct Document *document, const char *selector);
|
|
81
99
|
|
|
82
100
|
/**
|
|
83
101
|
* Caller must free with yerba_string_free.
|
|
84
102
|
*/
|
|
85
|
-
char *yerba_document_get_value(const struct Document *document, const char *
|
|
103
|
+
char *yerba_document_get_value(const struct Document *document, const char *selector);
|
|
86
104
|
|
|
87
105
|
/**
|
|
88
106
|
* Caller must free with yerba_string_free.
|
|
89
107
|
*/
|
|
90
108
|
char *yerba_document_selectors(const struct Document *document);
|
|
91
109
|
|
|
92
|
-
char *yerba_document_resolve_selectors(const struct Document *document, const char *
|
|
110
|
+
char *yerba_document_resolve_selectors(const struct Document *document, const char *selector);
|
|
93
111
|
|
|
94
|
-
bool yerba_selector_has_wildcard(const char *
|
|
112
|
+
bool yerba_selector_has_wildcard(const char *selector);
|
|
95
113
|
|
|
96
114
|
/**
|
|
97
115
|
* Parses a selector into JSON: `{"relative": bool, "segments": [...]}`.
|
|
98
116
|
*
|
|
99
|
-
* Keys are encoded as strings, indexes as integers, `[]` as `{"all": "items"}` and `*` as `{"all": "keys"}`.
|
|
117
|
+
* Keys are encoded as strings, indexes as integers (negative from the end), `[]` as `{"all": "items"}` and `*` as `{"all": "keys"}`.
|
|
100
118
|
*/
|
|
101
|
-
char *yerba_selector_parse(const char *
|
|
119
|
+
char *yerba_selector_parse(const char *selector);
|
|
102
120
|
|
|
103
121
|
/**
|
|
104
122
|
* Builds a selector string from a JSON array of segments, encoded like `yerba_selector_parse` returns them.
|
|
@@ -106,43 +124,43 @@ char *yerba_selector_parse(const char *path);
|
|
|
106
124
|
char *yerba_selector_build(const char *segments_json,
|
|
107
125
|
bool relative);
|
|
108
126
|
|
|
109
|
-
char *yerba_document_keys(const struct Document *document, const char *
|
|
127
|
+
char *yerba_document_keys(const struct Document *document, const char *selector);
|
|
110
128
|
|
|
111
|
-
char *yerba_document_get_quote_style(const struct Document *document, const char *
|
|
129
|
+
char *yerba_document_get_quote_style(const struct Document *document, const char *selector);
|
|
112
130
|
|
|
113
131
|
struct YerbaResult yerba_document_set_quote_style(struct Document *document,
|
|
114
|
-
const char *
|
|
132
|
+
const char *selector,
|
|
115
133
|
const char *style);
|
|
116
134
|
|
|
117
|
-
char *yerba_document_get_collection_style(const struct Document *document, const char *
|
|
135
|
+
char *yerba_document_get_collection_style(const struct Document *document, const char *selector);
|
|
118
136
|
|
|
119
137
|
struct YerbaResult yerba_document_set_collection_style(struct Document *document,
|
|
120
|
-
const char *
|
|
138
|
+
const char *selector,
|
|
121
139
|
const char *style);
|
|
122
140
|
|
|
123
|
-
char *yerba_document_get_sequence_indent(const struct Document *document, const char *
|
|
141
|
+
char *yerba_document_get_sequence_indent(const struct Document *document, const char *selector);
|
|
124
142
|
|
|
125
143
|
struct YerbaResult yerba_document_set_sequence_indent(struct Document *document,
|
|
126
|
-
const char *
|
|
144
|
+
const char *selector,
|
|
127
145
|
const char *style);
|
|
128
146
|
|
|
129
147
|
char *yerba_validate_condition(const char *condition, bool item_context);
|
|
130
148
|
|
|
131
149
|
bool yerba_document_evaluate_condition(const struct Document *document,
|
|
132
|
-
const char *
|
|
150
|
+
const char *parent_selector,
|
|
133
151
|
const char *condition);
|
|
134
152
|
|
|
135
|
-
bool yerba_document_exists(const struct Document *document, const char *
|
|
153
|
+
bool yerba_document_exists(const struct Document *document, const char *selector);
|
|
136
154
|
|
|
137
|
-
bool yerba_document_valid_selector(const struct Document *document, const char *
|
|
155
|
+
bool yerba_document_valid_selector(const struct Document *document, const char *selector);
|
|
138
156
|
|
|
139
157
|
char *yerba_document_find(const struct Document *document,
|
|
140
|
-
const char *
|
|
158
|
+
const char *selector,
|
|
141
159
|
const char *condition,
|
|
142
160
|
const char *select);
|
|
143
161
|
|
|
144
162
|
struct YerbaResult yerba_document_set(struct Document *document,
|
|
145
|
-
const char *
|
|
163
|
+
const char *selector,
|
|
146
164
|
const char *value,
|
|
147
165
|
uintptr_t value_length,
|
|
148
166
|
enum YerbaValueType value_type,
|
|
@@ -150,7 +168,7 @@ struct YerbaResult yerba_document_set(struct Document *document,
|
|
|
150
168
|
bool all);
|
|
151
169
|
|
|
152
170
|
struct YerbaResult yerba_document_insert(struct Document *document,
|
|
153
|
-
const char *
|
|
171
|
+
const char *selector,
|
|
154
172
|
const char *value,
|
|
155
173
|
uintptr_t value_length,
|
|
156
174
|
enum YerbaValueType value_type,
|
|
@@ -161,28 +179,28 @@ struct YerbaResult yerba_document_insert(struct Document *document,
|
|
|
161
179
|
int64_t at);
|
|
162
180
|
|
|
163
181
|
struct YerbaResult yerba_document_insert_object(struct Document *document,
|
|
164
|
-
const char *
|
|
182
|
+
const char *selector,
|
|
165
183
|
const char *json,
|
|
166
184
|
const char *before,
|
|
167
185
|
const char *after,
|
|
168
186
|
int64_t at);
|
|
169
187
|
|
|
170
|
-
struct YerbaResult yerba_document_delete(struct Document *document, const char *
|
|
188
|
+
struct YerbaResult yerba_document_delete(struct Document *document, const char *selector);
|
|
171
189
|
|
|
172
190
|
struct YerbaResult yerba_document_insert_objects(struct Document *document,
|
|
173
|
-
const char *
|
|
191
|
+
const char *selector,
|
|
174
192
|
const char *json);
|
|
175
193
|
|
|
176
194
|
struct YerbaResult yerba_document_remove(struct Document *document,
|
|
177
|
-
const char *
|
|
195
|
+
const char *selector,
|
|
178
196
|
const char *value);
|
|
179
197
|
|
|
180
198
|
struct YerbaResult yerba_document_remove_at(struct Document *document,
|
|
181
|
-
const char *
|
|
199
|
+
const char *selector,
|
|
182
200
|
uintptr_t index);
|
|
183
201
|
|
|
184
202
|
struct YerbaResult yerba_document_move_item(struct Document *document,
|
|
185
|
-
const char *
|
|
203
|
+
const char *selector,
|
|
186
204
|
uintptr_t from,
|
|
187
205
|
uintptr_t to);
|
|
188
206
|
|
|
@@ -191,26 +209,27 @@ struct YerbaResult yerba_document_rename(struct Document *document,
|
|
|
191
209
|
const char *dest);
|
|
192
210
|
|
|
193
211
|
struct YerbaResult yerba_document_sort(struct Document *document,
|
|
194
|
-
const char *
|
|
212
|
+
const char *selector,
|
|
195
213
|
const char *by,
|
|
196
|
-
bool case_sensitive
|
|
214
|
+
bool case_sensitive,
|
|
215
|
+
const char *missing);
|
|
197
216
|
|
|
198
217
|
struct YerbaResult yerba_document_reorder(struct Document *document,
|
|
199
|
-
const char *
|
|
218
|
+
const char *selector,
|
|
200
219
|
const char *by,
|
|
201
220
|
const char *order_csv);
|
|
202
221
|
|
|
203
222
|
struct YerbaResult yerba_document_sort_keys(struct Document *document,
|
|
204
|
-
const char *
|
|
223
|
+
const char *selector,
|
|
205
224
|
const char *order);
|
|
206
225
|
|
|
207
226
|
struct YerbaResult yerba_document_quote_style(struct Document *document,
|
|
208
|
-
const char *
|
|
227
|
+
const char *selector,
|
|
209
228
|
const char *key_style,
|
|
210
229
|
const char *value_style);
|
|
211
230
|
|
|
212
231
|
struct YerbaResult yerba_document_blank_lines(struct Document *document,
|
|
213
|
-
const char *
|
|
232
|
+
const char *selector,
|
|
214
233
|
uintptr_t count);
|
|
215
234
|
|
|
216
235
|
/**
|
|
@@ -237,14 +256,18 @@ void yerba_string_free(char *s);
|
|
|
237
256
|
|
|
238
257
|
void yerba_result_free(struct YerbaResult result);
|
|
239
258
|
|
|
259
|
+
struct YerbaNodeList yerba_document_nodes(const struct Document *document);
|
|
260
|
+
|
|
261
|
+
void yerba_node_list_free(struct YerbaNodeList list);
|
|
262
|
+
|
|
240
263
|
void yerba_get_result_free(struct YerbaGetResult result);
|
|
241
264
|
|
|
242
|
-
struct YerbaTypedList yerba_glob_get(const char *glob_pattern, const char *
|
|
265
|
+
struct YerbaTypedList yerba_glob_get(const char *glob_pattern, const char *selector);
|
|
243
266
|
|
|
244
|
-
struct YerbaTypedList yerba_document_get_all(const struct Document *document, const char *
|
|
267
|
+
struct YerbaTypedList yerba_document_get_all(const struct Document *document, const char *selector);
|
|
245
268
|
|
|
246
269
|
struct YerbaTypedList yerba_glob_find(const char *glob_pattern,
|
|
247
|
-
const char *
|
|
270
|
+
const char *selector,
|
|
248
271
|
const char *condition,
|
|
249
272
|
const char *select);
|
|
250
273
|
|