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

Support null values for strings, plus defaulting to null #34

Open
cmebarrow opened this issue Sep 14, 2017 · 0 comments
Open

Support null values for strings, plus defaulting to null #34

cmebarrow opened this issue Sep 14, 2017 · 0 comments

Comments

@cmebarrow
Copy link

cmebarrow commented Sep 14, 2017

PR #30 added support for default values for integer fields (uint8, int8, etc) using syntax like uint16 length = 0. But there is no support for defaulting string fields, or for representing a null value. This is needed for example in ws nukleus to set the reason in the End frame extension to indicate there is no specified reason (workaround is setting it to "", empty string, although of course that is not the same semantically).

Proposed syntax (example):

        struct myStrings
        {
            string shortString = null;
            string16 longerString = null;
        }

A null string would be represented either by setting the length byte (or short in the case of string16) to a special value (like 0xff or 0xffff) and rejecting strings of that length (i.e. effectively reducing the maximum supported string length by one), or by making it a one character string where the character is a special value which is not a valid UTF-8 character.
If no default value is supplied, behavior will remain as now: Builder's requires a value to be set.

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

2 participants