Fix source lifetime and preserve input strings in response::IdType #256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #254
This includes a fix for the original
valgrind
error, and a couple of bugs around automatically convertingresponse::IdType
strings to Base64 binaries.I'm bumping the minor version because
response::IdType
in inputs/arguments is going to be a string all the time internally, and that changes which accessors you can use on field arguments. It's generally more consistent now, but if you are used to using it with Base64 encoded binaries and your code assumes that's what it contains, you may need to perform the conversion explicitly withargId.release<response::IdType::ByteData>()
rather than using theconst
ByteData
accessors. You can still useresponse::IdType::isBase64()
to tell if it's safe to release it as a binary (otherwise it will throw an exception for strings which are not valid Base64 encodings), and it's always safe to release it as a string. It's also always safe to use theconst
c_str()
OpaqueString
accessor onresponse::IdType
field arguments now because they are guaranteed to hold a string internally.The
response::IdType::ByteData
type is just an alias forstd::vector<std::uint8_t>
, which was the original type forresponse::IdType
before I addedstd::string
support, so you could also write therelease
call asargId.release<std::vector<std::uint8_t>>()
if that looks better to you. The same applies toresponse::IdType::OpaqueString
vs.std::string
.