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


C++ ArrayIter::second方法代码示例

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


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

示例1: debug_string_backtrace

String debug_string_backtrace(bool skip, bool ignore_args /* = false */,
                              int limit /* = 0 */) {
  if (RuntimeOption::InjectedStackTrace) {
    Array bt;
    StringBuffer buf;
    bt = g_context->debugBacktrace(skip, false, false, nullptr,
                                     ignore_args, limit);
    int i = 0;
    for (ArrayIter it = bt.begin(); !it.end(); it.next(), i++) {
      Array frame = it.second().toArray();
      buf.append('#');
      buf.append(i);
      if (i < 10) buf.append(' ');
      buf.append(' ');
      if (frame.exists(s_class)) {
        buf.append(frame->get(s_class).toString());
        buf.append(frame->get(s_type).toString());
      }
      buf.append(frame->get(s_function).toString());
      buf.append("(");
      if (!ignore_args) {
        bool first = true;
        for (ArrayIter it = frame->get(s_args).begin(); !it.end(); it.next()) {
          if (!first) {
            buf.append(", ");
          } else {
            first = false;
          }
          try {
            buf.append(it.second().toString());
          } catch (FatalErrorException& fe) {
            buf.append(fe.getMessage());
          }
        }
      }
      buf.append(")");
      if (frame.exists(s_file)) {
        buf.append(" called at [");
        buf.append(frame->get(s_file).toString());
        buf.append(':');
        buf.append(frame->get(s_line).toString());
        buf.append(']');
      }
      buf.append('\n');
    }
    return buf.detach();
  } else {
    StackTrace st;
    return String(st.toString());
  }
}
开发者ID:RdeWilde,项目名称:hhvm,代码行数:51,代码来源:ext_error.cpp

示例2: debug_string_backtrace

String debug_string_backtrace(bool skip, bool ignore_args /* = false */,
                              int64_t limit /* = 0 */) {
  Array bt;
  StringBuffer buf;
  bt = createBacktrace(BacktraceArgs()
                       .skipTop(skip)
                       .ignoreArgs(ignore_args)
                       .setLimit(limit));
  int i = 0;
  for (ArrayIter it = bt.begin(); !it.end(); it.next(), i++) {
    Array frame = it.second().toArray();
    buf.append('#');
    buf.append(i);
    if (i < 10) buf.append(' ');
    buf.append(' ');
    if (frame.exists(s_class)) {
      buf.append(frame->get(s_class).toString());
      buf.append(frame->get(s_type).toString());
    }
    buf.append(frame->get(s_function).toString());
    buf.append("(");
    if (!ignore_args) {
      bool first = true;
      for (ArrayIter it(frame->get(s_args).toArray());
          !it.end();
          it.next()) {
        if (!first) {
          buf.append(", ");
        } else {
          first = false;
        }
        try {
          buf.append(it.second().toString());
        } catch (FatalErrorException& fe) {
          buf.append(fe.getMessage());
        }
      }
    }
    buf.append(")");
    if (frame.exists(s_file)) {
      buf.append(" called at [");
      buf.append(frame->get(s_file).toString());
      buf.append(':');
      buf.append(frame->get(s_line).toString());
      buf.append(']');
    }
    buf.append('\n');
  }
  return buf.detach();
}
开发者ID:Debug-Orz,项目名称:hhvm,代码行数:50,代码来源:ext_std_errorfunc.cpp

示例3: eval

