本文整理汇总了C++中Value函数的典型用法代码示例。如果您正苦于以下问题:C++ Value函数的具体用法?C++ Value怎么用?C++ Value使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uassert
intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson(
BSONElement *pBsonElement,
const intrusive_ptr<ExpressionContext> &pExpCtx) {
uassert(15947, "a group's fields must be specified in an object",
pBsonElement->type() == Object);
intrusive_ptr<DocumentSourceGroup> pGroup(
DocumentSourceGroup::create(pExpCtx));
bool idSet = false;
BSONObj groupObj(pBsonElement->Obj());
BSONObjIterator groupIterator(groupObj);
while(groupIterator.more()) {
BSONElement groupField(groupIterator.next());
const char *pFieldName = groupField.fieldName();
if (str::equals(pFieldName, "_id")) {
uassert(15948, "a group's _id may only be specified once",
!idSet);
BSONType groupType = groupField.type();
if (groupType == Object) {
/*
Use the projection-like set of field paths to create the
group-by key.
*/
Expression::ObjectCtx oCtx(Expression::ObjectCtx::DOCUMENT_OK);
intrusive_ptr<Expression> pId(
Expression::parseObject(&groupField, &oCtx));
pGroup->setIdExpression(pId);
idSet = true;
}
else if (groupType == String) {
const string groupString = groupField.str();
if (!groupString.empty() && groupString[0] == '$') {
pGroup->setIdExpression(ExpressionFieldPath::parse(groupString));
idSet = true;
}
}
if (!idSet) {
// constant id - single group
pGroup->setIdExpression(ExpressionConstant::create(Value(groupField)));
idSet = true;
}
}
else {
/*
Treat as a projection field with the additional ability to
add aggregation operators.
*/
uassert(16414, str::stream() <<
"the group aggregate field name '" << pFieldName <<
"' cannot be used because $group's field names cannot contain '.'",
!str::contains(pFieldName, '.') );
uassert(15950, str::stream() <<
"the group aggregate field name '" <<
pFieldName << "' cannot be an operator name",
pFieldName[0] != '$');
uassert(15951, str::stream() <<
"the group aggregate field '" << pFieldName <<
"' must be defined as an expression inside an object",
groupField.type() == Object);
BSONObj subField(groupField.Obj());
BSONObjIterator subIterator(subField);
size_t subCount = 0;
for(; subIterator.more(); ++subCount) {
BSONElement subElement(subIterator.next());
/* look for the specified operator */
GroupOpDesc key;
key.name = subElement.fieldName();
const GroupOpDesc *pOp =
(const GroupOpDesc *)bsearch(
&key, GroupOpTable, NGroupOp, sizeof(GroupOpDesc),
GroupOpDescCmp);
uassert(15952, str::stream() << "unknown group operator '" << key.name << "'",
pOp);
intrusive_ptr<Expression> pGroupExpr;
BSONType elementType = subElement.type();
if (elementType == Object) {
Expression::ObjectCtx oCtx(
Expression::ObjectCtx::DOCUMENT_OK);
pGroupExpr = Expression::parseObject(
&subElement, &oCtx);
}
else if (elementType == Array) {
uasserted(15953, str::stream()
<< "aggregating group operators are unary (" << key.name << ")");
}
else { /* assume its an atomic single operand */
pGroupExpr = Expression::parseOperand(&subElement);
//.........这里部分代码省略.........
示例2: GetWorld
void AGameplayDebuggerReplicator::TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{
Super::TickActor(DeltaTime, TickType, ThisTickFunction);
#if ENABLED_GAMEPLAY_DEBUGGER
UWorld* World = GetWorld();
const ENetMode NetMode = GetNetMode();
if (!World)
{
// return without world
return;
}
UGameInstance* GameInstance = World->GetGameInstance();
if (!GameInstance || !World->IsGameWorld())
{
return;
}
if (NetMode != NM_DedicatedServer)
{
if (bActivationKeyPressed)
{
ActivationKeyTime += DeltaTime;
if (ActivationKeyTime >= GameplayDebuggerHelpers::ActivationKeyTimePch)
{
GEngine->bEnableOnScreenDebugMessages = false;
if (AHUD* const GameHUD = LocalPlayerOwner ? LocalPlayerOwner->GetHUD() : nullptr)
{
GameHUD->bShowHUD = false;
}
BindKeyboardInput(InputComponent);
ServerActivateGameplayDebugger(true);
ClientActivateGameplayDebugger(true);
bActivationKeyPressed = false;
}
}
if (bEnabledTargetSelection)
{
if (GetLocalPlayerOwner())
{
SelectTargetToDebug();
}
}
bool bMarkComponentsAsRenderStateDirty = false;
for (UGameplayDebuggerBaseObject* Obj : ReplicatedObjects)
{
if (Obj && Obj->IsRenderStateDirty())
{
if (!bMarkComponentsAsRenderStateDirty)
{
MarkComponentsRenderStateDirty();
}
bMarkComponentsAsRenderStateDirty = true;
Obj->CleanRenderStateDirtyFlag();
}
}
}
if (NetMode < NM_Client && LocalPlayerOwner)
{
TMap<FString, TArray<UGameplayDebuggerBaseObject*> > CategoryToClasses;
for (UGameplayDebuggerBaseObject* Obj : ReplicatedObjects)
{
if (Obj)
{
FString Category = Obj->GetCategoryName();
if (IsCategoryEnabled(Category))
{
CategoryToClasses.FindOrAdd(Category).Add(Obj);
}
}
}
for (auto It(CategoryToClasses.CreateIterator()); It; ++It)
{
TArray<UGameplayDebuggerBaseObject*>& CurrentObjects = It.Value();
for (UGameplayDebuggerBaseObject* Obj : CurrentObjects)
{
Obj->CollectDataToReplicateOnServer(LocalPlayerOwner, LastSelectedActorToDebug);
}
}
}
#endif
}
示例3: Delete
bool GCombo::Delete()
{
return Delete(Value());
}
示例4: interiorValue
virtual Value interiorValue() override final { return Value(); }
示例5: vanishTiles
void TableScreen::update(float dt)
{
TableLogic* gl = static_cast<TableLogic*>(GlobalVar::gameLogic);
Size s = util::graphic::getScreenSize();
// update bar
timeBar->setScaleX(gl->currTime/gl->totalTime *(s.width/timeBar->getContentSize().width));
score->setString(StringUtils::toString(gl->score));
if(gl->isShowScore) // finish category
{
util::common::stopAllSounds();
vanishTiles();
gl->isShowScore = false;
int best = ScoreDB::instance->getScoreFor(gl->cat);
int star = ScoreDB::instance->getScoreFor(STAR_KEY_FOR(gl->cat.c_str()));
int coin = ScoreDB::instance->getScoreFor(WordedApp::COIN_KEY);
Node* n = ScoreGUI::create(coin, gl->cat, gl->score, best, star, CC_CALLBACK_0(TableScreen::onBack2Cats, this), CC_CALLBACK_0(TableScreen::onRetry, this));
n->setTag(23);
getChildByTag(LABEL_LAYER)->addChild(n);
bool isSave = false;
if (gl->score > best)
{
ScoreDB::instance->setScoreFor(gl->cat, gl->score);
isSave = true;
util::platform::setScoreGC(WordedApp::getGCKey( gl->cat.c_str()), gl->score);
}
if (gl->score >= WordedApp::STAR_MIN_PT)
{
star++;
if (star <= WordedApp::STAR_MAX)
{
ScoreDB::instance->setScoreFor(STAR_KEY_FOR(gl->cat.c_str()), star);
int starTotal = ScoreDB::instance->getScoreFor(std::string(WordedApp::STARTOTAL_KEY));
starTotal++;
ScoreDB::instance->setScoreFor(std::string(WordedApp::STARTOTAL_KEY), starTotal);
isSave = true;
}
if(gl->score >=90)
{
bool checkGot90 = util::common::getValue(STAR90_KEY_FOR(gl->cat.c_str())).asBool();
if(!checkGot90)
{
int score = ScoreDB::instance->getScoreFor(WordedApp::TOTAL_90STAR);
ScoreDB::instance->setScoreFor(WordedApp::TOTAL_90STAR, score+1);
util::common::saveValue(STAR90_KEY_FOR(gl->cat.c_str()), Value(true));
isSave = true;
}
}
}
if(isSave)
ScoreDB::instance->saveDB();
currWord = "";
timeBar->setVisible(false);
score->setVisible(false);
word->setVisible(false);
// runAction(Sequence::createWithTwoActions(DelayTime::create(1.f),CallFunc::create(CC_CALLBACK_0(TableScreen::onBack2Cats,this))));
}
else if(gl->isPlaying) // game is playing
{
timeBar->setVisible(true);
score->setVisible(true);
word->setVisible(true);
std::string logicWord = gl->word;
if(currWord!=logicWord)
{
currWord = logicWord;
if (WordedApp::difficult == WordedApp::DIFFICULT_EASY)
{
Vector<FiniteTimeAction*> v;
v.pushBack(FadeOut::create(0.2f));
v.pushBack(CallFunc::create(CC_CALLBACK_0(Label::setString, word, logicWord)));
v.pushBack(FadeIn::create(0.4f));
word->runAction(Sequence::create(v));
}
WordedApp::playSound(gl->word);
makeTiles(gl->formation);
}
if(gl->currTime <= 3 && !playTimeout)
{
util::common::playSound(Constants::ASS_SND_TIMEOUT,false);
playTimeout = true;
}
else if (gl->currTime > 3)
{
playTimeout = false;
}
}
else // is Pause
{
}
}
示例6: SaveFile
bool TiXmlDocument::SaveFile() const
{
return SaveFile( Value() );
}
示例7: Value
void HostsUsingFeatures::countName(Feature feature, const String& name)
{
auto result = m_valueByName.add(name, Value());
result.storedValue->value.count(feature);
}
示例8: switch
void CProtocolDemo::GetMemoryInfo(CPointDemoBase *pPoint_)
{
CTagI *pTempTagI = pPoint_->m_pTag;
if (pTempTagI)
{
double fValue=0.0;
switch(pPoint_->m_nFunction)
{
case 20://物理内存总数
{
QString strTitle_("MemTotal");
QFile file(PROC_MEMINFO);
MEM_OCCUPY m;
if (file.open(QIODevice::ReadOnly| QIODevice::Text))
{
QTextStream in(&file);
QString data = in.readAll();
QStringList lineList = data.split('\n');
for (int i = 0; i < lineList.count(); ++i)
{
if (lineList.at(i).contains(strTitle_))
{
sscanf (lineList.at(i).toStdString().data(), "%s %lu %s", m.name, &m.total, m.name2);
fValue = m.total;
break;
}
}
file.close();
}
}
break;
case 22://物理内存空闲
{
QString strTitle_("MemFree");
QFile file(PROC_MEMINFO);
MEM_OCCUPY m;
if (file.open(QIODevice::ReadOnly| QIODevice::Text))
{
QTextStream in(&file);
QString data = in.readAll();
QStringList lineList = data.split('\n');
for (int i = 0; i < lineList.count(); ++i)
{
if (lineList.at(i).contains(strTitle_))
{
sscanf (lineList.at(i).toStdString().data(), "%s %lu %s", m.name, &m.total, m.name2);
fValue = m.total;
break;
}
}
file.close();
}
}
break;
case 24://物理内存使用
{
QString strTitle_1("MemTotal");
QString strTitle_2("MemFree");
double value1 = 0.0;
double value2 = 0.0;
QFile file(PROC_MEMINFO);
MEM_OCCUPY m;
if (file.open(QIODevice::ReadOnly| QIODevice::Text))
{
QTextStream in(&file);
QString data = in.readAll();
QStringList lineList = data.split('\n');
for (int i = 0; i < lineList.count(); ++i)
{
if (lineList.at(i).contains(strTitle_1))
{
sscanf (lineList.at(i).toStdString().data(), "%s %lu %s", m.name, &m.total, m.name2);
value1 = m.total;
break;
}else if (lineList.at(i).contains(strTitle_2))
{
sscanf (lineList.at(i).toStdString().data(), "%s %lu %s", m.name, &m.total, m.name2);
value2 = m.total;
break;
}
}
file.close();
fValue = value1 - value2;
}
}
break;
case 26://虚内存总数
{
QString strTitle_("VmallocTotal");
QFile file(PROC_MEMINFO);
MEM_OCCUPY m;
if (file.open(QIODevice::ReadOnly| QIODevice::Text))
{
QTextStream in(&file);
QString data = in.readAll();
QStringList lineList = data.split('\n');
for (int i = 0; i < lineList.count(); ++i)
{
if (lineList.at(i).contains(strTitle_))
{
//.........这里部分代码省略.........
示例9: Header
Header(const std::string &n, const std::string &v = "", const std::string &q = "")
{
setName(n);
if(!v.empty())
values.push_back(Value(v, q));
}
示例10: Value
Value DocumentSourceSkip::serialize(bool explain) const {
return Value(DOC(getSourceName() << _skip));
}
示例11: Value
void JSCWebWorker::postMessageToOwner(JSValueRef msg) {
std::string msgString = Value(context_, msg).toJSONString();
ownerMessageQueueThread_->runOnQueue([this, msgString] () {
owner_->onMessageReceived(id_, msgString);
});
}
示例12: dassert
void DocumentSourceGroup::populate() {
const size_t numAccumulators = vpAccumulatorFactory.size();
dassert(numAccumulators == vpExpression.size());
const bool mergeInputs = pExpCtx->getDoingMerge();
// pushed to on spill()
vector<shared_ptr<Sorter<Value, Value>::Iterator> > sortedFiles;
int memoryUsageBytes = 0;
// This loop consumes all input from pSource and buckets it based on pIdExpression.
for (bool hasNext = !pSource->eof(); hasNext; hasNext = pSource->advance()) {
if (memoryUsageBytes > _maxMemoryUsageBytes) {
uassert(16945, "Exceeded memory limit for $group, but didn't allow external sort",
_extSortAllowed);
sortedFiles.push_back(spill());
memoryUsageBytes = 0;
}
const Document input = pSource->getCurrent();
const Variables vars (input);
/* get the _id value */
Value id = pIdExpression->evaluate(vars);
/* treat missing values the same as NULL SERVER-4674 */
if (id.missing())
id = Value(BSONNULL);
/*
Look for the _id value in the map; if it's not there, add a
new entry with a blank accumulator.
*/
const size_t oldSize = groups.size();
vector<intrusive_ptr<Accumulator> >& group = groups[id];
const bool inserted = groups.size() != oldSize;
if (inserted) {
memoryUsageBytes += id.getApproximateSize();
// Add the accumulators
group.reserve(numAccumulators);
for (size_t i = 0; i < numAccumulators; i++) {
group.push_back(vpAccumulatorFactory[i]());
}
} else {
for (size_t i = 0; i < numAccumulators; i++) {
// subtract old mem usage. New usage added back after processing.
memoryUsageBytes -= group[i]->memUsageForSorter();
}
}
/* tickle all the accumulators for the group we found */
dassert(numAccumulators == group.size());
for (size_t i = 0; i < numAccumulators; i++) {
group[i]->process(vpExpression[i]->evaluate(vars), mergeInputs);
memoryUsageBytes += group[i]->memUsageForSorter();
}
DEV {
// In debug mode, spill every time we have a duplicate id to stress merge logic.
if (!inserted // is a dup
&& !pExpCtx->getInRouter() // can't spill to disk in router
&& !_extSortAllowed // don't change behavior when testing external sort
&& sortedFiles.size() < 20 // don't open too many FDs
) {
sortedFiles.push_back(spill());
}
}
}
// These blocks do any final steps necessary to prepare to output results.
if (!sortedFiles.empty()) {
_spilled = true;
if (!groups.empty()) {
sortedFiles.push_back(spill());
}
// We won't be using groups again so free its memory.
GroupsMap().swap(groups);
_sorterIterator.reset(
Sorter<Value,Value>::Iterator::merge(
sortedFiles, SortOptions(), SorterComparator()));
// prepare current to accumulate data
_currentAccumulators.reserve(numAccumulators);
for (size_t i = 0; i < numAccumulators; i++) {
_currentAccumulators.push_back(vpAccumulatorFactory[i]());
}
// must be before call to advance so we don't recurse
populated = true;
verify(_sorterIterator->more()); // we put data in, we should get something out.
_firstPartOfNextGroup = _sorterIterator->next();
verify(advance()); // moves first result into _currentId and _currentAccumulators
} else {
// start the group iterator
groupsIterator = groups.begin();
//.........这里部分代码省略.........
示例13: MenuBuilder
TSharedRef<SWidget> FAnimTransitionNodeDetails::OnGetShareableNodesMenu(bool bShareRules)
{
FMenuBuilder MenuBuilder(true, NULL);
FText SectionText;
if (bShareRules)
{
SectionText = LOCTEXT("PickSharedAnimTransition", "Shared Transition Rules");
}
else
{
SectionText = LOCTEXT("PickSharedAnimCrossfadeSettings", "Shared Settings");
}
MenuBuilder.BeginSection("AnimTransitionSharableNodes", SectionText);
if (UAnimStateTransitionNode* TransNode = TransitionNode.Get())
{
const UEdGraph* CurrentGraph = TransNode->GetGraph();
// Loop through the graph and build a list of the unique shared transitions
TMap<FString, UAnimStateTransitionNode*> SharedTransitions;
for (int32 NodeIdx=0; NodeIdx < CurrentGraph->Nodes.Num(); NodeIdx++)
{
if (UAnimStateTransitionNode* GraphTransNode = Cast<UAnimStateTransitionNode>(CurrentGraph->Nodes[NodeIdx]))
{
if (bShareRules && !GraphTransNode->SharedRulesName.IsEmpty())
{
SharedTransitions.Add(GraphTransNode->SharedRulesName, GraphTransNode);
}
if (!bShareRules && !GraphTransNode->SharedCrossfadeName.IsEmpty())
{
SharedTransitions.Add(GraphTransNode->SharedCrossfadeName, GraphTransNode);
}
}
}
for (auto Iter = SharedTransitions.CreateIterator(); Iter; ++Iter)
{
FUIAction Action = FUIAction( FExecuteAction::CreateSP(this, &FAnimTransitionNodeDetails::BecomeSharedWith, Iter.Value(), bShareRules) );
MenuBuilder.AddMenuEntry( FText::FromString( Iter.Key() ), LOCTEXT("ShaerdTransitionToolTip", "Use this shared transition"), FSlateIcon(), Action);
}
}
MenuBuilder.EndSection();
return MenuBuilder.MakeWidget();
}
示例14: BaseHandler
FbReadHandler::BinaryHandler::BinaryHandler(FbReadHandler &owner, const QString &name, const QXmlAttributes &atts)
: BaseHandler(owner, name)
, m_file(Value(atts, "id"))
{
}
示例15: LoadFile
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
{
return LoadFile( Value(), encoding );
}