Skip to content

Feature: Parse a single line #4

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

Open
fubar-coder opened this issue Dec 30, 2023 · 2 comments
Open

Feature: Parse a single line #4

fubar-coder opened this issue Dec 30, 2023 · 2 comments
Labels
enhancement New feature or request up for graps feel free to make a pull request ;)

Comments

@fubar-coder
Copy link

Description

It would be nice if I'd be able to parse a single line. The function signature might look like:

// without options
YourType ParseData(ReadOnlySpan<char> line);

// with options
YourType ParseData(ReadOnlySpan<char> line, Options<char> option);

// without options, but bytes instead of char
YourType ParseData(ReadOnlySpan<byte> line);

// with options, but bytes instead of char
YourType ParseData(ReadOnlySpan<byte> line, Options<char> option);

Reason

  • Parallelization of line parsing
  • Avoid allocation of List or similar

Other

Maybe support for lines without newline characters could be limited to single line parsing?

@LokiMidgard
Copy link
Owner

So the difference is mainly the return type I guess?
Maybe I look at this when I look at #3 (if it dose not require to much restructuring)

@LokiMidgard
Copy link
Owner

LokiMidgard commented Jan 6, 2024

While not impossible, I currently don't think I will find the time to rewrite this. But I will write down my thoughts…


  1. The return type can't be used to switch between single row and mult row (dose it implement an collection or not)
    Since a custom type could implement an Collection interface it could not distinct
  2. Using an additonal parameter in the attribute,
    This could disable the collection check, and instead of adding the value to an collection, it will simply retrun the first value. No newline handling at all is needede then…
  3. Having a special struct like ValueTuple as wrapper, probably less demanding when it comes to allocations, would be easy to implement but seems like hacked…

@LokiMidgard LokiMidgard added enhancement New feature or request up for graps feel free to make a pull request ;) labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request up for graps feel free to make a pull request ;)
Projects
None yet
Development

No branches or pull requests

2 participants