本文整理汇总了C++中Nullable::Construct方法的典型用法代码示例。如果您正苦于以下问题:C++ Nullable::Construct方法的具体用法?C++ Nullable::Construct怎么用?C++ Nullable::Construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nullable
的用法示例。
在下文中一共展示了Nullable::Construct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
static Nullable<ParseResult> parse (CommandEvent event) {
Nullable<ParseResult> retr;
ParseResult result;
result.IsBan=is_ban(event.Identifier);
// At least one argument (player's name)
// is required for both unbanning and
// banning
if (event.Arguments.Count()==0) return retr;
// The argument we're currently
// examining
Word loc=0;
// Is this quiet?
if (event.Arguments[loc]==quiet_arg) {
++loc;
result.Quiet=true;
}
// Did we run out of arguments?
if (loc==event.Arguments.Count()) return retr;
// Get player's name
result.Info.Username=std::move(event.Arguments[loc]);
++loc;
// Did we run out of arguments?
if (loc!=event.Arguments.Count()) {
// A reason can only be supplied when
// banning, not when unbanning
if (!result.IsBan) return retr;
// Remove the groups we've already
// parsed from the raw arguments
for (Word i=0;i<loc;++i) event.RawArguments=remove_group.Replace(
event.RawArguments,
String()
);
// Now what's left is the reason
result.Info.Reason.Construct(std::move(event.RawArguments));
}
// Get the name of the person
// issuing this command (if
// applicable)
if (!event.Issuer.IsNull()) result.Info.By.Construct(event.Issuer->GetUsername());
retr.Construct(std::move(result));
return retr;
}
示例2: get
static Nullable<CommandLineArgument> get (const String * & begin, const String * end) {
Nullable<CommandLineArgument> retr;
// If there's nothing left to parse,
// return nothing
if (begin==end) return retr;
retr.Construct();
// Record raw flag
retr->RawFlag=*begin;
// Try and parse flag
auto match=regex.Match(*begin);
++begin;
if (!match.Success()) return retr;
// Store parsed flag
retr->Flag.Construct(match[1].Value());
// Get all arguments which follow
for (
;
(begin!=end) &&
!regex.IsMatch(*begin);
++begin
) retr->Arguments.Add(*begin);
return retr;
}
示例3:
Nullable<Promise<bool>> PluginMessages::Send (PluginMessage message) {
Nullable<Promise<bool>> retr;
if (message.Endpoint.IsNull()) return retr;
if (
is_builtin.IsMatch(message.Channel) ||
lock.Read([&] () mutable {
auto iter=clients.find(message.Endpoint);
return !((iter==clients.end()) || (iter->second.count(message.Channel)==0));
})
) {
outgoing packet;
packet.Channel=std::move(message.Channel);
packet.Data=std::move(message.Buffer);
retr.Construct(message.Endpoint->Send(packet));
}
return retr;
}
示例4:
Nullable<Word> get_opt_value<Word> (JSON::Object & obj, const String & key) {
auto dbl=get_opt_value<Double>(obj,key);
Nullable<Word> retr;
if (dbl.IsNull()) return retr;
auto wrd=static_cast<Word>(*dbl);
if (static_cast<Double>(wrd)!=dbl) return retr;
retr.Construct(wrd);
return retr;
}
示例5: worker_func
void Console::worker_func () noexcept {
// STDIN
HANDLE in;
// Screen buffer
Nullable<ConsoleScreenBuffer> buffer;
// Console mode when this thread
// started
DWORD mode;
try {
// Get handles
in=get_std_handle(STD_INPUT_HANDLE);
if (!(
// Attempt to cache old console
// mode so that it can be restored
// when this thread exits
GetConsoleMode(
in,
&mode
) &&
// Attempt to set new console mode,
// enabling the receipt of resize
// messages
SetConsoleMode(
in,
mode|ENABLE_WINDOW_INPUT
)
)) Raise();
// Create buffer
try {
HANDLE out=get_std_handle(STD_OUTPUT_HANDLE);
if (output_max.IsNull()) buffer.Construct(out);
else buffer.Construct(out,*output_max);
} catch (...) {
// Restore original console
// mode on failure
SetConsoleMode(
in,
mode
);
throw;
}
} catch (...) {
// Startup failed, notify
// constructor
except=std::current_exception();
barrier.Enter();
// ABORT
return;
}
// Startup success, notify
// constructor
barrier.Enter();
// Prepare handles to wait
// on
HANDLE handles []= {stop,in,queued};
try {
// Worker loop
for (;;) {
// Wait
auto result=WaitForMultipleObjects(
static_cast<DWORD>(std::extent<decltype(handles)>::value),
handles,
false,
poll_freq
);
// Did the wait fail?
if (result==WAIT_FAILED) Raise();
// Did the wait timeout?
if (result==WAIT_TIMEOUT) {
buffer->Resize();
continue;
}
//.........这里部分代码省略.........