本文整理汇总了C++中Nullable类的典型用法代码示例。如果您正苦于以下问题:C++ Nullable类的具体用法?C++ Nullable怎么用?C++ Nullable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Promise<RefreshResult> Client::Refresh (
String access_token,
String client_token,
Nullable<Profile> profile
) {
// Create JSON request
JSON::Object obj;
obj.Add(
refresh_token_key,
std::move(access_token),
refresh_client_token_key,
std::move(client_token)
);
if (!profile.IsNull()) obj.Add(
refresh_profile_key,
profile->ToJSON()
);
// Dispatch request
return dispatch<RefreshResult>(
refresh_endpoint,
std::move(obj)
);
}
示例2: mb
// https://w3c.github.io/web-animations/#set-the-animation-playback-rate
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
if (aPlaybackRate == mPlaybackRate) {
return;
}
AutoMutationBatchForAnimation mb(*this);
Nullable<TimeDuration> previousTime = GetCurrentTime();
mPlaybackRate = aPlaybackRate;
if (!previousTime.IsNull()) {
SetCurrentTime(previousTime.Value());
}
// In the case where GetCurrentTime() returns the same result before and
// after updating mPlaybackRate, SetCurrentTime will return early since,
// as far as it can tell, nothing has changed.
// As a result, we need to perform the following updates here:
// - update timing (since, if the sign of the playback rate has changed, our
// finished state may have changed),
// - dispatch a change notification for the changed playback rate, and
// - update the playback rate on animations on layers.
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
if (IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
PostUpdate();
}
示例3: WebGLExtensionID
void
WebGLContext::GetSupportedExtensions(JSContext *cx, Nullable< nsTArray<nsString> > &retval)
{
retval.SetNull();
if (IsContextLost())
return;
nsTArray<nsString>& arr = retval.SetValue();
for (size_t i = 0; i < size_t(WebGLExtensionID_max); i++)
{
WebGLExtensionID extension = WebGLExtensionID(i);
if (IsExtensionSupported(cx, extension)) {
arr.AppendElement(NS_ConvertUTF8toUTF16(GetExtensionString(extension)));
}
}
/**
* We keep backward compatibility for these deprecated vendor-prefixed
* alias. Do not add new ones anymore. Hide it behind the
* webgl.enable-draft-extensions flag instead.
*/
if (IsExtensionSupported(cx, WEBGL_lose_context))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_lose_context"));
if (IsExtensionSupported(cx, WEBGL_compressed_texture_s3tc))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_s3tc"));
if (IsExtensionSupported(cx, WEBGL_compressed_texture_atc))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_atc"));
if (IsExtensionSupported(cx, WEBGL_compressed_texture_pvrtc))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_pvrtc"));
if (IsExtensionSupported(cx, WEBGL_depth_texture))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_depth_texture"));
}
示例4: GetCurrentTime
void
AnimationPlayer::DoPlay()
{
// FIXME: When we implement finishing behavior (bug 1074630) we will
// need to pass a flag so that when we start playing due to a change in
// animation-play-state we *don't* trigger finishing behavior.
Nullable<TimeDuration> currentTime = GetCurrentTime();
if (currentTime.IsNull()) {
mHoldTime.SetValue(TimeDuration(0));
} else if (mHoldTime.IsNull()) {
// If the hold time is null, we are already playing normally
return;
}
// Clear ready promise. We'll create a new one lazily.
mReady = nullptr;
mIsPending = true;
nsIDocument* doc = GetRenderedDocument();
if (!doc) {
StartOnNextTick(Nullable<TimeDuration>());
return;
}
PendingPlayerTracker* tracker = doc->GetOrCreatePendingPlayerTracker();
tracker->AddPlayPending(*this);
// We may have updated the current time when we set the hold time above
// so notify source content.
UpdateSourceContent();
}
示例5: AdjustRowNumber
/**
* @return true, if row number was adjusted, false otherwise
*/
static bool AdjustRowNumber(Nullable<Codeword>& codeword, const Nullable<Codeword>& otherCodeword) {
if (codeword != nullptr && otherCodeword != nullptr
&& otherCodeword.value().hasValidRowNumber() && otherCodeword.value().bucket() == codeword.value().bucket()) {
codeword.value().setRowNumber(otherCodeword.value().rowNumber());
return true;
}
return false;
}
示例6: GetNullableWString
// Helper function for converting values of char * to Nullable<std::wstring>
Nullable<std::wstring> GetNullableWString(const std::string& value)
{
Nullable<std::wstring> ret;
std::wstring str = Utils::ConvertToUtf16(value);
wprintf(L"%ls\n", str.c_str());
ret.SetValue(str);
return ret;
}
示例7: evalNoWrap
bool HTMLElementImp::evalNoWrap(HTMLElementImp* element)
{
Nullable<std::u16string> value = element->getAttribute(u"nowrap");
if (value.hasValue()) {
element->getStyle().setProperty(u"white-space", u"nowrap", u"non-css");
return true;
}
return false;
}
示例8: evalValign
bool HTMLElementImp::evalValign(HTMLElementImp* element)
{
Nullable<std::u16string> value = element->getAttribute(u"valign");
if (value.hasValue()) {
element->getStyle().setProperty(u"vertical-align", value.value(), u"non-css");
return true;
}
return false;
}
示例9: if
void
MessageEvent::GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const
{
if (mWindowSource) {
aValue.SetValue().SetAsWindowProxy() = mWindowSource;
} else if (mPortSource) {
aValue.SetValue().SetAsMessagePort() = mPortSource;
}
}
示例10: tagger
tagger(CharacterVector dict, CharacterVector model, CharacterVector user,Nullable<CharacterVector> stop) :
dict_path(dict[0]), model_path(model[0]), user_path(user[0]), stopWords(unordered_set<string>()), taggerseg(dict_path, model_path, user_path)
{
if(!stop.isNull()){
CharacterVector stop_value = stop.get();
const char *const stop_path = stop_value[0];
_loadStopWordDict(stop_path,stopWords);
}
}
示例11: GetCurrentTime
void
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
{
Nullable<TimeDuration> previousTime = GetCurrentTime();
mPlaybackRate = aPlaybackRate;
if (!previousTime.IsNull()) {
SilentlySetCurrentTime(previousTime.Value());
}
}
示例12: NS_ENSURE_SUCCESS
/* static */ nsresult
IccContact::Create(mozContact& aMozContact, nsIIccContact** aIccContact)
{
*aIccContact = nullptr;
ErrorResult er;
// Id
nsAutoString id;
aMozContact.GetId(id, er);
NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
// Names
Nullable<nsTArray<nsString>> names;
aMozContact.GetName(names, er);
NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
if (names.IsNull()) {
// Set as Empty nsTarray<nsString> for IccContact constructor.
names.SetValue();
}
// Numbers
Nullable<nsTArray<ContactTelField>> nullableNumberList;
aMozContact.GetTel(nullableNumberList, er);
NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
nsTArray<nsString> numbers;
if (!nullableNumberList.IsNull()) {
const nsTArray<ContactTelField>& numberList = nullableNumberList.Value();
for (uint32_t i = 0; i < numberList.Length(); i++) {
if (numberList[i].mValue.WasPassed()) {
numbers.AppendElement(numberList[i].mValue.Value());
}
}
}
// Emails
Nullable<nsTArray<ContactField>> nullableEmailList;
aMozContact.GetEmail(nullableEmailList, er);
NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
nsTArray<nsString> emails;
if (!nullableEmailList.IsNull()) {
const nsTArray<ContactField>& emailList = nullableEmailList.Value();
for (uint32_t i = 0; i < emailList.Length(); i++) {
if (emailList[i].mValue.WasPassed()) {
emails.AppendElement(emailList[i].mValue.Value());
}
}
}
nsCOMPtr<nsIIccContact> iccContact = new IccContact(id,
names.Value(),
numbers,
emails);
iccContact.forget(aIccContact);
return NS_OK;
}
示例13: evalBackground
bool HTMLElementImp::evalBackground(HTMLElementImp* element)
{
Nullable<std::u16string> attr = element->getAttribute(u"background");
if (attr.hasValue()) {
css::CSSStyleDeclaration style = element->getStyle();
style.setProperty(u"background-image", u"url(" + attr.value() + u")", u"non-css");
return true;
}
return false;
}
示例14: InitDevice
/// <summary>
/// Initializes the device context.
/// </summary>
void BaseTelemetryContext::InitDevice()
{
Nullable<std::wstring> strOs;
strOs.SetValue(L"Windows");
device.SetOs(strOs);
Nullable<std::wstring> strType;
strType.SetValue(L"Other");
device.SetType(strType);
}
示例15: evalColor
bool HTMLElementImp::evalColor(HTMLElementImp* element, const std::u16string& attr, const std::u16string& prop)
{
Nullable<std::u16string> value = element->getAttribute(attr);
if (value.hasValue()) {
css::CSSStyleDeclaration style = element->getStyle();
style.setProperty(prop, value.value(), u"non-css");
return true;
}
return false;
}