Skip to content

Commit

Permalink
bits: Allow both | and , separatos when parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
shramov committed Dec 23, 2024
1 parent ed2effd commit b5626f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/test/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def test_enum():
('uint16', 'A', 0x3),
('int32', 'A |B', 0x3),
('int64', 'A | 0x2', 0x3),
('int32', 'A ,B', 0x3),
('int32', 'A | C , B', 0x7),
])
def test_bits(t, s, v):
scheme = f'''yamls://
Expand Down
2 changes: 1 addition & 1 deletion src/tll/conv/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct parse<T, typename std::enable_if<std::is_base_of_v<tll::util::Bits<typena
{
T t;
const auto desc = T::bits_descriptor();
for (auto v : tll::split<'|'>(s)) {
for (auto v : tll::split<'|', ','>(s)) {
v = tll::util::strip(v);
auto r = tll::conv::select(v, desc);
if (r) {
Expand Down
2 changes: 1 addition & 1 deletion src/tll/scheme/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int ConfigEncoder::_fill_numeric(T * ptr, const tll::scheme::Field * field, std:
if constexpr (!std::is_same_v<T, double>) {
if (field->sub_type == field->Bits) {
*ptr = 0;
for (auto v : tll::split<'|'>(s)) {
for (auto v : tll::split<'|', ','>(s)) {
v = tll::util::strip(v);

auto b = field->type_bits->values;
Expand Down

0 comments on commit b5626f7

Please sign in to comment.