Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijay-Nirmal committed Jan 11, 2025
1 parent 641e1fe commit 898920a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions JsonCraft.JsonPath/PathFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,37 @@

namespace JsonCraft.JsonPath
{
/// <summary>
/// Represents an abstract base class for path filters used in JSON selection.
/// </summary>
public abstract class PathFilter
{
/// <summary>
/// Executes the filter on the specified JSON element.
/// </summary>
/// <param name="root">The root JSON element.</param>
/// <param name="current">The current JSON element.</param>
/// <param name="settings">The settings used for JSON selection.</param>
/// <returns>An enumerable collection of JSON elements that match the filter.</returns>
public abstract IEnumerable<JsonElement> ExecuteFilter(JsonElement root, JsonElement current, JsonSelectSettings? settings);

/// <summary>
/// Executes the filter on the specified collection of JSON elements.
/// </summary>
/// <param name="root">The root JSON element.</param>
/// <param name="current">The collection of current JSON elements.</param>
/// <param name="settings">The settings used for JSON selection.</param>
/// <returns>An enumerable collection of JSON elements that match the filter.</returns>
public abstract IEnumerable<JsonElement> ExecuteFilter(JsonElement root, IEnumerable<JsonElement> current, JsonSelectSettings? settings);

/// <summary>
/// Gets the JSON element at the specified index in an array.
/// </summary>
/// <param name="t">The JSON element.</param>
/// <param name="index">The index of the element to retrieve.</param>
/// <param name="errorWhenNoMatch">A flag indicating whether an error should be thrown if the index is out of bounds.</param>
/// <returns>The JSON element at the specified index, or null if the index is out of bounds and <paramref name="errorWhenNoMatch"/> is false.</returns>
/// <exception cref="JsonException">Thrown if the index is out of bounds and <paramref name="errorWhenNoMatch"/> is true.</exception>
protected static JsonElement? GetTokenIndex(JsonElement t, int index, bool errorWhenNoMatch = false)
{
if (t.ValueKind == JsonValueKind.Array)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)

### Duration Chart

![Duration chart of the benchmark](./Results/duration-chart.png)
![Duration chart of the benchmark](https://raw.githubusercontent.com/Vijay-Nirmal/JsonCraft/refs/heads/master/Results/duration-chart.png)

### Allocated Memory Chart

![Allocated memory chart of the benchmark](./Results/allocated-memory-chart.png)
![Allocated memory chart of the benchmark](https://raw.githubusercontent.com/Vijay-Nirmal/JsonCraft/refs/heads/master/Results/allocated-memory-chart.png)

## Supported JSONPath Syntax

Expand Down

0 comments on commit 898920a

Please sign in to comment.