@brief Store a string in the buffer, which can contain any binary data. @param[in] str A const char pointer to the data to be stored as a string. @param[in] len The number of bytes that should be stored from `str`. @return Returns the offset in the buffer where the string starts.
| 1544 | /// @param[in] len The number of bytes that should be stored from `str`. |
| 1545 | /// @return Returns the offset in the buffer where the string starts. |
| 1546 | Offset<String> CreateString(const char *str, size_t len) { |
| 1547 | NotNested(); |
| 1548 | PreAlign<uoffset_t>(len + 1); // Always 0-terminated. |
| 1549 | buf_.fill(1); |
| 1550 | PushBytes(reinterpret_cast<const uint8_t *>(str), len); |
| 1551 | PushElement(static_cast<uoffset_t>(len)); |
| 1552 | return Offset<String>(GetSize()); |
| 1553 | } |
| 1554 | |
| 1555 | /// @brief Store a string in the buffer, which is null-terminated. |
| 1556 | /// @param[in] str A const char pointer to a C-string to add to the buffer. |