@@ -2225,9 +2225,7 @@ private static void generateFieldMetaAttributeMethod(
22252225 }
22262226
22272227 private static CharSequence generateEnumFieldNotPresentCondition (
2228- final int sinceVersion ,
2229- final String enumName ,
2230- final String indent )
2228+ final int sinceVersion , final String enumName , final String indent )
22312229 {
22322230 if (0 == sinceVersion )
22332231 {
@@ -2248,12 +2246,13 @@ private void generateEnumProperty(
22482246 final String containingClassName ,
22492247 final Token fieldToken ,
22502248 final String propertyName ,
2251- final Token token ,
2249+ final Token encodingToken ,
22522250 final String indent )
22532251 {
2254- final String enumName = formatClassName (token .applicableTypeName ());
2255- final String typeName = cppTypeName (token .encoding ().primitiveType ());
2256- final int offset = token .offset ();
2252+ final String enumName = formatClassName (encodingToken .applicableTypeName ());
2253+ final PrimitiveType primitiveType = encodingToken .encoding ().primitiveType ();
2254+ final String typeName = cppTypeName (primitiveType );
2255+ final int offset = encodingToken .offset ();
22572256
22582257 new Formatter (sb ).format ("\n " +
22592258 indent + " SBE_NODISCARD static SBE_CONSTEXPR std::size_t %1$sEncodingLength() SBE_NOEXCEPT\n " +
@@ -2286,9 +2285,31 @@ private void generateEnumProperty(
22862285 propertyName ,
22872286 generateEnumFieldNotPresentCondition (fieldToken .version (), enumName , indent ),
22882287 constValue .substring (constValue .indexOf ("." ) + 1 ));
2288+
2289+ new Formatter (sb ).format ("\n " +
2290+ indent + " SBE_NODISCARD %1$s %2$sRaw() const\n " +
2291+ indent + " {\n " +
2292+ indent + " return static_cast<%1$s>(%3$s::Value::%4$s);\n " +
2293+ indent + " }\n " ,
2294+ typeName ,
2295+ propertyName ,
2296+ enumName ,
2297+ constValue .substring (constValue .indexOf ("." ) + 1 ));
22892298 }
22902299 else
22912300 {
2301+ final String offsetStr = Integer .toString (offset );
2302+ new Formatter (sb ).format ("\n " +
2303+ indent + " SBE_NODISCARD %1$s %2$sRaw() const SBE_NOEXCEPT\n " +
2304+ indent + " {\n " +
2305+ "%3$s" +
2306+ "%4$s" +
2307+ indent + " }\n " ,
2308+ typeName ,
2309+ propertyName ,
2310+ generateFieldNotPresentCondition (fieldToken .version (), encodingToken .encoding (), indent ),
2311+ generateLoadValue (primitiveType , offsetStr , encodingToken .encoding ().byteOrder (), indent ));
2312+
22922313 new Formatter (sb ).format ("\n " +
22932314 indent + " SBE_NODISCARD %1$s::Value %2$s() const\n " +
22942315 indent + " {\n " +
@@ -2300,7 +2321,7 @@ private void generateEnumProperty(
23002321 enumName ,
23012322 propertyName ,
23022323 generateEnumFieldNotPresentCondition (fieldToken .version (), enumName , indent ),
2303- formatByteOrderEncoding (token .encoding ().byteOrder (), token . encoding (). primitiveType () ),
2324+ formatByteOrderEncoding (encodingToken .encoding ().byteOrder (), primitiveType ),
23042325 typeName ,
23052326 offset );
23062327
@@ -2316,7 +2337,7 @@ private void generateEnumProperty(
23162337 enumName ,
23172338 typeName ,
23182339 offset ,
2319- formatByteOrderEncoding (token .encoding ().byteOrder (), token . encoding (). primitiveType () ));
2340+ formatByteOrderEncoding (encodingToken .encoding ().byteOrder (), primitiveType ));
23202341 }
23212342 }
23222343
0 commit comments