本文整理汇总了C++中Sequence::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::Length方法的具体用法?C++ Sequence::Length怎么用?C++ Sequence::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: actorLock
already_AddRefed<Promise>
Cache::AddAll(JSContext* aContext,
const Sequence<OwningRequestOrUSVString>& aRequestList,
CallerType aCallerType,
ErrorResult& aRv)
{
if (NS_WARN_IF(!mActor)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
CacheChild::AutoLock actorLock(mActor);
GlobalObject global(aContext, mGlobal->GetGlobalJSObject());
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
nsTArray<RefPtr<Request>> requestList(aRequestList.Length());
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
RequestOrUSVString requestOrString;
if (aRequestList[i].IsRequest()) {
requestOrString.SetAsRequest() = aRequestList[i].GetAsRequest();
if (NS_WARN_IF(!IsValidPutRequestMethod(requestOrString.GetAsRequest(),
aRv))) {
return nullptr;
}
} else {
requestOrString.SetAsUSVString().Rebind(
aRequestList[i].GetAsUSVString().Data(),
aRequestList[i].GetAsUSVString().Length());
}
RefPtr<Request> request = Request::Constructor(global, requestOrString,
RequestInit(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
nsAutoString url;
request->GetUrl(url);
if (NS_WARN_IF(!IsValidPutRequestURL(url, aRv))) {
return nullptr;
}
requestList.AppendElement(std::move(request));
}
return AddAll(global, std::move(requestList), aCallerType, aRv);
}
示例2: Send
void
MobileMessageManager::Send(const Sequence<nsString>& aNumbers,
const nsAString& aText,
const SmsSendParameters& aSendParams,
nsTArray<RefPtr<DOMRequest>>& aReturn,
ErrorResult& aRv)
{
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
if (!smsService) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
// Use the default one unless |aSendParams.serviceId| is available.
uint32_t serviceId;
if (aSendParams.mServiceId.WasPassed()) {
serviceId = aSendParams.mServiceId.Value();
} else {
nsresult rv = smsService->GetSmsDefaultServiceId(&serviceId);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
}
const uint32_t size = aNumbers.Length();
for (uint32_t i = 0; i < size; ++i) {
RefPtr<DOMRequest> request = Send(smsService, serviceId, aNumbers[i], aText, aRv);
if (aRv.Failed()) {
return;
}
aReturn.AppendElement(request);
}
}
示例3: Delete
already_AddRefed<DOMRequest>
MobileMessageManager::Delete(const Sequence<OwningLongOrSmsMessageOrMmsMessage>& aParams,
ErrorResult& aRv)
{
const uint32_t size = aParams.Length();
FallibleTArray<int32_t> idArray;
if (!idArray.SetLength(size, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
DebugOnly<nsresult> rv;
for (uint32_t i = 0; i < size; i++) {
const OwningLongOrSmsMessageOrMmsMessage& element = aParams[i];
int32_t &id = idArray[i];
if (element.IsLong()) {
id = element.GetAsLong();
} else if (element.IsMmsMessage()) {
id = element.GetAsMmsMessage()->Id();
} else /*if (element.IsSmsMessage())*/ {
id = element.GetAsSmsMessage()->Id();
}
}
return Delete(idArray.Elements(), size, aRv);
}
示例4: DOMMatrix
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNumberSequence, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
SetDataInMatrix(obj, aNumberSequence.Elements(), aNumberSequence.Length(), aRv);
return obj.forget();
}
示例5: TouchList
already_AddRefed<TouchList> TouchEvent::CopyTouches(
const Sequence<OwningNonNull<Touch>>& aTouches) {
RefPtr<TouchList> list = new TouchList(GetParentObject());
size_t len = aTouches.Length();
for (size_t i = 0; i < len; ++i) {
list->Append(aTouches[i]);
}
return list.forget();
}
示例6: requests
already_AddRefed<Promise>
Cache::AddAll(const Sequence<OwningRequestOrUSVString>& aRequests,
ErrorResult& aRv)
{
MOZ_ASSERT(mActor);
nsRefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
if (!promise) {
return nullptr;
}
// If there is no work to do, then resolve immediately
if (aRequests.IsEmpty()) {
promise->MaybeResolve(JS::UndefinedHandleValue);
return promise.forget();
}
AutoChildRequestList requests(this, aRequests.Length());
for (uint32_t i = 0; i < aRequests.Length(); ++i) {
if (!IsValidPutRequestMethod(aRequests[i], aRv)) {
return nullptr;
}
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequests[i], ReadBody,
aRv);
if (aRv.Failed()) {
return nullptr;
}
requests.Add(ir, ReadBody, ExpandReferrer, NetworkErrorOnInvalidScheme,
aRv);
if (aRv.Failed()) {
return nullptr;
}
}
RequestId requestId = AddRequestPromise(promise, aRv);
unused << mActor->SendAddAll(requestId, requests.SendAsRequestList());
return promise.forget();
}
示例7:
bool
CryptoKey::AllUsagesRecognized(const Sequence<nsString>& aUsages)
{
for (uint32_t i = 0; i < aUsages.Length(); ++i) {
if (!IsRecognizedUsage(aUsages[i])) {
return false;
}
}
return true;
}
示例8: if
void
MultipartBlobImpl::InitializeBlob(
JSContext* aCx,
const Sequence<OwningArrayBufferOrArrayBufferViewOrBlobOrString>& aData,
const nsAString& aContentType,
bool aNativeEOL,
ErrorResult& aRv)
{
mContentType = aContentType;
BlobSet blobSet;
for (uint32_t i = 0, len = aData.Length(); i < len; ++i) {
const OwningArrayBufferOrArrayBufferViewOrBlobOrString& data = aData[i];
if (data.IsBlob()) {
nsRefPtr<Blob> blob = data.GetAsBlob().get();
blobSet.AppendBlobImpl(blob->Impl());
}
else if (data.IsString()) {
aRv = blobSet.AppendString(data.GetAsString(), aNativeEOL, aCx);
if (aRv.Failed()) {
return;
}
}
else if (data.IsArrayBuffer()) {
const ArrayBuffer& buffer = data.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;
}
}
else if (data.IsArrayBufferView()) {
const ArrayBufferView& buffer = data.GetAsArrayBufferView();
buffer.ComputeLengthAndData();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;
}
}
else {
MOZ_CRASH("Impossible blob data type.");
}
}
mBlobImpls = blobSet.GetBlobImpls();
SetLengthAndModifiedDate();
}
示例9: Initialize
void
Initialize(JSContext* aCx, Console::MethodName aName,
const nsAString& aString, const Sequence<JS::Value>& aArguments)
{
mGlobal = JS::CurrentGlobalOrNull(aCx);
mMethodName = aName;
mMethodString = aString;
for (uint32_t i = 0; i < aArguments.Length(); ++i) {
mArguments.AppendElement(aArguments[i]);
}
}
示例10: Append
void
InternalHeaders::Fill(const Sequence<Sequence<nsCString>>& aInit, ErrorResult& aRv)
{
for (uint32_t i = 0; i < aInit.Length() && !aRv.Failed(); ++i) {
const Sequence<nsCString>& tuple = aInit[i];
if (tuple.Length() != 2) {
aRv.ThrowTypeError<MSG_INVALID_HEADER_SEQUENCE>();
return;
}
Append(tuple[0], tuple[1], aRv);
}
}
示例11: ToCString
static nsCString ToCString(const Sequence<Type>& aSequence) {
nsCString str;
str.AppendLiteral("[");
for (size_t i = 0; i < aSequence.Length(); i++) {
if (i != 0) {
str.AppendLiteral(",");
}
str.Append(ToCString(aSequence[i]));
}
str.AppendLiteral("]");
return str;
}
示例12: if
void
MultipartBlobImpl::InitializeBlob(const Sequence<Blob::BlobPart>& aData,
const nsAString& aContentType,
bool aNativeEOL,
ErrorResult& aRv)
{
mContentType = aContentType;
BlobSet blobSet;
for (uint32_t i = 0, len = aData.Length(); i < len; ++i) {
const Blob::BlobPart& data = aData[i];
if (data.IsBlob()) {
RefPtr<Blob> blob = data.GetAsBlob().get();
blobSet.AppendBlobImpl(blob->Impl());
}
else if (data.IsUSVString()) {
aRv = blobSet.AppendString(data.GetAsUSVString(), aNativeEOL);
if (aRv.Failed()) {
return;
}
}
else if (data.IsArrayBuffer()) {
const ArrayBuffer& buffer = data.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;
}
}
else if (data.IsArrayBufferView()) {
const ArrayBufferView& buffer = data.GetAsArrayBufferView();
buffer.ComputeLengthAndData();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;
}
}
else {
MOZ_CRASH("Impossible blob data type.");
}
}
mBlobImpls = blobSet.GetBlobImpls();
SetLengthAndModifiedDate(aRv);
NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
}
示例13: Parse
// static
nsresult KeyPath::Parse(const Sequence<nsString>& aStrings, KeyPath* aKeyPath) {
KeyPath keyPath(0);
keyPath.SetType(ARRAY);
for (uint32_t i = 0; i < aStrings.Length(); ++i) {
if (!keyPath.AppendStringWithValidation(aStrings[i])) {
return NS_ERROR_FAILURE;
}
}
*aKeyPath = keyPath;
return NS_OK;
}
示例14: DispatchTrustedEvent
void
BluetoothAdapter::DispatchAttributeEvent(const Sequence<nsString>& aTypes)
{
NS_ENSURE_TRUE_VOID(aTypes.Length());
BluetoothAttributeEventInit init;
init.mAttrs = aTypes;
nsRefPtr<BluetoothAttributeEvent> event =
BluetoothAttributeEvent::Constructor(
this, NS_LITERAL_STRING(ATTRIBUTE_CHANGED_ID), init);
DispatchTrustedEvent(event);
}
示例15: if
bool
nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
ErrorResult& aRv)
{
if (ShouldResistFingerprinting()) {
return false;
}
hal::ScreenOrientation orientation = hal::eScreenOrientation_None;
for (uint32_t i = 0; i < aOrientations.Length(); ++i) {
const nsString& item = aOrientations[i];
if (item.EqualsLiteral("portrait")) {
orientation |= hal::eScreenOrientation_PortraitPrimary |
hal::eScreenOrientation_PortraitSecondary;
} else if (item.EqualsLiteral("portrait-primary")) {
orientation |= hal::eScreenOrientation_PortraitPrimary;
} else if (item.EqualsLiteral("portrait-secondary")) {
orientation |= hal::eScreenOrientation_PortraitSecondary;
} else if (item.EqualsLiteral("landscape")) {
orientation |= hal::eScreenOrientation_LandscapePrimary |
hal::eScreenOrientation_LandscapeSecondary;
} else if (item.EqualsLiteral("landscape-primary")) {
orientation |= hal::eScreenOrientation_LandscapePrimary;
} else if (item.EqualsLiteral("landscape-secondary")) {
orientation |= hal::eScreenOrientation_LandscapeSecondary;
} else if (item.EqualsLiteral("default")) {
orientation |= hal::eScreenOrientation_Default;
} else {
// If we don't recognize the token, we should just return 'false'
// without throwing.
return false;
}
}
switch (mScreenOrientation->GetLockOrientationPermission(false)) {
case ScreenOrientation::LOCK_DENIED:
return false;
case ScreenOrientation::LOCK_ALLOWED:
UpdateDocShellOrientationLock(GetOwner(), orientation);
return mScreenOrientation->LockDeviceOrientation(orientation, false, aRv);
case ScreenOrientation::FULLSCREEN_LOCK_ALLOWED:
UpdateDocShellOrientationLock(GetOwner(), orientation);
return mScreenOrientation->LockDeviceOrientation(orientation, true, aRv);
}
// This is only for compilers that don't understand that the previous switch
// will always return.
MOZ_CRASH("unexpected lock orientation permission value");
}