本文整理汇总了C++中ErrorContext::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorContext::toString方法的具体用法?C++ ErrorContext::toString怎么用?C++ ErrorContext::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorContext
的用法示例。
在下文中一共展示了ErrorContext::toString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBigInteger
// Defined by the WebCrypto spec as:
//
// typedef Uint8Array BigInteger;
bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<Uint8Array>& array, const ErrorContext& context, String& errorDetails)
{
if (!getUint8Array(raw, propertyName, array, context, errorDetails))
return false;
if (!array->byteLength()) {
errorDetails = context.toString(propertyName, "BigInteger should not be empty");
return false;
}
if (!raw.get(propertyName, array) || !array) {
errorDetails = context.toString(propertyName, "Missing or not a Uint8Array");
return false;
}
return true;
}
示例2: getUint8Array
bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<Uint8Array>& array, const ErrorContext& context, String& errorDetails)
{
if (!raw.get(propertyName, array) || !array) {
errorDetails = context.toString(propertyName, "Missing or not a Uint8Array");
return false;
}
return true;
}
示例3: getCryptoOperationData
// Defined by the WebCrypto spec as:
//
// typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData;
//
// FIXME: Currently only supports ArrayBufferView.
bool getCryptoOperationData(const Dictionary& raw, const char* propertyName, RefPtr<ArrayBufferView>& buffer, const ErrorContext& context, String& errorDetails)
{
bool hasProperty;
bool ok = getOptionalCryptoOperationData(raw, propertyName, hasProperty, buffer, context, errorDetails);
if (!hasProperty) {
errorDetails = context.toString(propertyName, "Missing required property");
return false;
}
return ok;
}
示例4: parseHash
bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, ErrorContext context, String& errorDetails)
{
Dictionary rawHash;
if (!raw.get("hash", rawHash)) {
errorDetails = context.toString("hash", "Missing or not a dictionary");
return false;
}
context.add("hash");
return parseAlgorithm(rawHash, Digest, hash, context, errorDetails);
}
示例5: getInteger
bool getInteger(const Dictionary& raw, const char* propertyName, double& value, double minValue, double maxValue, const ErrorContext& context, String& errorDetails)
{
bool hasProperty;
if (!getOptionalInteger(raw, propertyName, hasProperty, value, minValue, maxValue, context, errorDetails))
return false;
if (!hasProperty) {
errorDetails = context.toString(propertyName, "Missing required property");
return false;
}
return true;
}
示例6: parseAesCbcParams
// Defined by the WebCrypto spec as:
//
// dictionary AesCbcParams : Algorithm {
// CryptoOperationData iv;
// };
bool parseAesCbcParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails)
{
RefPtr<ArrayBufferView> iv;
if (!getCryptoOperationData(raw, "iv", iv, context, errorDetails))
return false;
if (iv->byteLength() != 16) {
errorDetails = context.toString("iv", "Must be 16 bytes");
return false;
}
params = adoptPtr(new blink::WebCryptoAesCbcParams(static_cast<unsigned char*>(iv->baseAddress()), iv->byteLength()));
return true;
}
示例7: getOptionalInteger
// Gets an integer according to WebIDL's [EnforceRange].
bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& hasProperty, double& value, double minValue, double maxValue, const ErrorContext& context, String& errorDetails)
{
double number;
bool ok = raw.get(propertyName, number, hasProperty);
if (!hasProperty)
return true;
if (!ok || std::isnan(number)) {
errorDetails = context.toString(propertyName, "Is not a number");
return false;
}
number = trunc(number);
if (std::isinf(number) || number < minValue || number > maxValue) {
errorDetails = context.toString(propertyName, "Outside of numeric range");
return false;
}
value = number;
return true;
}
示例8: parseAlgorithm
bool parseAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::WebCryptoAlgorithm& algorithm, ErrorContext context, String& errorDetails)
{
context.add("Algorithm");
if (!raw.isObject()) {
errorDetails = context.toString("Not an object");
return false;
}
String algorithmName;
if (!raw.get("name", algorithmName)) {
errorDetails = context.toString("name", "Missing or not a string");
return false;
}
const AlgorithmInfo* info = AlgorithmRegistry::instance().lookupAlgorithmByName(algorithmName);
if (!info) {
errorDetails = context.toString("Unrecognized algorithm name");
return false;
}
context.add(info->algorithmName);
if (info->paramsForOperation[op] == UnsupportedOp) {
errorDetails = context.toString("Unsupported operation");
return false;
}
blink::WebCryptoAlgorithmParamsType paramsType = static_cast<blink::WebCryptoAlgorithmParamsType>(info->paramsForOperation[op]);
OwnPtr<blink::WebCryptoAlgorithmParams> params;
if (!parseAlgorithmParams(raw, paramsType, params, context, errorDetails))
return false;
algorithm = blink::WebCryptoAlgorithm(info->algorithmId, params.release());
return true;
}
示例9: getOptionalCryptoOperationData
// Defined by the WebCrypto spec as:
//
// typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData;
//
// FIXME: Currently only supports ArrayBufferView.
bool getOptionalCryptoOperationData(const Dictionary& raw, const char* propertyName, bool& hasProperty, RefPtr<ArrayBufferView>& buffer, const ErrorContext& context, String& errorDetails)
{
if (!raw.get(propertyName, buffer)) {
hasProperty = false;
return true;
}
hasProperty = true;
if (!buffer) {
errorDetails = context.toString(propertyName, "Not an ArrayBufferView");
return false;
}
return true;
}