void ForEachStatement::eval(VariableEnvironment &env) const {
  if (env.isGotoing()) return;
  ENTER_STMT;
  DECLARE_THREAD_INFO;
  LOOP_COUNTER(1);
  Variant map(m_source->eval(env));
  if (m_key) {
    TempExpressionList *texp = m_key->cast<TempExpressionList>();
    if (texp) {
      for (ArrayIter iter = map.begin(env.currentContext(), true);
           !iter.end(); iter.next()) {
        {
          LOOP_COUNTER_CHECK_INFO(1);
          const Variant &value = iter.second();
          const Variant &key = iter.first();
          TempExpressionHelper helper(texp, env);
          m_value->set(env, value);
          texp->setImpl(env, key);
        }
        if (!m_body) continue;
        EVAL_STMT_HANDLE_GOTO_BEGIN(restart1);
        EVAL_STMT_HANDLE_BREAK(m_body, env);
        EVAL_STMT_HANDLE_GOTO_END(restart1);
      }
    } else {
      for (ArrayIter iter = map.begin(env.currentContext(), true);
           !iter.end(); iter.next()) {
        LOOP_COUNTER_CHECK_INFO(1);
        const Variant &value = iter.second();
        const Variant &key = iter.first();
        m_value->set(env, value);
        m_key->set(env, key);
        if (!m_body) continue;
        EVAL_STMT_HANDLE_GOTO_BEGIN(restart2);
        EVAL_STMT_HANDLE_BREAK(m_body, env);
        EVAL_STMT_HANDLE_GOTO_END(restart2);
      }
    }
  } else {
    for (ArrayIter iter = map.begin(env.currentContext(), true);
         !iter.end(); iter.next()) {
      LOOP_COUNTER_CHECK_INFO(1);
      m_value->set(env, iter.second());
      if (!m_body) continue;
      EVAL_STMT_HANDLE_GOTO_BEGIN(restart3);
      EVAL_STMT_HANDLE_BREAK(m_body, env);
      EVAL_STMT_HANDLE_GOTO_END(restart3);
    }
  }
}
开发者ID:canerdogan,项目名称:hiphop-php,代码行数:50,代码来源:foreach_statement.cpp

示例4: getArrayIterHelper

ALWAYS_INLINE
typename std::enable_if<
  std::is_base_of<BaseMap, TMap>::value, Object>::type
BaseMap::php_zip(const Variant& iterable) const {
  size_t sz;
  ArrayIter iter = getArrayIterHelper(iterable, sz);
  auto map = req::make<TMap>();
  if (!m_size) {
    return Object{std::move(map)};
  }
  map->reserve(std::min(sz, size_t(m_size)));
  uint32_t used = posLimit();
  for (uint32_t i = 0; i < used && iter; ++i) {
    if (isTombstone(i)) continue;
    const Elm& e = data()[i];
    Variant v = iter.second();
    auto pair = req::make<c_Pair>(c_Pair::NoInit{});
    pair->initAdd(&e.data);
    pair->initAdd(v);
    TypedValue tv;
    tv.m_data.pobj = pair.detach();
    tv.m_type = KindOfObject;
    if (e.hasIntKey()) {
      map->setRaw(e.ikey, &tv);
    } else {
      assert(e.hasStrKey());
      map->setRaw(e.skey, &tv);
    }
    ++iter;
  }
  return Object{std::move(map)};
}
开发者ID:gamer7569,项目名称:hhvm,代码行数:32,代码来源:ext_collections-map.cpp

示例5: debug_string_backtrace

String debug_string_backtrace(bool skip) {
  if (RuntimeOption::InjectedStackTrace) {
    Array bt;
    StringBuffer buf;
    bt = g_vmContext->debugBacktrace(skip);
    int i = 0;
    for (ArrayIter it = bt.begin(); !it.end(); it.next(), i++) {
      Array frame = it.second().toArray();
      buf.append('#');
      buf.append(i);
      if (i < 10) buf.append(' ');
      buf.append(' ');
      if (frame.exists(s_class)) {
        buf.append(frame->get(s_class).toString());
        buf.append(frame->get(s_type).toString());
      }
      buf.append(frame->get(s_function).toString());
      buf.append("()");
      if (frame.exists(s_file)) {
        buf.append(" called at [");
        buf.append(frame->get(s_file).toString());
        buf.append(':');
        buf.append(frame->get(s_line).toString());
        buf.append(']');
      }
      buf.append('\n');
    }
    return buf.detach();
  } else {
    StackTrace st;
    return String(st.toString());
  }
}
开发者ID:7755373049,项目名称:hiphop-php,代码行数:33,代码来源:ext_error.cpp

示例6: f_debug_print_backtrace

