本文整理汇总了C++中CArrRef::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ CArrRef::exists方法的具体用法?C++ CArrRef::exists怎么用?C++ CArrRef::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrRef
的用法示例。
在下文中一共展示了CArrRef::exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HHVM_STATIC_METHOD
static Variant HHVM_STATIC_METHOD(Locale, composeLocale, CArrRef subtags) {
s_intl_error->clearError();
if (subtags.exists(s_GRANDFATHERED)) {
auto val = subtags[s_GRANDFATHERED];
if (val.isString()) {
return val;
}
}
if (!subtags.exists(s_LOC_LANG)) {
s_intl_error->setError(U_ILLEGAL_ARGUMENT_ERROR, "locale_compose: "
"parameter array does not contain 'language' tag.");
return false;
}
String ret(subtags[s_LOC_LANG].toString());
if (!append_multiple_key_values(ret, subtags, LOC_EXTLANG) ||
!append_key_value(ret, subtags, LOC_SCRIPT) ||
!append_key_value(ret, subtags, LOC_REGION) ||
!append_multiple_key_values(ret, subtags, LOC_VARIANT) ||
!append_multiple_key_values(ret, subtags, LOC_PRIVATE)) {
return false;
}
return ret;
}
示例2: mergeParams
void StreamContext::mergeParams(CArrRef params) {
if (m_params.isNull()) {
m_params = Array::Create();
}
const String& notification_key = String::FromCStr("notification");
if (params.exists(notification_key)) {
m_params.set(notification_key, params[notification_key]);
}
const String& options_key = String::FromCStr("options");
if (params.exists(options_key)) {
assert(params[options_key].isArray());
mergeOptions(params[options_key].toArray());
}
}
示例3: create
bool PDOSqliteConnection::create(CArrRef options) {
String filename = data_source.substr(0,1) == ":" ? String(data_source) :
File::TranslatePath(data_source);
if (filename.empty()) {
throw_pdo_exception(0, Array(),
"safe_mode/open_basedir prohibits opening %s",
data_source.c_str());
return false;
}
if (sqlite3_open(filename.data(), &m_db) != SQLITE_OK) {
handleError(__FILE__, __LINE__);
return false;
}
sqlite3_set_authorizer(m_db, authorizer, NULL);
long timeout = 60;
if (options.exists(PDO_ATTR_TIMEOUT)) {
timeout = options[PDO_ATTR_TIMEOUT].toInt64();
}
sqlite3_busy_timeout(m_db, timeout * 1000);
return true;
}
示例4: pdo_attr_strval
String pdo_attr_strval(const CArrRef& options, int opt, const char *def){
if(options.exists(opt)){
return options[opt].toString();
}
if(def){
return def;
}
return String();
}
示例5: append_key_value
static bool append_key_value(String& ret,
CArrRef subtags,
LocaleTag tag) {
auto name = LocaleName(tag);
if (!subtags.exists(name)) return true;
auto val = subtags[name];
if (!val.isString()) {
element_not_string();
return false;
}
ret += s_SEPARATOR + val.toString();
return true;
}
示例6: StringOfFrame
std::string ExtendedLogger::StringOfFrame(CArrRef frame, int i, bool escape) {
std::ostringstream ss;
if (i > 0) {
ss << (escape ? "\\n" : "\n");
}
ss << " #" << i << " ";
if (frame.exists(s_function)) {
if (frame.exists(s_class)) {
ss << frame[s_class].toString().c_str()
<< frame[s_type].toString().c_str()
<< frame[s_function].toString().c_str()
<< "(), called ";
} else {
ss << frame[s_function].toString().c_str()
<< "(), called ";
}
}
ss << "at [" << frame[s_file].toString().c_str()
<< ":" << frame[s_line].toInt64() << "]";
return ss.str();
}
示例7: f_pagelet_server_task_start
Object f_pagelet_server_task_start(CStrRef url,
CArrRef headers /* = null_array */,
CStrRef post_data /* = null_string */,
CArrRef files /* = null_array */) {
String remote_host;
Transport *transport = g_context->getTransport();
if (transport) {
remote_host = transport->getRemoteHost();
if (!headers.exists("Host") && RuntimeOption::SandboxMode) {
Array tmp = headers;
tmp.set("Host", transport->getHeader("Host"));
return PageletServer::TaskStart(url, tmp, remote_host, post_data, files);
}
}
return PageletServer::TaskStart(url, headers, remote_host, post_data);
}
示例8: f_pagelet_server_task_start
Resource f_pagelet_server_task_start(CStrRef url,
CArrRef headers /* = null_array */,
CStrRef post_data /* = null_string */,
CArrRef files /* = null_array */) {
String remote_host;
Transport *transport = g_context->getTransport();
int timeout = ThreadInfo::s_threadInfo->m_reqInjectionData.getRemainingTime();
if (transport) {
remote_host = transport->getRemoteHost();
if (!headers.exists(s_Host) && RuntimeOption::SandboxMode) {
Array tmp = headers;
tmp.set(s_Host, transport->getHeader("Host"));
return PageletServer::TaskStart(url, tmp, remote_host,
post_data, files, timeout);
}
}
return PageletServer::TaskStart(url, headers, remote_host,
post_data, files, timeout);
}
示例9: diffImpl
Array Array::diffImpl(CArrRef array, bool by_key, bool by_value, bool match,
PFUNC_CMP key_cmp_function,
const void *key_data,
PFUNC_CMP value_cmp_function,
const void *value_data) const {
ASSERT(by_key || by_value);
ASSERT(by_key || key_cmp_function == NULL);
ASSERT(by_value || value_cmp_function == NULL);
PFUNC_CMP value_cmp_as_string_function = value_cmp_function;
if (!value_cmp_function) {
value_cmp_function = SortStringAscending;
value_cmp_as_string_function = CompareAsStrings;
}
Array ret = Array::Create();
if (by_key && !key_cmp_function) {
// Fast case
for (ArrayIter iter(*this); iter; ++iter) {
Variant key(iter.first());
CVarRef value(iter.secondRef());
bool found = false;
if (array->exists(key)) {
if (by_value) {
found = value_cmp_as_string_function(
value, array.rvalAt(key, AccessFlags::Key), value_data) == 0;
} else {
found = true;
}
}
if (found == match) {
ret.addLval(key, true).setWithRef(value);
}
}
return ret;
}
if (!key_cmp_function) {
key_cmp_function = SortRegularAscending;
}
vector<int> perm1;
SortData opaque1;
int bottom = 0;
int top = array.size();
PFUNC_CMP cmp;
const void *cmp_data;
if (by_key) {
cmp = key_cmp_function;
cmp_data = key_data;
} else {
cmp = value_cmp_function;
cmp_data = value_data;
}
SortImpl(perm1, array, opaque1, cmp, by_key, cmp_data);
for (ArrayIter iter(*this); iter; ++iter) {
Variant target;
if (by_key) {
target = iter.first();
} else {
target = iter.second();
}
int mid = -1;
int min = bottom;
int max = top;
while (min < max) {
mid = (max + min) / 2;
ssize_t pos = opaque1.positions[perm1[mid]];
int cmp_res = cmp(target,
by_key ? array->getKey(pos)
: array->getValueRef(pos),
cmp_data);
if (cmp_res > 0) { // outer is bigger
min = mid + 1;
} else if (cmp_res == 0) {
break;
} else {
max = mid;
}
}
bool found = false;
if (min < max) { // found
// if checking both, check value
if (by_key && by_value) {
CVarRef val(iter.secondRef());
// Have to look up and down for matches
for (int i = mid; i < max; i++) {
ssize_t pos = opaque1.positions[perm1[i]];
if (key_cmp_function(target, array->getKey(pos), key_data) != 0) {
break;
}
if (value_cmp_as_string_function(val, array->getValueRef(pos),
value_data) == 0) {
found = true;
break;
}
}
if (!found) {
for (int i = mid-1; i >= min; i--) {
//.........这里部分代码省略.........
示例10: append_multiple_key_values
static bool append_multiple_key_values(String& ret,
CArrRef subtags,
LocaleTag tag) {
auto name = LocaleName(tag);
if (subtags.exists(name)) {
// Sane version: [tag] => string, [tag] => array<tring>
auto val = subtags[name];
if (val.isString()) {
if (tag == LOC_PRIVATE) {
ret += s_SEPARATOR_x;
}
ret += s_SEPARATOR + val.toString();
return true;
}
if (!val.isArray()) {
return false;
}
bool first = true;
for (ArrayIter it(val.toArray()); it; ++it) {
auto v = it.second();
if (!v.isString()) {
element_not_string();
return false;
}
if (first) {
if (tag == LOC_PRIVATE) {
ret += s_SEPARATOR + "x";
}
first = false;
}
ret += s_SEPARATOR + v.toString();
}
return true;
}
// clowny version [tag$n] => string
// Only extlang, variant, and private
if (tag != LOC_EXTLANG &&
tag != LOC_VARIANT &&
tag != LOC_PRIVATE) {
return true;
}
int max = (tag == LOC_EXTLANG) ? 3 : 15;
bool first = true;
for (int i = 0; i < max; ++i) {
auto namenum = name + String(i, CopyString);
if (!subtags.exists(namenum)) continue;
auto val = subtags[namenum];
if (!val.isString()) {
element_not_string();
return false;
}
if (first) {
if (tag == LOC_PRIVATE) {
ret += s_SEPARATOR + "x";
}
first = false;
}
ret += s_SEPARATOR + val.toString();
}
return true;
}
示例11: pdo_attr_lval
long pdo_attr_lval(const CArrRef& options, int opt, long defaultValue){
if(options.exists(opt)){
return options[opt].toInt64();
}
return defaultValue;
}