Skip to content

Commit

Permalink
[C++]: changes to support #9 for C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd L. Montgomery committed Dec 23, 2013
1 parent 687143c commit da95145
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions main/java/uk/co/real_logic/sbe/generation/cpp98/Cpp98Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1079,29 +1079,36 @@ private CharSequence generateMessageFlyweightCode(final int blockLength,
final int schemaId,
final int version)
{
final StringBuilder sb = new StringBuilder();
final String blockLengthType = cpp98TypeName(ir.headerStructure().blockLengthType());
final String templateIdType = cpp98TypeName(ir.headerStructure().templateIdType());
final String templateVersionType = cpp98TypeName(ir.headerStructure().templateVersionType());

sb.append(String.format(
return String.format(
"private:\n" +
" char *buffer_;\n" +
" int *positionPtr_;\n" +
" int offset_;\n" +
" int position_;\n" +
" int actingBlockLength_;\n" +
" int actingVersion_;\n\n"
));

sb.append(String.format(
" int actingVersion_;\n\n" +
"public:\n\n" +
" static sbe_uint64_t blockLength(void)\n" +
" static %1$s blockLength(void)\n" +
" {\n" +
" return %1$d;\n" +
" return %2$s;\n" +
" }\n\n" +
" static %3$s templateId(void)\n" +
" {\n" +
" return %4$s;\n" +
" }\n\n" +
" static %5$s templateVersion(void)\n" +
" {\n" +
" return %6$s;\n" +
" }\n\n" +
" sbe_uint64_t offset(void) const\n" +
" {\n" +
" return offset_;\n" +
" }\n\n" +
" %2$s &wrapForEncode(char *buffer, const int offset)\n" +
" %7$s &wrapForEncode(char *buffer, const int offset)\n" +
" {\n" +
" buffer_ = buffer;\n" +
" offset_ = offset;\n" +
Expand All @@ -1111,7 +1118,7 @@ private CharSequence generateMessageFlyweightCode(final int blockLength,
" positionPtr_ = &position_;\n" +
" return *this;\n" +
" }\n\n" +
" %2$s &wrapForDecode(char *buffer, const int offset,\n" +
" %7$s &wrapForDecode(char *buffer, const int offset,\n" +
" const int actingBlockLength, const int actingVersion)\n" +
" {\n" +
" buffer_ = buffer;\n" +
Expand All @@ -1134,14 +1141,6 @@ private CharSequence generateMessageFlyweightCode(final int blockLength,
" {\n" +
" return position() - offset_;\n" +
" }\n\n" +
" static int templateId(void)\n" +
" {\n" +
" return %3$d;\n" +
" }\n\n" +
" static int templateVersion(void)\n" +
" {\n" +
" return %4$d;\n" +
" }\n\n" +
" char *buffer(void)\n" +
" {\n" +
" return buffer_;\n" +
Expand All @@ -1150,13 +1149,14 @@ private CharSequence generateMessageFlyweightCode(final int blockLength,
" {\n" +
" return actingVersion_;\n" +
" }\n",
Integer.valueOf(blockLength),
className,
Integer.valueOf(schemaId),
Long.valueOf(version)
));

return sb;
blockLengthType,
generateLiteral(ir.headerStructure().blockLengthType(), Integer.toString(blockLength)),
templateIdType,
generateLiteral(ir.headerStructure().templateIdType(), Integer.toString(schemaId)),
templateVersionType,
generateLiteral(ir.headerStructure().templateVersionType(), Integer.toString(version)),
className
);
}

private CharSequence generateFields(final String containingClassName,
Expand Down

0 comments on commit da95145

Please sign in to comment.