void f_debug_print_backtrace() {
  if (RuntimeOption::InjectedStackTrace) {
    Array bt = FrameInjection::GetBacktrace(true);
    int i = 0;
    for (ArrayIter it = bt.begin(); !it.end(); it.next(), i++) {
      Array frame = it.second().toArray();
      StringBuffer buf;
      buf.append('#');
      buf.append(i);
      if (i < 10) buf.append(' ');
      buf.append(' ');
      if (frame.exists("class")) {
        buf.append(frame->get("class").toString());
        buf.append(frame->get("type").toString());
      }
      buf.append(frame->get("function").toString());
      buf.append("()");
      if (frame.exists("file")) {
        buf.append(" called at [");
        buf.append(frame->get("file").toString());
        buf.append(':');
        buf.append(frame->get("line").toString());
        buf.append(']');
      }
      buf.append('\n');
      echo(buf.detach());
    }
  } else {
    StackTrace st;
    echo(String(st.toString()));
  }
}
开发者ID:Jostein,项目名称:hiphop-php,代码行数:32,代码来源:ext_error.cpp

示例7: setAllImpl

void BaseMap::setAllImpl(const Variant& iterable) {
  if (iterable.isNull()) return;
  size_t sz;
  ArrayIter iter = getArrayIterHelper(iterable, sz);
  for (; iter; ++iter) {
    set(iter.first(), iter.second());
  }
}
开发者ID:gamer7569,项目名称:hhvm,代码行数:8,代码来源:ext_collections-map.cpp

示例8: init

