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

Implement validation functions #4

Open
jpetso opened this issue Jan 5, 2016 · 0 comments
Open

Implement validation functions #4

jpetso opened this issue Jan 5, 2016 · 0 comments

Comments

@jpetso
Copy link
Collaborator

jpetso commented Jan 5, 2016

Sometimes I'm not interested in actually decoding a base-N string into its binary form, I just want to know whether it's valid and then keep it as encoded string.

I was thinking that the current API makes this possible with an empty Result type that makes put() a no-op, one would merely watch for a parse_error being thrown. This could be wrapped in an API like this:

bool <codec>::valid(const T& encoded);
bool <codec>::valid(const [char|uint8_t]* encoded, size_t encoded_size);

It would also be nice if this method didn't throw internally, because that will hit gdb/lldb when listening for arbitrary throws. Given that, the decode() functions should probably expose more overloads that take a std::error_code and set that to an error, instead of throwing. This would also make it possible to use cppcodec entirely without RTTI internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant