File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change @@ -591,25 +591,15 @@ private void generateVarData(
591591 new Formatter (sb ).format ("\n " +
592592 indent + " %1$s &put%2$s(const std::string& str)\n " +
593593 indent + " {\n " +
594- indent + " if (str.length() > %6 $d)\n " +
594+ indent + " if (str.length() > %4 $d)\n " +
595595 indent + " {\n " +
596596 indent + " throw std::runtime_error(\" std::string too long for length type [E109]\" );\n " +
597597 indent + " }\n " +
598- indent + " std::uint64_t lengthOfLengthField = %3$d;\n " +
599- indent + " std::uint64_t lengthPosition = sbePosition();\n " +
600- indent + " %4$s lengthFieldValue = %5$s(static_cast<%4$s>(str.length()));\n " +
601- indent + " sbePosition(lengthPosition + lengthOfLengthField);\n " +
602- indent + " std::memcpy(m_buffer + lengthPosition, &lengthFieldValue, sizeof(%4$s));\n " +
603- indent + " std::uint64_t pos = sbePosition();\n " +
604- indent + " sbePosition(pos + str.length());\n " +
605- indent + " std::memcpy(m_buffer + pos, str.c_str(), str.length());\n " +
606- indent + " return *this;\n " +
598+ indent + " return put%2$s(str.data(), static_cast<%3$s>(str.length()));" +
607599 indent + " }\n " ,
608600 className ,
609601 propertyName ,
610- lengthOfLengthField ,
611602 lengthCppType ,
612- lengthByteOrderStr ,
613603 lengthToken .encoding ().applicableMaxValue ().longValue ());
614604
615605 i += token .componentTokenCount ();
You can’t perform that action at this time.
0 commit comments