本文整理汇总了C++中CStrRef::get方法的典型用法代码示例。如果您正苦于以下问题:C++ CStrRef::get方法的具体用法?C++ CStrRef::get怎么用?C++ CStrRef::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStrRef
的用法示例。
在下文中一共展示了CStrRef::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
bool ConcurrentTableSharedStore::get(CStrRef key, Variant &value) {
const StoreValue *sval;
SharedVariant *svar = nullptr;
ConditionalReadLock l(m_lock, !apcExtension::ConcurrentTableLockFree ||
m_lockingFlag);
bool expired = false;
bool promoteObj = false;
{
Map::const_accessor acc;
if (!m_vars.find(acc, key.data())) {
log_apc(std_apc_miss);
return false;
} else {
sval = &acc->second;
if (sval->expired()) {
// Because it only has a read lock on the data, deletion from
// expiration has to happen after the lock is released
expired = true;
} else {
if (!sval->inMem()) {
std::lock_guard<SmallLock> sval_lock(sval->lock);
if (!sval->inMem()) {
svar = unserialize(key, sval);
if (!svar) return false;
} else {
svar = sval->var;
}
} else {
svar = sval->var;
}
if (apcExtension::AllowObj && svar->is(KindOfObject)) {
// Hold ref here for later promoting the object
svar->incRef();
promoteObj = true;
}
value = svar->toLocal();
stats_on_get(key.get(), svar);
}
}
}
if (expired) {
log_apc(std_apc_miss);
eraseImpl(key, true);
return false;
}
log_apc(std_apc_hit);
if (promoteObj) {
handlePromoteObj(key, svar, value);
// release the extra ref
svar->decRef();
}
return true;
}
示例2: InvalidArgumentException
UserStreamWrapper::UserStreamWrapper(CStrRef name, CStrRef clsname) :
m_name(name) {
m_cls = Unit::loadClass(clsname.get());
if (!m_cls) {
throw InvalidArgumentException(0, "Undefined class '%s'", clsname.data());
}
// There is a third param in Zend to stream_wrapper_register() which could
// affect that when we add that param
m_isLocal = true;
}
示例3: f_defined
bool f_defined(CStrRef name, bool autoload /* = true */) {
if (!name.get()) return false;
const char *data = name.data();
int len = name.length();
char *colon;
if ((colon = (char*)memchr(data, ':', len)) && colon[1] == ':') {
// class constant
int classNameLen = colon - data;
char *constantName = colon + 2;
String className(data, classNameLen, CopyString);
// translate "self" or "parent"
if (className == "self") {
String this_class = g_vmContext->getContextClassName();
if (this_class.empty()) {
throw FatalErrorException("Cannot access self:: "
"when no class scope is active");
} else {
className = this_class;
}
} else if (className == "parent") {
String parent_class = g_vmContext->getParentContextClassName();
if (parent_class.empty()) {
throw FatalErrorException("Cannot access parent");
} else {
className = parent_class;
}
}
if (class_exists(className)) { // taking care of volatile class
const ClassInfo *info;
for (String parentClass = className;
!parentClass.empty();
parentClass = info->getParentClass()) {
info = ClassInfo::FindClass(parentClass);
if (!info) {
assert(false);
}
if (info->hasConstant(constantName)) return true;
}
return false;
} else {
return false;
}
} else {
// system/uniquely defined scalar constant
if (ClassInfo::FindConstant(name)) return true;
if (g_vmContext->defined(name)) {
return true;
}
if (!autoload || !AutoloadHandler::s_instance->autoloadConstant(name)) {
return false;
}
return g_vmContext->defined(name);
}
}
示例4: getIndex
int ThreadSharedVariant::getIndex(CStrRef key) {
ASSERT(is(KindOfArray));
if (getIsVector()) return -1;
StringData *sd = key.get();
if (RuntimeOption::ApcUseGnuMap) {
StringDataToIntMap::const_iterator it = m_data.gnuMap->strMap->find(sd);
if (it == m_data.gnuMap->strMap->end()) return -1;
return it->second;
}
return m_data.map->indexOf(sd);
}
示例5: WarnIfTainted
void TaintWarning::WarnIfTainted(CStrRef s, const taint_t bit) {
const TaintData& td = s.get()->getTaintDataRefConst();
if (!(td.getTaint() & bit)) { return; }
bool force_warning = false;
std::string buf, aux;
buf = "Using a ";
switch (bit) {
case TAINT_BIT_HTML:
buf += "HTML-unsafe (tainted)";
if (TaintTracer::IsTraceEnabled(TAINT_BIT_TRACE_HTML)) {
force_warning = true;
aux = TaintTracer::ExtractTrace(td.getTaintTrace());
}
break;
case TAINT_BIT_MUTATED:
buf += "non-static (tainted)";
break;
case TAINT_BIT_SQL:
buf += "SQL-unsafe (tainted)";
break;
case TAINT_BIT_SHELL:
buf += "shell-unsafe (tainted)";
break;
case TAINT_BIT_ALL:
buf += "tainted";
break;
default:
return;
}
buf += " string!\n";
if (RuntimeOption::EnableTaintWarnings || force_warning) {
buf += aux;
buf += "\n";
buf += "---begin output---\n";
buf += s.c_str();
buf += "\n";
buf += "----end output----\n";
ZeroCount(bit);
raise_warning(buf);
} else {
IncCount(bit);
}
}
示例6: f_defined
bool f_defined(CStrRef name, bool autoload /* = true */) {
if (!name.get()) return false;
const char *data = name.data();
int len = name.length();
char *colon;
if ((colon = (char*)memchr(data, ':', len)) && colon[1] == ':') {
// class constant
int classNameLen = colon - data;
char *constantName = colon + 2;
VM::Class* cls = getClassByName(data, classNameLen);
if (cls) {
String cnsName(constantName, data + len - constantName, CopyString);
return cls->clsCnsGet(cnsName.get());
}
return false;
} else {
return autoload ?
VM::Unit::loadCns(name.get()) :
VM::Unit::lookupCns(name.get());
}
}
示例7: get
CVarRef ZendArray::get(CStrRef k, bool error /* = false */) const {
StringData *key = k.get();
int64 prehash = key->hash();
Bucket *p = find(key->data(), key->size(), prehash);
if (p) {
return p->data;
}
if (error) {
raise_notice("Undefined index: %s", k.data());
}
return null_variant;
}
示例8: f_constant
Variant f_constant(CStrRef name) {
if (!name.get()) return uninit_null();
const char *data = name.data();
int len = name.length();
// slice off starting backslash
bool hadInitialBackslash = false;
if (len > 0 && data[0] == '\\') {
data += 1;
len -= 1;
hadInitialBackslash = true;
}
char *colon;
if ((colon = (char*)memchr(data, ':', len)) && colon[1] == ':') {
// class constant
int classNameLen = colon - data;
char *constantName = colon + 2;
Class* cls = getClassByName(data, classNameLen);
if (cls) {
String cnsName(constantName, data + len - constantName, CopyString);
TypedValue* tv = cls->clsCnsGet(cnsName.get());
if (tv) {
return tvAsCVarRef(tv);
}
}
raise_warning("Couldn't find constant %s", data);
} else {
TypedValue* cns;
if (hadInitialBackslash) {
String s(data, len, CopyString);
cns = Unit::loadCns(s.get());
} else {
cns = Unit::loadCns(name.get());
}
if (cns) return tvAsVariant(cns);
}
return uninit_null();
}
示例9: f_hphp_set_static_property
void f_hphp_set_static_property(CStrRef cls, CStrRef prop, CVarRef value) {
StringData* sd = cls.get();
Class* class_ = Unit::lookupClass(sd);
if (class_ == nullptr) {
String normName = normalizeNS(sd);
if (normName) {
return f_hphp_set_static_property(normName, prop, value);
} else {
raise_error("Non-existent class %s", sd->data());
}
}
VMRegAnchor _;
bool visible, accessible;
TypedValue* tv = class_->getSProp(arGetContextClass(
g_vmContext->getFP()),
prop.get(), visible, accessible);
if (tv == nullptr) {
raise_error("Class %s does not have a property named %s",
cls.get()->data(), prop.get()->data());
}
if (!visible || !accessible) {
raise_error("Invalid access to class %s's property %s",
cls.get()->data(), prop.get()->data());
}
tvAsVariant(tv) = value;
}
示例10: f_hphp_get_function_info
Array f_hphp_get_function_info(CStrRef name) {
Array ret;
const Func* func = Unit::loadFunc(name.get());
if (!func) return ret;
ret.set(s_name, VarNR(func->name()));
ret.set(s_closure, empty_string);
// setting parameters and static variables
set_function_info(ret, func);
set_source_info(ret, func->unit()->filepath()->data(),
func->line1(), func->line2());
return ret;
}
示例11: vm_get_class_vars
Array vm_get_class_vars(CStrRef className) {
HPHP::VM::Class* cls = HPHP::VM::Unit::lookupClass(className.get());
if (cls == NULL) {
raise_error("Unknown class %s", className->data());
}
cls->initialize();
const VM::Class::SProp* sPropInfo = cls->staticProperties();
const size_t numSProps = cls->numStaticProperties();
const VM::Class::Prop* propInfo = cls->declProperties();
const size_t numDeclProps = cls->numDeclProperties();
// The class' instance property initialization template is in different
// places, depending on whether it has any request-dependent initializers
// (i.e. constants)
const VM::Class::PropInitVec& declPropInitVec = cls->declPropInit();
const VM::Class::PropInitVec* propVals = !cls->pinitVec().empty()
? cls->getPropData() : &declPropInitVec;
ASSERT(propVals != NULL);
ASSERT(propVals->size() == numDeclProps);
// For visibility checks
CallerFrame cf;
HPHP::VM::Class* ctx = arGetContextClass(cf());
const ClassInfo* ctxCI =
(ctx == NULL ? NULL : g_vmContext->findClassInfo(CStrRef(ctx->nameRef())));
ClassInfo::PropertyMap propMap;
g_vmContext->findClassInfo(className)->getAllProperties(propMap);
HphpArray* ret = NEW(HphpArray)(numDeclProps + numSProps);
for (size_t i = 0; i < numDeclProps; ++i) {
StringData* name = const_cast<StringData*>(propInfo[i].m_name);
// Empty names are used for invisible/private parent properties; skip them
if (name->size() == 0) continue;
if (propMap[String(name)]->isVisible(ctxCI)) {
const TypedValue* value = &((*propVals)[i]);
ret->nvSet(name, value, false);
}
}
for (size_t i = 0; i < numSProps; ++i) {
bool vis, access;
TypedValue* value = cls->getSProp(ctx, sPropInfo[i].m_name, vis, access);
if (vis) {
ret->nvSet(const_cast<StringData*>(sPropInfo[i].m_name), value, false);
}
}
return ret;
}
示例12: write
void VariableSerializer::write(CStrRef v) {
if (m_type == APCSerialize && !v.isNull() && v->isStatic()) {
union {
char buf[8];
StringData *sd;
} u;
u.sd = v.get();
m_buf->append("S:");
m_buf->append(u.buf, 8);
m_buf->append(';');
} else {
v.serialize(this);
}
}
示例13: eval_invoke_file_hook
bool eval_invoke_file_hook(Variant &res, CStrRef path, bool once,
LVariableTable* variables, const char *currentDir) {
bool initial;
HPHP::Eval::PhpFile* efile =
g_vmContext->lookupPhpFile(path.get(), currentDir, &initial);
HPHP::VM::Unit* u = nullptr;
if (efile) u = efile->unit();
if (u == nullptr) {
return false;
}
if (!once || initial) {
g_vmContext->invokeUnit((TypedValue*)(&res), u);
}
return true;
}
示例14: f_define
bool f_define(CStrRef name, CVarRef value,
bool case_insensitive /* = false */) {
if (case_insensitive) {
raise_warning(Strings::CONSTANTS_CASE_SENSITIVE);
}
if (hhvm) {
// TODO: Once we're inlining constants from hphpc this should
// fatal or fail in some other way.
return g_vmContext->setCns(name.get(), value, true);
} else {
// define() should be turned into constant definition by HPHP
assert(false);
return false;
}
}
示例15: f_get_class_constants
Array f_get_class_constants(CStrRef class_name) {
if (hhvm) {
return vm_get_class_constants(class_name.get());
}
const ClassInfo *cls = ClassInfo::FindClass(class_name);
Array ret = Array::Create();
if (cls) {
const ClassInfo::ConstantVec &constants = cls->getConstantsVec();
for (ClassInfo::ConstantVec::const_iterator iter = constants.begin();
iter != constants.end(); ++iter) {
ret.set((*iter)->name, (*iter)->getValue());
}
}
return ret;
}