Source release 19.5.0
This commit is contained in:
@@ -52,6 +52,7 @@ class CborValidator {
|
||||
GetValidateMessages() const {
|
||||
return validate_messages_;
|
||||
}
|
||||
std::string PrintValidateMessage() const;
|
||||
// Prints |parse_result_| in readable format. Requires that Parse() is called
|
||||
// first and |parse_result_| contains a valid CBOR message.
|
||||
virtual std::string GetFormattedMessage() const;
|
||||
|
||||
@@ -24,16 +24,20 @@ std::string StatusToString(FieldStatus status);
|
||||
void ApplyStatus(CborMessageStatus& status, CborMessageStatus new_status);
|
||||
|
||||
// Validates that the given field name is present, and prints error messages
|
||||
// if not.
|
||||
// if not. It is acceptable that some field, although specified as required by
|
||||
// DICE specification, is not present in practice. This function will return
|
||||
// kCborValidateWarning instead of the default kCborValidateError in those
|
||||
// cases.
|
||||
template <typename T>
|
||||
CborMessageStatus ValidateRequiredField(
|
||||
const std::string& name, const std::string& component,
|
||||
const std::pair<FieldStatus, T>& p,
|
||||
std::vector<std::pair<CborMessageStatus, std::string>>& msgs) {
|
||||
std::vector<std::pair<CborMessageStatus, std::string>>& msgs,
|
||||
CborMessageStatus error = kCborValidateError) {
|
||||
if (p.first != kPresent) {
|
||||
msgs.push_back(std::make_pair(
|
||||
kCborValidateError, component + ": missing required field " + name));
|
||||
return kCborValidateError;
|
||||
msgs.push_back(
|
||||
std::make_pair(error, component + ": missing required field " + name));
|
||||
return error;
|
||||
}
|
||||
return kCborValidateOk;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user