当前位置: 首页>>代码示例>>C++>>正文


C++ ArrayData类代码示例

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


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

示例1: releaseIfCopied

ArrayData *SharedMap::lvalNew(Variant *&ret, bool copy) {
  ArrayData *escalated = SharedMap::escalate();
  return releaseIfCopied(escalated, escalated->lvalNew(ret, false));
}
开发者ID:changguanghua,项目名称:hiphop-php,代码行数:4,代码来源:shared_map.cpp

示例2: setFullPos

bool Globals::setFullPos(const FullPos &pos) {
  ArrayData *arr = Array::get();
  return arr->setFullPos(pos);
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:4,代码来源:hphp_system.cpp

示例3: Escalate

ArrayData *SharedMap::LvalStr(ArrayData* ad, StringData* k, Variant *&ret,
                              bool copy) {
  ArrayData *escalated = Escalate(ad);
  return releaseIfCopied(escalated, escalated->lval(k, ret, false));
}
开发者ID:Halfnhav,项目名称:hiphop-php,代码行数:5,代码来源:shared-map.cpp

示例4: Escalate

ArrayData*
APCLocalArray::RemoveStr(ArrayData* ad, const StringData* k, bool copy) {
  ArrayData *escalated = Escalate(ad);
  return releaseIfCopied(escalated, escalated->remove(k, false));
}
开发者ID:Bakerl,项目名称:hhvm,代码行数:5,代码来源:apc-local-array.cpp

示例5: loadElems

ArrayData *SharedMap::escalate() const {
  ArrayData *ret = loadElems();
  assert(!ret->isStatic());
  return ret;
}
开发者ID:changguanghua,项目名称:hiphop-php,代码行数:5,代码来源:shared_map.cpp

示例6: extract_impl

ALWAYS_INLINE static
int64_t extract_impl(VRefParam vref_array,
                     int extract_type /* = EXTR_OVERWRITE */,
                     const String& prefix /* = "" */) {
  auto arrByRef = false;
  auto arr_tv = vref_array.wrapped().asTypedValue();
  if (arr_tv->m_type == KindOfRef) {
    arr_tv = arr_tv->m_data.pref->tv();
    arrByRef = true;
  }
  if (!isArrayType(arr_tv->m_type)) {
    raise_warning("extract() expects parameter 1 to be array");
    return 0;
  }

  bool reference = extract_type & EXTR_REFS;
  extract_type &= ~EXTR_REFS;

  VMRegAnchor _;
  auto const varEnv = g_context->getOrCreateVarEnv();
  if (!varEnv) return 0;

  auto& carr = tvAsCVarRef(arr_tv).asCArrRef();
  if (UNLIKELY(reference)) {
    auto extr_refs = [&](Array& arr) {
      if (arr.size() > 0) {
        // force arr to escalate (if necessary) by getting an lvalue to the
        // first element.
        ArrayData* ad = arr.get();
        auto const& first_key = ad->getKey(ad->iter_begin());
        arr.lvalAt(first_key);
      }
      int count = 0;
      for (ArrayIter iter(arr); iter; ++iter) {
        auto name = iter.first().toString();
        if (!modify_extract_name(varEnv, name, extract_type, prefix)) continue;
        // The const_cast is safe because we escalated the array.  We can't use
        // arr.lvalAt(name), because arr may have been modified as a side
        // effect of an earlier iteration.
        auto& ref = const_cast<Variant&>(iter.secondRef());
        g_context->bindVar(name.get(), ref.asTypedValue());
        ++count;
      }
      return count;
    };

    if (arrByRef) {
      return extr_refs(tvAsVariant(vref_array.getRefData()->tv()).asArrRef());
    }
    Array tmp = carr;
    return extr_refs(tmp);
  }

  int count = 0;
  for (ArrayIter iter(carr); iter; ++iter) {
    auto name = iter.first().toString();
    if (!modify_extract_name(varEnv, name, extract_type, prefix)) continue;
    g_context->setVar(name.get(), iter.secondRef().asTypedValue());
    ++count;
  }
  return count;
}
开发者ID:Thomascarette,项目名称:hhvm,代码行数:62,代码来源:ext_std_variable.cpp

示例7: tvCastToArrayInPlace

void tvCastToArrayInPlace(TypedValue* tv) {
  assert(tvIsPlausible(*tv));
  tvUnboxIfNeeded(tv);
  ArrayData* a;

  do {
    switch (tv->m_type) {
      case KindOfUninit:
      case KindOfNull:
        a = ArrayData::Create();
        continue;

      case KindOfBoolean:
      case KindOfInt64:
      case KindOfDouble:
      case KindOfPersistentString:
        a = ArrayData::Create(tvAsVariant(tv));
        continue;

      case KindOfString:
        a = ArrayData::Create(tvAsVariant(tv));
        tvDecRefStr(tv);
        continue;

      case KindOfPersistentVec: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isVecArray());
        a = PackedArray::ToPHPArrayVec(adIn, true);
        assert(a != adIn);
        continue;
      }

      case KindOfVec: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isVecArray());
        a = PackedArray::ToPHPArrayVec(adIn, adIn->cowCheck());
        if (a != adIn) tvDecRefArr(tv);
        continue;
      }

      case KindOfPersistentDict: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isDict());
        a = MixedArray::ToPHPArrayDict(adIn, true);
        assert(a != adIn);
        continue;
      }

      case KindOfDict: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isDict());
        a = MixedArray::ToPHPArrayDict(adIn, adIn->cowCheck());
        if (a != adIn) tvDecRefArr(tv);
        continue;
      }

      case KindOfPersistentKeyset: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isKeyset());
        a = MixedArray::ToPHPArrayKeyset(adIn, true);
        assert(a != adIn);
        continue;
      }

      case KindOfKeyset: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isKeyset());
        a = MixedArray::ToPHPArrayKeyset(adIn, adIn->cowCheck());
        if (a != adIn) tvDecRefArr(tv);
        continue;
      }

      case KindOfPersistentArray:
      case KindOfArray:
        assert(tv->m_data.parr->isPHPArray());
        return;

      case KindOfObject:
        // For objects, we fall back on the Variant machinery
        tvAsVariant(tv) = tv->m_data.pobj->toArray();
        return;

      case KindOfResource:
        a = ArrayData::Create(tvAsVariant(tv));
        tvDecRefRes(tv);
        continue;

      case KindOfRef:
      case KindOfClass:
        break;
    }
    not_reached();
  } while (0);

  assert(!a->isRefCounted() || a->hasExactlyOneRef());

  tv->m_data.parr = a;
  tv->m_type = KindOfArray;
  assert(cellIsPlausible(*tv));
}
开发者ID:coldlamper,项目名称:hhvm,代码行数:100,代码来源:tv-helpers.cpp

