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

enhancement(vrl): Add format_int and parse_int functions #8078

Merged
merged 4 commits into from Jun 30, 2021

Conversation

jszwedko
Copy link
Member

For converting integers to/from strings.

We currently have to_int which is equivalent to parse_int(foo, 10),
but the added parse_int is able to:

  • Parse in a specified base
  • Determine the base of the number by looking at its prefix (e.g. 0x ->
    16)

I added an analogous format_int for going the other way.

Closes: #7228

Signed-off-by: Jesse Szwedko jesse@szwedko.me

For converting integers to/from strings.

We currently have `to_int` which is equivalent to `parse_int(foo, 10)`,
but the added `parse_int` is able to:

* Parse in a specified base
* Determine the base of the number by looking at its prefix (e.g. 0x ->
  16)

I added an analogous `format_int` for going the other way.

Closes: #7228

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
@jszwedko jszwedko requested review from a team, pablosichert, JeanMertz, spencergilbert and StephenWakely and removed request for a team and pablosichert June 29, 2021 21:08
@jszwedko
Copy link
Member Author

jszwedko commented Jun 29, 2021

@aphelps would you mind taking a peek and seeing if this solves your issue? Based on #7228 it seems like it should.

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
]
}

fn examples(&self) -> &'static [Example] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it legally required to always use 42 for example numbers 😛

@jszwedko jszwedko enabled auto-merge (squash) June 30, 2021 20:58
@jszwedko jszwedko merged commit a1543b3 into master Jun 30, 2021
@jszwedko jszwedko deleted the add-parse-int-format-int branch June 30, 2021 22:06
001wwang pushed a commit to 001wwang/vector that referenced this pull request Jul 7, 2021
…otdev#8078)

* enhancement(vrl): Add `format_int` and `parse_int` functions

For converting integers to/from strings.

We currently have `to_int` which is equivalent to `parse_int(foo, 10)`,
but the added `parse_int` is able to:

* Parse in a specified base
* Determine the base of the number by looking at its prefix (e.g. 0x ->
  16)

I added an analogous `format_int` for going the other way.

Closes: vectordotdev#7228

Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
@jszwedko jszwedko mentioned this pull request Jul 12, 2021
3 tasks
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.

Implement hex-to-int function within VRL
2 participants