• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ValuePtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ValuePtr的典型用法代码示例。如果您正苦于以下问题:C++ ValuePtr类的具体用法?C++ ValuePtr怎么用?C++ ValuePtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ValuePtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pushScalarProperties

void ModuleMerger::pushScalarProperties(Item::PropertyMap *dst, Item *srcItem)
{
    Item *origSrcItem = srcItem;
    do {
        if (!m_seenInstancesTopDown.contains(srcItem)) {
            m_seenInstancesTopDown.insert(srcItem);
            for (auto it = srcItem->properties().constBegin();
                 it != srcItem->properties().constEnd(); ++it) {
                const ValuePtr &srcVal = it.value();
                if (srcVal->type() != Value::JSSourceValueType)
                    continue;
                const PropertyDeclaration srcDecl = srcItem->propertyDeclaration(it.key());
                if (!srcDecl.isValid() || !srcDecl.isScalar())
                    continue;
                ValuePtr &v = (*dst)[it.key()];
                if (v)
                    continue;
                ValuePtr clonedVal = srcVal->clone();
                m_decls[clonedVal] = srcDecl;
                clonedVal->setDefiningItem(origSrcItem);
                v = clonedVal;
            }
        }
        srcItem = srcItem->prototype();
    } while (srcItem && srcItem->isModuleInstance());
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:26,代码来源:modulemerger.cpp


示例2: insertProperties

void ModuleMerger::insertProperties(Item::PropertyMap *dst, Item *srcItem, PropertiesType type)
{
    QSet<const Item *> &seenInstances
            = type == ScalarProperties ? m_seenInstancesTopDown : m_seenInstancesBottomUp;
    Item *origSrcItem = srcItem;
    do {
        if (!seenInstances.contains(srcItem)) {
            seenInstances.insert(srcItem);
            for (Item::PropertyMap::const_iterator it = srcItem->properties().constBegin();
                 it != srcItem->properties().constEnd(); ++it) {
                const ValuePtr &srcVal = it.value();
                if (srcVal->type() != Value::JSSourceValueType)
                    continue;
                const PropertyDeclaration srcDecl = srcItem->propertyDeclaration(it.key());
                if (!srcDecl.isValid() || srcDecl.isScalar() != (type == ScalarProperties))
                    continue;
                ValuePtr &v = (*dst)[it.key()];
                if (v && type == ScalarProperties)
                    continue;
                ValuePtr clonedVal = srcVal->clone();
                m_decls[clonedVal] = srcDecl;
                clonedVal->setDefiningItem(origSrcItem);
                if (v) {
                    QBS_CHECK(!clonedVal->next());
                    clonedVal->setNext(v);
                }
                v = clonedVal;
            }
        }
        srcItem = srcItem->prototype();
    } while (srcItem && srcItem->type() == ItemType::ModuleInstance);
}
开发者ID:johan-boule,项目名称:qt-labs-qbs,代码行数:32,代码来源:modulemerger.cpp


示例3: sCdr

ValuePtr
sCdr(EnvPtr env, ValuePtr args)
{
  CHECK("Number of arguments", sLength(args) == 1);
  CHECK("Argument is pair", args->car()->isPair());
  return args->car()->cdr();
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:7,代码来源:Library.cpp


示例4: evalIf

ValuePtr
evalIf(EnvPtr env, ValuePtr statement)
{
  int length = sLength(statement);
  if(length == 3) {
    if(sEqP(eval(env, statement->cdr()->car()), rsFalse()) == false) {
      return eval(env, statement->cdr()->cdr()->car());
    }
    else {
      return rsUndefined();
    }    
  }
  else if(length == 4) {
    if(sEqP(eval(env, statement->cdr()->car()), rsFalse()) == false) {
      return eval(env, statement->cdr()->cdr()->car());
    }
    else {
      return eval(env, statement->cdr()->cdr()->cdr()->car());
    }    
  }
  else {
    CHECK_FAIL("Wrong number of arguments to if");
    return rsUndefined();
  }
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:25,代码来源:Eval.cpp


示例5: libraryEnvironment

void
TestEval::eval_apply()
{
  EnvPtr env = libraryEnvironment();
  ValuePtr result = eval(env, "(list? '(foo bar baz))");
  CHECK("Result is boolean", result->isBool() && result->vBool());
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:7,代码来源:Eval.cpp


示例6: print_exists

 void DisassemblerContext::print_exists(const ValuePtr<Exists>& term, bool bracket) {
   if (bracket)
     *m_output << '(';
   *m_output << "exists (";
   
   unsigned n_parameters = term->parameter_types().size();
   unsigned parameter_name_base = m_parameter_name_index;
   m_parameter_name_index += n_parameters;
   
   boost::format name_formatter("%%%s");
   
   m_parameter_names.push_back(ParameterNameList::value_type());
   ParameterNameList::value_type& name_list = m_parameter_names.back();
   for (unsigned ii = 0; ii != n_parameters; ++ii) {
     if (ii)
       *m_output << ", ";
     
     std::string name = str(name_formatter % (parameter_name_base + ii));
     *m_output << name << " : ";
     print_term(term->parameter_types()[ii], false);
     
     name_list.push_back(name);
   }
   
   *m_output << ") > ";
   
   print_term(term->result(), true);
   
   m_parameter_names.pop_back();
   m_parameter_name_index = parameter_name_base;
   
   if (bracket)
     *m_output << ')';
 }
开发者ID:FriedBreakfast,项目名称:Psi,代码行数:34,代码来源:Disassembler.cpp


示例7: lastInNextChain

ValuePtr ModuleMerger::lastInNextChain(const ValuePtr &v)
{
    ValuePtr n = v;
    while (n->next())
        n = n->next();
    return n;
}
开发者ID:johan-boule,项目名称:qt-labs-qbs,代码行数:7,代码来源:modulemerger.cpp


示例8: encodeProperties

void ObjectImpl::encodeProperties(qpid::framing::Buffer& buffer) const
{
    int propCount = objectClass->getPropertyCount();
    uint8_t bit = 0;
    uint8_t mask = 0;
    ValuePtr value;

    for (int idx = 0; idx < propCount; idx++) {
        const SchemaProperty* prop = objectClass->getProperty(idx);
        if (prop->isOptional()) {
            value = properties[prop->getName()];
            if (bit == 0)
                bit = 1;
            if (!value->isNull())
                mask |= bit;
            if (bit == 0x80) {
                buffer.putOctet(mask);
                bit = 0;
                mask = 0;
            } else
                bit = bit << 1;
        }
    }
    if (bit != 0) {
        buffer.putOctet(mask);
    }

    for (int idx = 0; idx < propCount; idx++) {
        const SchemaProperty* prop = objectClass->getProperty(idx);
        value = properties[prop->getName()];
        if (!prop->isOptional() || !value->isNull()) {
            value->impl->encode(buffer);
        }
    }
}
开发者ID:cajus,项目名称:qpid-cpp-debian,代码行数:35,代码来源:ObjectImpl.cpp


示例9: apply

ValuePtr
apply(EnvPtr env, ValuePtr procedure, ValuePtr args)
{
  if(procedure->type() == Value::NATIVE_PROCEDURE) {
    NativeProcedureValue* proc = static_cast<NativeProcedureValue*>(procedure.mValue);
    return (*proc->mProc)(env, args);
  }
  else if(procedure->type() == Value::PROCEDURE) {
    EnvPtr callEnvironment = new Environment;
    ProcedureValue* proc = static_cast<ProcedureValue*>(procedure.mValue);
    callEnvironment->parent = proc->environment;
    int iParam = 0;
    while(args->isNull() == false) {
      if(iParam == static_cast<int>(proc->paramList.size())) {
        CHECK_FAIL("Too many arguments to procedure");
      }
      callEnvironment->values[proc->paramList[iParam]] = args->car();
      iParam++;
      args = args->cdr();
    }
    if(iParam != static_cast<int>(proc->paramList.size())) {
      CHECK_FAIL("Too few arguments to procedure");
    }
    return evalSequence(callEnvironment, proc->body);
  }
  else {
    sWrite(env, new PairValue(procedure, new PairValue()));
    CHECK_FAIL("Wrong type of argument to apply: not procedure");
    return NULL;
  }  
  
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:32,代码来源:Eval.cpp


示例10: LogicError

    void PackedValue::Unpack() const
    {
        if (m_packedDataLayout && (m_packedDataLayout->GetNumTimeSteps() != 1) && (m_packedDataLayout->GetNumSequences() != 1) && Internal::IsAutomaticUnpackingOfPackedValuesDisabled())
            LogicError("PackedValue::Unpack: Automatic unpacking of PackedValue objects is disabled");

        if (m_isPacked)
        {
            ValuePtr valueObject;
            auto dataType = m_packedData->GetDataType();
            switch (dataType)
            {
            case DataType::Float:
                valueObject = CompositeFunction::GetValueObjectFromCNTKImplMatrixAndMBLayout(m_sampleShape, *(m_packedData->GetMatrix<float>()), m_packedDataLayout, m_isReadOnly);
                break;
            case DataType::Double:
                valueObject = CompositeFunction::GetValueObjectFromCNTKImplMatrixAndMBLayout(m_sampleShape, *(m_packedData->GetMatrix<double>()), m_packedDataLayout, m_isReadOnly);
                break;
            default:
                LogicError("Unsupported DataType %s", DataTypeName(dataType));
            }

            m_data = valueObject->Data();
            m_mask = valueObject->Mask();

            m_packedData = nullptr;
            m_packedDataLayout = nullptr;
            m_isPacked = false;

            if (m_unpackedShape != m_data->Shape())
                LogicError("The computed unpacked shape of the PackedValue object does not match the actual Data NDArrayView's shape after unpacking");
        }
    }
开发者ID:hahatt,项目名称:CNTK,代码行数:32,代码来源:Value.cpp


示例11: sListP

bool
sListP(ValuePtr data)
{
  while(data->isPair() && !data->isNull())
    data = data->cdr();
  return data->isNull();
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:7,代码来源:Library.cpp


示例12: RunEvaluationOneHidden

void RunEvaluationOneHidden(FunctionPtr evalFunc, const DeviceDescriptor& device)
{
    const std::wstring inputNodeName = L"features";
    const std::wstring outputNodeName = L"out.z_output";

    Variable inputVar;
    if (!GetInputVariableByName(evalFunc, inputNodeName, inputVar))
    {
        fprintf(stderr, "Input variable %S is not available.\n", inputNodeName.c_str());
        throw("Input variable not found error.");
    }

    Variable outputVar;
    if (!GetOutputVaraiableByName(evalFunc, outputNodeName, outputVar))
    {
        fprintf(stderr, "Output variable %S is not available.\n", outputNodeName.c_str());
        throw("Output variable not found error.");
    }

    // Evaluate the network in several runs 
    size_t iterationCount = 4;   
    size_t numSamples = 3;
    for (size_t t = 0; t < iterationCount; ++t)
    {
        std::vector<float> inputData(inputVar.Shape().TotalSize() * numSamples);
        for (size_t i = 0; i < inputData.size(); ++i)
        {
            inputData[i] = static_cast<float>(i % 255);
        }

        NDShape inputShape = inputVar.Shape().AppendShape({1, numSamples});
        ValuePtr inputValue = MakeSharedObject<Value>(MakeSharedObject<NDArrayView>(inputShape, inputData, true));

        ValuePtr outputValue;
        std::unordered_map<Variable, ValuePtr> outputs = {{outputVar, outputValue}};
        evalFunc->Forward({{inputVar, inputValue}}, outputs, device);

        outputValue = outputs[outputVar];        
        NDShape outputShape = outputVar.Shape().AppendShape({1, numSamples});
        std::vector<float> outputData(outputShape.TotalSize());
        NDArrayViewPtr cpuArrayOutput = MakeSharedObject<NDArrayView>(outputShape, outputData, false);
        cpuArrayOutput->CopyFrom(*outputValue->Data());

        assert(outputData.size() == outputVar.Shape()[0] * numSamples);
        fprintf(stderr, "Evaluation result:\n");
        size_t dataIndex = 0;
        auto outputDim = outputVar.Shape()[0];
        for (size_t i = 0; i < numSamples; i++)
        {
            fprintf(stderr, "Iteration:%lu, Sample %lu:\n", t, i);
            fprintf(stderr, "Ouput:");
            for (size_t j = 0; j < outputDim; j++)
            {
                fprintf(stderr, "%f ", outputData[dataIndex++]);
            }
            fprintf(stderr, "\n");
        }
    }
}
开发者ID:Soukiy,项目名称:CNTK,代码行数:59,代码来源:EvalMultithreads.cpp


示例13: CheckValue

void CheckValue(const ValuePtr testValue, const size_t dimension, const vector<vector<size_t>>& expectedData, const vector<size_t>& seqLenList, const vector<bool>& seqStartFlags = {})
{
    // Check parameters
    BOOST_TEST(expectedData.size() == seqLenList.size(), "Parameter error: the sequence number in the exepected data and sequence list does not match.");
    for (size_t i = 0; i < expectedData.size(); i++)
    {
        if (expectedData[i].size() != seqLenList[i])
        {
            ReportFailure("Parameter erroe: the number of data for sequence %" PRIu64 " in the expected data does not match. Expected: %" PRIu64 ", actual: %" PRIu64 ".",
                i, seqLenList[i], expectedData[i].size());
        }
    }

    // Check shape
    NDShape shape = testValue->Shape();
    size_t valueRank = shape.Rank();
    if (valueRank < 2 || valueRank > 3 || shape[0] != dimension)
    {
        ReportFailure("The shape of the value does not match\n");
    }
    size_t numOfSequences = valueRank == 2 ? 1 : shape[2]; 
    if (numOfSequences != expectedData.size())
    {
        ReportFailure("The sequence number in the Value does not match. Expected: %" PRIu64 ", actual: %" PRIu64 ".", expectedData.size(), numOfSequences);
    }

    CheckMask(testValue, seqLenList, seqStartFlags);

    // Get data from Value
    vector<ElementType> outputData(shape.TotalSize());
    NDArrayViewPtr arrayOutput = MakeSharedObject<NDArrayView>(shape, outputData, false);
    arrayOutput->CopyFrom(*testValue->Data());

    size_t maxSeqLen = *max_element(seqLenList.begin(), seqLenList.end());
    size_t oIndex = 0;
    for (size_t seq = 0; seq < seqLenList.size(); seq++)
    {
        size_t seqLen = seqLenList[seq];
        for (size_t sample = 0; sample < seqLen; sample++)
        {
            for (size_t c = 0; c < dimension; c++, oIndex++)
            {
                if (outputData[oIndex] != 0)
                {
                    if (outputData[oIndex] != 1)
                    {
                        ReportFailure("OneHot vector contains value other than 0 and 1 at seqNo=%" PRIu64 " sampleNo=%" PRIu64 " position=%" PRIu64 "\n", seq, sample, c);
                    }
                    if (c != expectedData[seq][sample])
                    {
                        ReportFailure("OneHot Index does match at seqNo=%" PRIu64 ", sampleNo=%" PRIu64 ", expected: %" PRIu64 ", actual: %" PRIu64 "\n", seq, sample, expectedData[seq][sample], c);
                    }
                }
            }
        }
        // Skip mask data
        oIndex += (maxSeqLen - seqLen) * dimension;
    }
}
开发者ID:BorisJineman,项目名称:CNTK,代码行数:59,代码来源:ValueTests.cpp


示例14: copy

ValuePtr Dict::copy(bool deep) const {
  ValuePtr c = new Dict;

  for (unsigned i = 0; i < size(); i++)
    c->insert(keyAt(i), deep ? get(i)->copy(true) : get(i));

  return c;
}
开发者ID:kbernhagen,项目名称:cbang,代码行数:8,代码来源:Dict.cpp


示例15: sPureInteger

bool
sPureInteger(ValuePtr args)
{
  while(args->isNull() == false) {
    if(!(args->car()->isNumber() && args->car()->isExact())) return false;
    args = args->cdr();
  }
  return true;
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:9,代码来源:Library.cpp


示例16: setup_block

    void DisassemblerContext::setup_block(const ValuePtr<Block>& block) {
      if (block->dominator())
        setup_term_name(block->dominator());
      
      for (Block::PhiList::const_iterator ii = block->phi_nodes().begin(), ie = block->phi_nodes().end(); ii != ie; ++ii)
        setup_term_definition(*ii);

      for (Block::InstructionList::const_iterator ii = block->instructions().begin(), ie = block->instructions().end(); ii != ie; ++ii)
        setup_term_definition(*ii);
    }
开发者ID:FriedBreakfast,项目名称:Psi,代码行数:10,代码来源:Disassembler.cpp


示例17: sStringAppend

ValuePtr
sStringAppend(EnvPtr env, ValuePtr args)
{
  ostringstream ossStream;
  while(args->isNull() == false) {
    if(args->car()->isString())
      ossStream << args->car()->vString();
    args = args->cdr();
  }
  return new StringValue(ossStream.str());
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:11,代码来源:Library.cpp


示例18: libraryEnvironment

void
TestLibrary::strings()
{
  EnvPtr env = libraryEnvironment();
  ValuePtr result;

  // number->string
  result = eval(env, "(string-append \"abc\" \"def\")");
  CHECK("Result is string", result->isString());
  CHECK_EQUAL("Correct value", string, "abcdef", result->vString());
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:11,代码来源:Library.cpp


示例19: sAsFloat

float
sAsFloat(ValuePtr number)
{
  CHECK("Error convering non number to float", number->isNumber());
  if(!number->isExact()) {
    return number->vFloat();
  }
  else {
    return static_cast<float>(number->vInt());
  }
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:11,代码来源:Library.cpp


示例20: main

int main(int argc, char *argv[]) {
  try {
    Reader reader(cin);
    ValuePtr data = reader.parse();
    if (!data.isNull()) cout << *data;

    return 0;

  } CBANG_CATCH_ERROR;
  return 0;
}
开发者ID:equinoxefr,项目名称:cbang,代码行数:11,代码来源:JSON.cpp



注:本文中的ValuePtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ValueRef类代码示例发布时间:2022-05-31
下一篇:
C++ ValueOperand类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap