Skip to content

Commit f2050af

Browse files
committed
[C++] Provide a fluent API for setting array values when encoding.
1 parent 24f6d6c commit f2050af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,14 +1222,16 @@ private CharSequence generateArrayProperty(
12221222
indent);
12231223

12241224
sb.append(String.format("\n" +
1225-
indent + " void %1$s(const std::uint64_t index, const %2$s value)\n" +
1225+
indent + " %1$s %2$s(const std::uint64_t index, const %3$s value)\n" +
12261226
indent + " {\n" +
1227-
indent + " if (index >= %3$d)\n" +
1227+
indent + " if (index >= %4$d)\n" +
12281228
indent + " {\n" +
1229-
indent + " throw std::runtime_error(\"index out of range for %1$s [E105]\");\n" +
1229+
indent + " throw std::runtime_error(\"index out of range for %2$s [E105]\");\n" +
12301230
indent + " }\n\n" +
1231-
"%4$s" +
1231+
"%5$s" +
1232+
indent + " return *this;\n" +
12321233
indent + " }\n",
1234+
containingClassName,
12331235
propertyName,
12341236
cppTypeName,
12351237
token.arrayLength(),

0 commit comments

Comments
 (0)