void BaseVector::init(CVarRef t) {
  size_t sz;
  ArrayIter iter = getArrayIterHelper(t, sz);
  if (sz) {
    reserve(sz);
  }
  for (; iter; ++iter) {
    Variant v = iter.second();
    TypedValue* tv = cvarToCell(&v);
    add(tv);
  }
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:12,代码来源:base_vector.cpp

示例9: addAllPairs

void BaseMap::addAllPairs(const Variant& iterable) {
  if (iterable.isNull()) return;
  VMRegGuard _;
  size_t sz;
  ArrayIter iter = getArrayIterHelper(iterable, sz);
  auto oldCap = cap();
  reserve(m_size + sz); // presume minimum key collisions ...
  for (; iter; ++iter) {
    add(iter.second());
  }
  // ... and shrink back if that was incorrect
  shrinkIfCapacityTooHigh(oldCap);
}
开发者ID:gamer7569,项目名称:hhvm,代码行数:13,代码来源:ext_collections-map.cpp

示例10: zip

void BaseVector::zip(BaseVector* bvec, CVarRef iterable) {
  size_t itSize;
  ArrayIter iter = getArrayIterHelper(iterable, itSize);
  uint sz = m_size;
  bvec->reserve(std::min(itSize, size_t(sz)));
  for (uint i = 0; i < sz && iter; ++i, ++iter) {
    Variant v = iter.second();
    if (bvec->m_capacity <= bvec->m_size) {
      bvec->grow();
    }
    c_Pair* pair = NEWOBJ(c_Pair)();
    pair->incRefCount();
    pair->initAdd(&m_data[i]);
    pair->initAdd(cvarToCell(&v));
    bvec->m_data[i].m_data.pobj = pair;
    bvec->m_data[i].m_type = KindOfObject;
    ++bvec->m_size;
  }
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:19,代码来源:base_vector.cpp

示例11: getArrayIterHelper

typename std::enable_if<
  std::is_base_of<BaseVector, TVector>::value, Object>::type
BaseSet::php_concat(const Variant& iterable) {
  size_t itSize;
  ArrayIter iter = getArrayIterHelper(iterable, itSize);
  auto vec = req::make<TVector>();
  uint32_t sz = m_size;
  vec->reserve((size_t)sz + itSize);
  assert(vec->canMutateBuffer());
  vec->setSize(sz);

  uint32_t used = posLimit();
  for (uint32_t i = 0, j = 0; i < used; ++i) {
    if (isTombstone(i)) {
      continue;
    }
    cellDup(data()[i].data, vec->data()[j]);
    ++j;
  }
  for (; iter; ++iter) {
    vec->addRaw(iter.second());
  }
  return Object{std::move(vec)};
}
开发者ID:Mr-Kumar-Abhishek,项目名称:hhvm,代码行数:24,代码来源:ext_collections-set.cpp

示例12: recursiveAddVar

bool WddxPacket::recursiveAddVar(const String& varName,
                                 const Variant& varVariant,
                                 bool hasVarTag) {

  bool isArray = varVariant.isArray();
  bool isObject = varVariant.isObject();

  if (isArray || isObject) {
    if (hasVarTag) {
      m_packetString.append("<var name='");
      m_packetString.append(varName.data());
      m_packetString.append("'>");
    }

    Array varAsArray;
    Object varAsObject = varVariant.toObject();
    if (isArray) varAsArray = varVariant.toArray();
    if (isObject) varAsArray = varAsObject.toArray();

    int length = varAsArray.length();
    if (length > 0) {
      ArrayIter it = ArrayIter(varAsArray);
      if (it.first().isString()) isObject = true;
      if (isObject) {
        m_packetString.append("<struct>");
        if (!isArray) {
          m_packetString.append("<var name='php_class_name'><string>");
          m_packetString.append(varAsObject->getClassName());
          m_packetString.append("</string></var>");
        }
      } else {
        m_packetString.append("<array length='");
        m_packetString.append(std::to_string(length));
        m_packetString.append("'>");
      }
      for (ArrayIter it(varAsArray); it; ++it) {
        Variant key = it.first();
        Variant value = it.second();
        recursiveAddVar(key.toString(), value, isObject);
      }
      if (isObject) {
        m_packetString.append("</struct>");
      }
      else {
        m_packetString.append("</array>");
      }
    }
    else {
      //empty object
      if (isObject) {
        m_packetString.append("<struct>");
        if (!isArray) {
          m_packetString.append("<var name='php_class_name'><string>");
          m_packetString.append(varAsObject->getClassName());
          m_packetString.append("</string></var>");
        }
        m_packetString.append("</struct>");
      }
    }
    if (hasVarTag) {
      m_packetString.append("</var>");
    }
    return true;
  }

  String varType = getDataTypeString(varVariant.getType());
  if (!getWddxEncoded(varType, "", varName, false).empty()) {
    String varValue;
    if (varType.compare("boolean") == 0) {
      varValue = varVariant.toBoolean() ? "true" : "false";
    } else {
      varValue = StringUtil::HtmlEncode(varVariant.toString(),
                                        StringUtil::QuoteStyle::Double,
                                        "UTF-8", false, false).toCppString();
    }
    m_packetString.append(
      getWddxEncoded(varType, varValue, varName, hasVarTag));
    return true;
  }

  return false;
}
开发者ID:anthonyattard,项目名称:hhvm,代码行数:82,代码来源:ext_wddx.cpp

示例13: TestArray

bool TestCppBase::TestArray() {
  // Array::Create(), Array constructors and informational
  {
    Array arr;
    VERIFY(arr.empty()); VERIFY(arr.size() == 0); VERIFY(arr.length() == 0);
    VERIFY(arr.isNull());

    arr = Array::Create();
    VERIFY(arr.empty()); VERIFY(arr.size() == 0); VERIFY(arr.length() == 0);
    VERIFY(!arr.isNull());

    arr = Array::Create(0);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY((int)arr[0] == 0);
    VS(arr, Array(ArrayInit(1).set(0).create()));

    arr = Array::Create("test");
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[0] == "test");
    VS(arr, Array(ArrayInit(1).set("test").create()));

    Array arrCopy = arr;
    arr = Array::Create(arr);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[0].toArray().size() == 1);
    VS(arr[0], arrCopy);
    VS(arr, Array(ArrayInit(1).set(arrCopy).create()));

    arr = Array::Create("name", 1);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY((int)arr[s_name] == 1);
    VS(arr, Array(ArrayInit(1).set(s_name, 1).create()));

    arr = Array::Create(s_name, "test");
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[s_name] == "test");
    VS(arr, Array(ArrayInit(1).set(s_name, "test").create()));

    arrCopy = arr;
    arr = Array::Create(s_name, arr);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VS(arr[s_name], arrCopy);
    VERIFY(arr[s_name].toArray().size() == 1);
    VS(arr, Array(ArrayInit(1).set(s_name, arrCopy).create()));
  }

  // iteration
  {
    Array arr = CREATE_MAP2("n1", "v1", "n2", "v2");
    int i = 0;
    for (ArrayIter iter = arr.begin(); iter; ++iter, ++i) {
      if (i == 0) {
        VERIFY(iter.first() == "n1");
        VERIFY(iter.second() == "v1");
      } else {
        VERIFY(iter.first() == "n2");
        VERIFY(iter.second() == "v2");
      }
    }
    VERIFY(i == 2);
  }
  /* TODO: fix this
  {
    Variant arr = CREATE_MAP2("n1", "v1", "n2", "v2");
    arr.escalate();
    for (ArrayIterPtr iter = arr.begin(arr, true); !iter->end(); iter->next()){
      unset(arr.lvalAt(iter->first()));
    }
    VS(arr, Array::Create());
  }
  */

  // conversions
  {
    Array arr0;
    VERIFY(arr0.toBoolean() == false);
    VERIFY(arr0.toByte() == 0);
    VERIFY(arr0.toInt16() == 0);
    VERIFY(arr0.toInt32() == 0);
    VERIFY(arr0.toInt64() == 0);
    VERIFY(arr0.toDouble() == 0.0);
    VERIFY(arr0.toString() == "");

    Array arr1 = Array::Create("test");
    VERIFY(arr1.toBoolean() == true);
    VERIFY(arr1.toByte() == 1);
    VERIFY(arr1.toInt16() == 1);
    VERIFY(arr1.toInt32() == 1);
    VERIFY(arr1.toInt64() == 1);
    VERIFY(arr1.toDouble() == 1.0);
    VERIFY(arr1.toString() == "Array");
  }

  // offset
