本文整理汇总了C++中ArrayIter::next方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayIter::next方法的具体用法?C++ ArrayIter::next怎么用?C++ ArrayIter::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayIter
的用法示例。
在下文中一共展示了ArrayIter::next方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: 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);
}
}
}
示例3: 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();
}
示例4: 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()));
}
}
示例5: iter_next_cold
/**
* iter_next will advance the iterator to point to the next element.
* If the iterator reaches the end, iter_next will free the iterator
* and will decRef the array.
* This function has been split into hot and cold parts. The hot part has
* been carefully crafted so that it's a leaf function (after all functions
* it calls have been trivially inlined) that then tail calls a cold
* version of itself (iter_next_array_cold). The hot part should cover the
* common case, which occurs when the array parameter is an HphpArray.
* If you make any changes to this function, please keep the hot/cold
* splitting in mind, and disasemble the optimized version of the binary
* to make sure the hot part is a good-looking leaf function; otherwise,
* you're likely to get a performance regression.
*/
static NEVER_INLINE
int64 iter_next_cold(Iter* iter, TypedValue* valOut, TypedValue* keyOut) {
TRACE(2, "iter_next_cold: I %p\n", iter);
ASSERT(iter->m_itype == Iter::TypeArray ||
iter->m_itype == Iter::TypeIterator);
ArrayIter* ai = &iter->arr();
ai->next();
if (ai->end()) {
// The ArrayIter destructor will decRef the array
ai->~ArrayIter();
iter->m_itype = Iter::TypeUndefined;
return 0;
}
if (iter->m_itype == Iter::TypeArray) {
iter_value_cell_local_impl<true>(iter, valOut);
if (keyOut) {
iter_key_cell_local_impl<true>(iter, keyOut);
}
} else {
iter_value_cell_local_impl<false>(iter, valOut);
if (keyOut) {
iter_key_cell_local_impl<false>(iter, keyOut);
}
}
return 1;
}
示例6: 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());
}
}
示例7: 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);
}
示例8: yaf_route_rewrite_match
static Variant yaf_route_rewrite_match(const Object& o,
const char* req_uri, int req_uri_len)
{
char match[8192];
auto ptr_match = o->o_realProp(YAF_ROUTE_PROPETY_NAME_MATCH,
ObjectData::RealPropUnchecked, "Yaf_Route_Rewrite");
snprintf(match, sizeof(match), "%s", ptr_match->toString().c_str());
std::string pattern;
pattern.append(YAF_ROUTE_REGEX_DILIMITER_STR);
pattern.append("^");
char* save_ptr;
char* seg = strtok_r(match, YAF_ROUTER_URL_DELIMIETER, &save_ptr);
while (seg != NULL) {
int len = strlen(seg);
if (len) {
pattern.append(YAF_ROUTER_URL_DELIMIETER);
if (*seg == '*') {
pattern.append("(?P<__yaf_route_rest>.*)");
break;
}
if (*seg == ':') {
pattern.append("(?P<");
pattern.append(std::string(seg+1));
pattern.append(std::string(">[^") + YAF_ROUTER_URL_DELIMIETER + "]+)");
} else {
pattern.append(seg);
}
}
seg = strtok_r(NULL, YAF_ROUTER_URL_DELIMIETER, &save_ptr);
}
pattern.append(YAF_ROUTE_REGEX_DILIMITER_STR);
pattern.append("i");
Variant matches;
Variant ret = preg_match_all(String(pattern),
String(std::string(req_uri, req_uri_len)), matches);
int match_count = 0;
if (ret.isIntVal() ) {
match_count = ret.toInt32();
}
if (match_count <= 0) {
return init_null_variant;
}
if (!matches.isArray()) {
return init_null_variant;
}
Array args = Array::Create();
Array& arr_matches = matches.toArrRef();
ArrayIter iter = arr_matches.begin();
while (!iter.end()) {
Variant key = iter.first();
Variant value = iter.second();
if (!key.isString()) {
iter.next();
continue;
}
if (!strncmp(key.toString().c_str(), "__yaf_route_rest", key.toString().length())) {
Variant retval = yaf_router_parse_parameters(value.toArrRef()[0].toString().c_str());
if (retval.isArray()) {
args.merge(retval.toArray());
}
} else {
args.set(key, value.toArrRef()[0]);
}
iter.next();
}
return args;
}