示例8: ASSERT

ArrayData *SharedMap::escalate(bool mutableIteration /* = false */) const {
  ArrayData *ret = NULL;
  m_arr->loadElems(ret, *this, mutableIteration);
  ASSERT(!ret->isStatic());
  return ret;
}
开发者ID:fantisGod,项目名称:hiphop-php,代码行数:6,代码来源:shared_map.cpp

示例9: tvCastToKeysetInPlace

void tvCastToKeysetInPlace(TypedValue* tv) {
  assert(tvIsPlausible(*tv));
  tvUnboxIfNeeded(tv);
  ArrayData* a;

  do {
    switch (tv->m_type) {
      case KindOfUninit:
      case KindOfNull:
        raise_warning("Null to keyset conversion");
        a = staticEmptyKeysetArray();
        continue;

      case KindOfBoolean:
        raise_warning("Bool to keyset conversion");
        a = staticEmptyKeysetArray();
        continue;

      case KindOfInt64:
        raise_warning("Int to keyset conversion");
        a = staticEmptyKeysetArray();
        continue;

      case KindOfDouble:
        raise_warning("Double to keyset conversion");
        a = staticEmptyKeysetArray();
        continue;

      case KindOfPersistentString:
      case KindOfString:
        raise_warning("String to keyset conversion");
        a = staticEmptyKeysetArray();
        decRefStr(tv->m_data.pstr);
        continue;

      case KindOfResource:
        raise_warning("Resource to keyset conversion");
        a = staticEmptyKeysetArray();
        decRefRes(tv->m_data.pres);
        continue;

      case KindOfPersistentVec:
      case KindOfVec: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isVecArray());
        a = PackedArray::ToKeysetVec(adIn, adIn->cowCheck());
        assert(a != adIn);
        decRefArr(adIn);
        continue;
      }

      case KindOfPersistentDict:
      case KindOfDict: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isDict());
        a = MixedArray::ToKeysetDict(adIn, adIn->cowCheck());
        if (a != adIn) decRefArr(adIn);
        continue;
      }

      case KindOfPersistentArray:
      case KindOfArray: {
        auto* adIn = tv->m_data.parr;
        assert(adIn->isPHPArray());
        a = adIn->toKeyset(adIn->cowCheck());
        if (a != adIn) decRefArr(adIn);
        continue;
      }

      case KindOfPersistentKeyset:
      case KindOfKeyset:
        assert(tv->m_data.parr->isKeyset());
        return;

      case KindOfObject: {
        auto* obj = tv->m_data.pobj;
        if (!obj->isCollection()) {
          raise_warning("Non-collection object conversion to keyset");
          a = staticEmptyKeysetArray();
        } else {
          auto keyset = collections::toArray(obj).toKeyset();
          decRefObj(obj);
          a = keyset.detach();
        }
        continue;
      }

      case KindOfRef:
      case KindOfClass:
        break;
    }
    not_reached();
  } while (0);

  assert(!a->isRefCounted() || a->hasExactlyOneRef());

  tv->m_data.parr = a;
  tv->m_type = KindOfKeyset;
  assert(cellIsPlausible(*tv));
}
开发者ID:coldlamper,项目名称:hhvm,代码行数:100,代码来源:tv-helpers.cpp