//.........这里部分代码省略.........
开发者ID:wanghong1987,项目名称:hiphop-php,代码行数:101,代码来源:test_cpp_base.cpp

示例14: test_pdo_sqlite

bool TestExtPdo::test_pdo_sqlite() {
  CreateSqliteTestTable();

  try {
    string source = "sqlite:/tmp/foo.db";

    p_PDO dbh(NEWOBJ(c_PDO)());
    dbh->t___construct(source.c_str(), TEST_USERNAME, TEST_PASSWORD,
                       CREATE_MAP1(q_PDO$$ATTR_PERSISTENT, false));
    Variant vstmt = dbh->t_prepare("select * from foo");
    c_PDOStatement *stmt = vstmt.toObject().getTyped<c_PDOStatement>();
    VERIFY(stmt->t_execute());

    Variant rs = stmt->t_fetch(q_PDO$$FETCH_ASSOC);
    VS(rs, CREATE_MAP1("bar", "ABC"));
    rs = stmt->t_fetch(q_PDO$$FETCH_ASSOC);
    VS(rs, CREATE_MAP1("bar", "DEF"));

  } catch (Object &e) {
    VS(e, null);
  }

  try {
    string source = "sqlite:/tmp/foo.db";

    p_PDO dbh(NEWOBJ(c_PDO)());
    dbh->t___construct(source.c_str(), TEST_USERNAME, TEST_PASSWORD,
                       CREATE_MAP1(q_PDO$$ATTR_PERSISTENT, false));
    Variant vstmt = dbh->t_query("select * from foo");
    ArrayIter iter = vstmt.begin();
    VERIFY(!iter.end());
    VS(iter.first(), 0);
    VS(iter.second(), CREATE_MAP2("bar", "ABC", 0, "ABC"));
    iter.next();
    VERIFY(!iter.end());
    VS(iter.first(), 1);
    VS(iter.second(), CREATE_MAP2("bar", "DEF", 0, "DEF"));
    iter.next();
    VERIFY(iter.end());

  } catch (Object &e) {
    VS(e, null);
  }

  try {
    string source = "sqlite:/tmp/foo.db";
    p_PDO dbh(NEWOBJ(c_PDO)());
    dbh->t___construct(source.c_str(), TEST_USERNAME, TEST_PASSWORD,
                       CREATE_MAP1(q_PDO$$ATTR_PERSISTENT, false));
    dbh->t_query("CREATE TABLE IF NOT EXISTS foobar (id INT)");
    dbh->t_query("INSERT INTO foobar (id) VALUES (1)");
    Variant res = dbh->t_query("SELECT id FROM foobar LIMIT 1");
    c_PDOStatement *stmt = res.toObject().getTyped<c_PDOStatement>();
    Variant ret = stmt->t_fetch();
    VS(ret["id"], "1");

  } catch (Object &e) {
    VS(e, null);
  }

  CleanupSqliteTestTable();
  return Count(true);
}
开发者ID:devmario,项目名称:hiphop-php,代码行数:63,代码来源:test_ext_pdo.cpp

