本文整理汇总了C++中array::Ptr::ShallowClone方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::ShallowClone方法的具体用法?C++ Ptr::ShallowClone怎么用?C++ Ptr::ShallowClone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array::Ptr
的用法示例。
在下文中一共展示了Ptr::ShallowClone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvaluateApplyRule
bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
if (service)
frame.Locals->Set("service", service);
Value vinstances;
if (rule.GetFTerm()) {
try {
vinstances = rule.GetFTerm()->Evaluate(frame);
} catch (const std::exception&) {
/* Silently ignore errors here and assume there are no instances. */
return false;
}
} else {
Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
bool match = false;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
Array::Ptr arr = vinstances;
Array::Ptr arrclone = arr->ShallowClone();
ObjectLock olock(arrclone);
BOOST_FOREACH(const Value& instance, arrclone) {
String name = rule.GetName();
if (!rule.GetFKVar().IsEmpty()) {
frame.Locals->Set(rule.GetFKVar(), instance);
name += instance;
}
if (EvaluateApplyRuleInstance(checkable, name, frame, rule))
match = true;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
示例2: OnAllConfigLoaded
void User::OnAllConfigLoaded(void)
{
ObjectImpl<User>::OnAllConfigLoaded();
UserGroup::EvaluateObjectRules(this);
Array::Ptr groups = GetGroups();
if (groups) {
groups = groups->ShallowClone();
ObjectLock olock(groups);
for (const String& name : groups) {
UserGroup::Ptr ug = UserGroup::GetByName(name);
if (ug)
ug->ResolveGroupMembership(this, true);
}
}
}
示例3: olock
static Array::Ptr ArraySort(const std::vector<Value>& args)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
Array::Ptr arr = self->ShallowClone();
if (args.empty()) {
ObjectLock olock(arr);
std::sort(arr->Begin(), arr->End());
} else {
Function::Ptr function = args[0];
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Sort function must be side-effect free."));
ObjectLock olock(arr);
std::sort(arr->Begin(), arr->End(), boost::bind(ArraySortCmp, args[0], _1, _2));
}
return arr;
}
示例4: ArrayShallowClone
static Array::Ptr ArrayShallowClone(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
return self->ShallowClone();
}