示例10: testproperty_Properties

void ArrayDataTest::testproperty_Properties()
{
    string id = "file_id";
    ArrayData array;
    array.ArraySetFileIdentifier() = id;
    CPPUNIT_ASSERT(array.ArraySetFileIdentifier() == id);

    array.DataTypeIdentifier() = "affymetrix-calvin-arraysetfile";
    CPPUNIT_ASSERT(array.DataTypeIdentifier() == "affymetrix-calvin-arraysetfile");
    array.CreatedStep() = ArrayRegistrationStep;
    CPPUNIT_ASSERT(array.CreatedStep() == ArrayRegistrationStep);
    array.InitialProject() = L"none";
    CPPUNIT_ASSERT(array.InitialProject() == L"none");
    array.CreationDateTime() = L"now";
    CPPUNIT_ASSERT(array.CreationDateTime() == L"now");
    array.CreatedBy() = L"me";
    CPPUNIT_ASSERT(array.CreatedBy() == L"me");
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例11: testmethod_Clear

void ArrayDataTest::testmethod_Clear()
{
    string id = "file_id";
    ArrayData array;
    array.ArraySetFileIdentifier() = id;
    array.PhysicalArraysAttributes().resize(2);
    array.UserAttributes().resize(4);
    array.DataTypeIdentifier() = "affymetrix-calvin-arraysetfile";
    array.CreatedStep() = ArrayRegistrationStep;
    array.InitialProject() = L"none";
    array.CreationDateTime() = L"now";
    array.CreatedBy() = L"me";
    array.Clear();

    CPPUNIT_ASSERT(array.ArraySetFileIdentifier() == "");
    CPPUNIT_ASSERT(array.PhysicalArraysAttributes().size() == 0);
    CPPUNIT_ASSERT(array.UserAttributes().size() == 0);
    CPPUNIT_ASSERT(array.DataTypeIdentifier() == "");
    CPPUNIT_ASSERT(array.CreatedStep() == NoStep);
    CPPUNIT_ASSERT(array.InitialProject() == L"");
    CPPUNIT_ASSERT(array.CreationDateTime() == L"");
    CPPUNIT_ASSERT(array.CreatedBy() == L"");
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例12: catch

bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response, const Dictionary::Ptr& params)
{
    if (request.RequestUrl->GetPath().size() < 3 || request.RequestUrl->GetPath().size() > 4)
        return false;

    if (request.RequestMethod != "GET")
        return false;

    Type::Ptr type = FilterUtility::TypeFromPluralName(request.RequestUrl->GetPath()[2]);

    if (!type) {
        HttpUtility::SendJsonError(response, params, 400, "Invalid type specified.");
        return true;
    }

    QueryDescription qd;
    qd.Types.insert(type->GetName());
    qd.Permission = "objects/query/" + type->GetName();

    Array::Ptr uattrs, ujoins, umetas;

    try {
        uattrs = params->Get("attrs");
    } catch (const std::exception&) {
        HttpUtility::SendJsonError(response, params, 400,
            "Invalid type for 'attrs' attribute specified. Array type is required.");
        return true;
    }

    try {
        ujoins = params->Get("joins");
    } catch (const std::exception&) {
        HttpUtility::SendJsonError(response, params, 400,
            "Invalid type for 'joins' attribute specified. Array type is required.");
        return true;
    }

    try {
        umetas = params->Get("meta");
    } catch (const std::exception&) {
        HttpUtility::SendJsonError(response, params, 400,
            "Invalid type for 'meta' attribute specified. Array type is required.");
        return true;
    }

    bool allJoins = HttpUtility::GetLastParameter(params, "all_joins");

    params->Set("type", type->GetName());

    if (request.RequestUrl->GetPath().size() >= 4) {
        String attr = type->GetName();
        boost::algorithm::to_lower(attr);
        params->Set(attr, request.RequestUrl->GetPath()[3]);
    }

    std::vector<Value> objs;

    try {
        objs = FilterUtility::GetFilterTargets(qd, params, user);
    } catch (const std::exception& ex) {
        HttpUtility::SendJsonError(response, params, 404,
            "No objects found.",
            DiagnosticInformation(ex));
        return true;
    }

    ArrayData results;
    results.reserve(objs.size());

    std::set<String> joinAttrs;
    std::set<String> userJoinAttrs;

    if (ujoins) {
        ObjectLock olock(ujoins);
        for (const String& ujoin : ujoins) {
            userJoinAttrs.insert(ujoin.SubStr(0, ujoin.FindFirstOf(".")));
        }
    }

    for (int fid = 0; fid < type->GetFieldCount(); fid++) {
        Field field = type->GetFieldInfo(fid);

        if (!(field.Attributes & FANavigation))
            continue;

        if (!allJoins && userJoinAttrs.find(field.NavigationName) == userJoinAttrs.end())
            continue;

        joinAttrs.insert(field.Name);
    }

    for (const ConfigObject::Ptr& obj : objs) {
        DictionaryData result1{
            { "name", obj->GetName() },
            { "type", obj->GetReflectionType()->GetName() }
        };

        DictionaryData metaAttrs;

        if (umetas) {
//.........这里部分代码省略.........
开发者ID:bebehei,项目名称:icinga2,代码行数:101,代码来源:objectqueryhandler.cpp

示例13: getFullPos

void Globals::getFullPos(FullPos &pos) {
  ArrayData *arr = Array::get();
  arr->getFullPos(pos);
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:4,代码来源:hphp_system.cpp

示例14: m_count

SharedVariant::SharedVariant(CVarRef source, bool serialized,
                             bool inner /* = false */,
                             bool unserializeObj /* = false */)
  : m_count (1), m_shouldCache(false), m_flags(0){
  ASSERT(!serialized || source.isString());

  m_type = source.getType();

  switch (m_type) {
  case KindOfBoolean:
    {
      m_data.num = source.toBoolean();
      break;
    }
  case KindOfByte:
  case KindOfInt16:
  case KindOfInt32:
  case KindOfInt64:
    {
      m_type = KindOfInt64;
      m_data.num = source.toInt64();
      break;
    }
  case KindOfDouble:
    {
      m_data.dbl = source.toDouble();
      break;
    }
  case KindOfStaticString:
  case KindOfString:
    {
      String s = source.toString();
      if (serialized) {
        m_type = KindOfObject;
        // It is priming, and there might not be the right class definitions
        // for unserialization.
        s = apc_reserialize(s);
      }
      m_data.str = s->copy(true);
      break;
    }
  case KindOfArray:
    {
      ArrayData *arr = source.getArrayData();

      if (!inner) {
        // only need to call hasInternalReference() on the toplevel array
        PointerSet seen;
        if (arr->hasInternalReference(seen)) {
          setSerializedArray();
          m_shouldCache = true;
          String s = apc_serialize(source);
          m_data.str = new StringData(s.data(), s.size(), CopyString);
          break;
        }
      }

      size_t size = arr->size();
      if (arr->isVectorData()) {
        setIsVector();
        m_data.vec = new VectorData(size);
        uint i = 0;
        for (ArrayIter it(arr); !it.end(); it.next(), i++) {
          SharedVariant* val = Create(it.secondRef(), false, true,
                                      unserializeObj);
          if (val->m_shouldCache) m_shouldCache = true;
          m_data.vec->vals[i] = val;
        }
      } else {
        m_data.map = new ImmutableMap(size);
        for (ArrayIter it(arr); !it.end(); it.next()) {
          SharedVariant* key = Create(it.first(), false, true,
                                      unserializeObj);
          SharedVariant* val = Create(it.secondRef(), false, true,
                                      unserializeObj);
          if (val->m_shouldCache) m_shouldCache = true;
          m_data.map->add(key, val);
        }
      }
      break;
    }
  case KindOfNull:
    {
      m_data.num = 0;
      break;
    }
  default:
    {
      ASSERT(source.isObject());
      m_shouldCache = true;
      if (unserializeObj) {
        // This assumes hasInternalReference(seen, true) is false
        ImmutableObj* obj = new ImmutableObj(source.getObjectData());
        m_data.obj = obj;
        setIsObj();
      } else {
        String s = apc_serialize(source);
        m_data.str = new StringData(s.data(), s.size(), CopyString);
      }
      break;
//.........这里部分代码省略.........
开发者ID:jhockly,项目名称:RED-COLOR-IS-MY-FAVORITE-COLOR,代码行数:101,代码来源:shared_variant.cpp

示例15: INSTANCE_METHOD_INJECTION_BUILTIN

void c_MutableArrayIterator::t___construct(VRefParam array) {
  INSTANCE_METHOD_INJECTION_BUILTIN(MutableArrayIterator, MutableArrayIterator::__construct);
  if (m_valid) {
    MIterCtx& mi = marr();
    mi.~MIterCtx();
    m_valid = false;
  }
  Variant var(strongBind(array));
  TypedValue* tv = (TypedValue*)(&var);
  ASSERT(tv->m_type == KindOfRef);
  if (tv->m_data.ptv->m_type == KindOfArray) {
    ArrayData* ad = tv->m_data.ptv->m_data.parr;
    if (ad->getCount() > 1) {
      ArrayData* copy = ad->copy();
      copy->incRefCount();
      ad->decRefCount();  // count > 1 to begin with; don't need release
      ad = tv->m_data.ptv->m_data.parr = copy;
    }
    MIterCtx& mi = marr();
    (void) new (&mi) MIterCtx(tv->m_data.pref);
    m_valid = mi.m_mArray->advance();
    if (!m_valid) mi.~MIterCtx();
  } else if (tv->m_data.ptv->m_type == KindOfObject) {
    CStrRef ctxStr = hhvm
                     ? g_vmContext->getContextClassName(true)
                     : FrameInjection::GetClassName(true);
    bool isIterator;
    Object obj = tv->m_data.ptv->m_data.pobj->iterableObject(isIterator);
    if (isIterator) {
      raise_error("An iterator cannot be used with foreach by reference");
    }
    Array iterArray = obj->o_toIterArray(ctxStr, true);
    ArrayData* ad = iterArray.getArrayData();
    if (ad->getCount() > 1) {
      ArrayData* copy = ad->copy();
      copy->incRefCount();
      ad->decRefCount();  // count > 1 to begin with; don't need release
      ad = copy;
    }
    MIterCtx& mi = marr();
    (void) new (&mi) MIterCtx(ad);
    m_valid = mi.m_mArray->advance();
    if (!m_valid) mi.~MIterCtx();
  } else {
    raise_warning("Invalid argument supplied for foreach()");
  }
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:47,代码来源:ext_iterator.cpp


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