示例15: TestArray

bool TestCppBase::TestArray() {
  // Array::Create(), Array constructors and informational
  {
    Array arr;
    VERIFY(arr.empty()); VERIFY(arr.size() == 0); VERIFY(arr.length() == 0);
    VERIFY(arr.isNull());

    arr = Array::Create();
    VERIFY(arr.empty()); VERIFY(arr.size() == 0); VERIFY(arr.length() == 0);
    VERIFY(!arr.isNull());

    arr = Array::Create(0);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[0].toInt32() == 0);

    arr = Array::Create("test");
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(equal(arr[0], String("test")));

    Array arrCopy = arr;
    arr = Array::Create(arr);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[0].toArray().size() == 1);
    VS(arr[0], arrCopy);

    arr = Array::Create("name", 1);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(arr[s_name].toInt32() == 1);

    arr = Array::Create(s_name, "test");
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VERIFY(equal(arr[s_name], String("test")));

    arrCopy = arr;
    arr = Array::Create(s_name, arr);
    VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
    VERIFY(!arr.isNull());
    VS(arr[s_name], arrCopy);
    VERIFY(arr[s_name].toArray().size() == 1);
  }

  // iteration
  {
    Array arr = make_map_array("n1", "v1", "n2", "v2");
    int i = 0;
    for (ArrayIter iter = arr.begin(); iter; ++iter, ++i) {
      if (i == 0) {
        VERIFY(equal(iter.first(), String("n1")));
        VERIFY(equal(iter.second(), String("v1")));
      } else {
        VERIFY(equal(iter.first(), String("n2")));
        VERIFY(equal(iter.second(), String("v2")));
      }
    }
    VERIFY(i == 2);
  }

  static const StaticString s_Array("Array");

  // conversions
  {
    Array arr0;
    VERIFY(arr0.toBoolean() == false);
    VERIFY(arr0.toByte() == 0);
    VERIFY(arr0.toInt16() == 0);
    VERIFY(arr0.toInt32() == 0);
    VERIFY(arr0.toInt64() == 0);
    VERIFY(arr0.toDouble() == 0.0);
    VERIFY(arr0.toString().empty());

    Array arr1 = Array::Create("test");
    VERIFY(arr1.toBoolean() == true);
    VERIFY(arr1.toByte() == 1);
    VERIFY(arr1.toInt16() == 1);
    VERIFY(arr1.toInt32() == 1);
    VERIFY(arr1.toInt64() == 1);
    VERIFY(arr1.toDouble() == 1.0);
    VERIFY(arr1.toString() == s_Array);
  }

  // offset
  {
    Array arr;
    arr.set(0, "v1");
    arr.set(1, "v2");
    VS(arr, make_packed_array("v1", "v2"));
  }
  {
    Array arr;
    arr.set(s_n1, "v1");
    arr.set(s_n2, "v2");
    VS(arr, make_map_array("n1", "v1", "n2", "v2"));
  }
  {
    Array arr;
//.........这里部分代码省略.........
开发者ID:AmineCherrai,项目名称:hhvm,代码行数:101,代码来源:test_cpp_base.cpp


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