Skip to content

Commit 94f4c69

Browse files
committed
💡 Add comments to update_flatbuffer_from_osc_message
1 parent 8609d6e commit 94f4c69

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

osc/src/osc.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ auto update_flatbuffer_from_osc_message(
6666
) == 0
6767
)
6868
{
69+
// Parse the field name from the OSC message address
6970
auto field_name = string_view(tosc_getAddress(&osc));
7071
if (not field_name.empty())
7172
{
@@ -75,20 +76,24 @@ auto update_flatbuffer_from_osc_message(
7576
tosc_getFormat(&osc)
7677
);
7778

79+
// Strip a leading / from the address
7880
if (field_name[0] == '/')
7981
{
8082
field_name = field_name.substr(1);
8183
}
8284

85+
// Search for a matching field name in the flatbuffer root table
8386
const auto* field = root_table_fields->LookupByKey(
8487
field_name.data()
8588
);
8689
if (field)
8790
{
91+
// Find the integer/float/... type of the field, set it
8892
for (auto i = 0; osc.format[i] != '\0'; ++i)
8993
{
9094
switch (osc.format[i])
9195
{
96+
// float
9297
case 'f':
9398
{
9499
flatbuffers::SetAnyFieldF(
@@ -99,6 +104,7 @@ auto update_flatbuffer_from_osc_message(
99104
did_update_flatbuffer = true;
100105
break;
101106
}
107+
// integer
102108
case 'i':
103109
{
104110
flatbuffers::SetAnyFieldI(
@@ -118,7 +124,10 @@ auto update_flatbuffer_from_osc_message(
118124

119125
if (did_update_flatbuffer)
120126
{
121-
printf("woot!\n");
127+
printf(
128+
"Updated flatbuffer field: %.*s\n",
129+
field_name.size(), field_name.data()
130+
);
122131
}
123132
}
124133
}

0 commit comments

Comments
 (0)