@@ -121,7 +121,7 @@ public void generate() throws IOException
121121 referencedTypes ));
122122 out .append (generateDocumentation (BASE_INDENT , msgToken ));
123123 classBuilder .appendTo (out );
124- out .append ("} // namespace \n " );
124+ out .append (CppUtil . closingBraces ( ir . namespaces (). length ) );
125125 out .append ("#endif\n " );
126126 }
127127 }
@@ -1336,15 +1336,21 @@ private void generateArrayProperty(
13361336 {
13371337 final String fieldName = "m_" + toLowerFirstChar (propertyName );
13381338 final String formattedPropertyName = formatPropertyName (propertyName );
1339+ final String validateMethod = "validate" + toUpperFirstChar (propertyName );
13391340
13401341 if (typeToken .encoding ().primitiveType () == PrimitiveType .CHAR )
13411342 {
1343+ final CharSequence typeName = typeWithFieldOptionality (
1344+ fieldToken ,
1345+ "std::string"
1346+ );
1347+
13421348 classBuilder .appendField ()
1343- .append (indent ).append ("std::string " ).append (fieldName ).append (";\n " );
1349+ .append (indent ).append (typeName ). append ( " " ).append (fieldName ).append (";\n " );
13441350
13451351 classBuilder .appendPublic ().append ("\n " )
13461352 .append (generateDocumentation (indent , fieldToken ))
1347- .append (indent ).append ("[[nodiscard]] const std::string & " )
1353+ .append (indent ).append ("[[nodiscard]] const " ). append ( typeName ). append ( " & " )
13481354 .append (formattedPropertyName ).append ("() const\n " )
13491355 .append (indent ).append ("{\n " )
13501356 .append (indent ).append (INDENT ).append ("return " ).append (fieldName ).append (";\n " )
@@ -1353,22 +1359,31 @@ private void generateArrayProperty(
13531359 classBuilder .appendPublic ().append ("\n " )
13541360 .append (generateDocumentation (indent , fieldToken ))
13551361 .append (indent ).append ("void " ).append (formattedPropertyName )
1356- .append ("(const std::string & borrowedValue)\n " )
1362+ .append ("(const " ). append ( typeName ). append ( " & borrowedValue)\n " )
13571363 .append (indent ).append ("{\n " )
13581364 .append (indent ).append (INDENT ).append (fieldName ).append (" = borrowedValue;\n " )
13591365 .append (indent ).append ("}\n " );
13601366
13611367 classBuilder .appendPublic ().append ("\n " )
13621368 .append (generateDocumentation (indent , fieldToken ))
1363- .append (indent ).append ("void " ).append (formattedPropertyName )
1364- .append ("(std::string && ownedValue)\n " )
1369+ .append (indent ).append ("void " ).append (formattedPropertyName ). append ( "(" )
1370+ .append (typeName ). append ( " && ownedValue)\n " )
13651371 .append (indent ).append ("{\n " )
13661372 .append (indent ).append (INDENT ).append (fieldName ).append (" = std::move(ownedValue);\n " )
13671373 .append (indent ).append ("}\n " );
1374+
1375+ generateArrayValidateMethod (
1376+ classBuilder ,
1377+ codecClassName ,
1378+ fieldToken ,
1379+ indent ,
1380+ validateMethod ,
1381+ typeName ,
1382+ "std::string" ,
1383+ formattedPropertyName );
13681384 }
13691385 else
13701386 {
1371- final String validateMethod = "validate" + toUpperFirstChar (propertyName );
13721387 final String elementTypeName = cppTypeName (typeToken .encoding ().primitiveType ());
13731388 final String vectorTypeName = "std::vector<" + elementTypeName + ">" ;
13741389 final CharSequence typeName = typeWithFieldOptionality (
@@ -1688,7 +1703,7 @@ private void generateComposite(final List<Token> tokens) throws IOException
16881703 codecClassName + "::sbeSchemaVersion()" , BASE_INDENT + INDENT );
16891704
16901705 classBuilder .appendTo (out );
1691- out .append ("} // namespace \n " );
1706+ out .append (CppUtil . closingBraces ( ir . namespaces (). length ) );
16921707 out .append ("#endif\n " );
16931708 }
16941709 }
@@ -1714,7 +1729,7 @@ private void generateChoiceSet(final List<Token> tokens) throws IOException
17141729 generateChoiceSetEncodeWith (classBuilder , className , codecClassName , setTokens , BASE_INDENT + INDENT );
17151730
17161731 classBuilder .appendTo (out );
1717- out .append ("} // namespace \n " );
1732+ out .append (CppUtil . closingBraces ( ir . namespaces (). length ) );
17181733 out .append ("#endif\n " );
17191734 }
17201735 }
0 commit comments