From 8db4cfaad8fd51af926c14c726d9683f0a056b81 Mon Sep 17 00:00:00 2001 From: Tomek Rozen Date: Wed, 25 Sep 2019 16:40:29 +0200 Subject: [PATCH] [C++] Read/write set raw value --- .../sbe/generation/cpp/CppGenerator.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java index cf4b9a146e..deac6cc5b9 100755 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java @@ -669,6 +669,24 @@ private void generateChoiceSet(final List tokens) throws IOException " }\n", cppTypeName(tokens.get(0).encoding().primitiveType()))); + out.append(String.format("\n" + + " SBE_NODISCARD %1$s rawValue() const\n" + + " {\n" + + " %1$s val;\n" + + " std::memcpy(&val, m_buffer + m_offset, sizeof(%1$s));\n" + + " return val;\n" + + " }\n", + cppTypeName(tokens.get(0).encoding().primitiveType()))); + + out.append(String.format("\n" + + " %1$s &rawValue(%2$s value)\n" + + " {\n" + + " std::memcpy(m_buffer + m_offset, &value, sizeof(%2$s));\n" + + " return *this;\n" + + " }\n", + bitSetName, + cppTypeName(tokens.get(0).encoding().primitiveType()))); + out.append(generateChoices(bitSetName, tokens.subList(1, tokens.size() - 1))); out.append(generateChoicesDisplay(bitSetName, tokens.subList(1, tokens.size() - 1))); out.append("};\n");