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

How to get/set BIT_STRING_t #5

Open
Octlot opened this issue Nov 17, 2021 · 3 comments
Open

How to get/set BIT_STRING_t #5

Octlot opened this issue Nov 17, 2021 · 3 comments

Comments

@Octlot
Copy link

Octlot commented Nov 17, 2021

BIT_STRING_t define like this:
DriveBehavior ::= BIT STRING {
goStraightForward(0),
laneChangingToLeft(1),
laneChangingToRight(2)
} (SIZE(14,...))

What can I get/set bitstring by getField or setField?

@Octlot Octlot changed the title How to get or set BIT_STRING_t How to get/set BIT_STRING_t Nov 17, 2021
@Svalorzen
Copy link
Owner

Svalorzen commented Nov 17, 2021

Currently it seems like BIT_STRING_t is not implemented. We have support for OCTET_STRING_t. This is the code that enables that:

        struct Setter<OCTET_STRING_t> {
            bool operator()(OCTET_STRING_t * field, const std::string & value) {
                return OCTET_STRING_fromBuf(field, value.data(), value.size()) == 0;
            }
            bool operator()(OCTET_STRING_t * field, const char * value) {
                return operator()(field, std::string(value));
            }
            bool operator()(OCTET_STRING_t * field, const OCTET_STRING_t * value) {
                return OCTET_STRING_fromBuf(field, reinterpret_cast<const char *>(value->buf), value->size) == 0;
            }
        };

It is likely that to support a BIT_STRING_t will require code that is quite similar to this. I can try to look into that when I have some time, or feel free to do so yourself and report your findings here.

If this is the case then adding support should be fairly easy. If not, we'll have to look into it.

@Svalorzen
Copy link
Owner

I looked a bit into it, it might not be super difficult.

The main issue is what you would like to have on the C++ side. Would an std::vector<bool> work, for example?

@Svalorzen
Copy link
Owner

std::vector<bool> unfortunately won't really work as we cannot get access to its underlying storage with data(). I think it'll have to be an std::string, but then when setting you will lose the information of how many bits are supposed to be unused (the bits_unused field in BIT_STRING_t.

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

No branches or pull requests

2 participants