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


C++ CStrRef::get方法代码示例

本文整理汇总了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;
}
开发者ID:Barbayar,项目名称:hiphop-php,代码行数:56,代码来源:concurrent-shared-store.cpp

示例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;
}
开发者ID:IMGM,项目名称:hiphop-php,代码行数:10,代码来源:user_stream_wrapper.cpp

示例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);
  }
}
开发者ID:sclin,项目名称:hiphop-php,代码行数:55,代码来源:ext_misc.cpp

示例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);
}
开发者ID:ckwalsh,项目名称:hiphop-php,代码行数:11,代码来源:thread_shared_variant.cpp

示例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);
  }
}
开发者ID:524777134,项目名称:hiphop-php,代码行数:53,代码来源:taint_warning.cpp

示例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());
  }
}
开发者ID:jobin-sun,项目名称:hiphop-php,代码行数:21,代码来源:ext_misc.cpp

示例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;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:12,代码来源:zend_array.cpp

示例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();
}
开发者ID:TingoZhou,项目名称:hiphop-php,代码行数:40,代码来源:ext_misc.cpp

示例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;
}
开发者ID:Parent5446,项目名称:hiphop-php,代码行数:26,代码来源:ext_reflection.cpp

示例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;
}
开发者ID:Parent5446,项目名称:hiphop-php,代码行数:13,代码来源:ext_reflection.cpp

示例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;
}
开发者ID:Sydney-o9,项目名称:hiphop-php,代码行数:51,代码来源:ext_class.cpp

示例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);
  }
}
开发者ID:TitoAgudelo,项目名称:hiphop-php,代码行数:14,代码来源:variable_serializer.cpp

示例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;
}
开发者ID:sclin,项目名称:hiphop-php,代码行数:15,代码来源:eval.cpp

示例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;
  }
}
开发者ID:Chuwiey,项目名称:hiphop-php,代码行数:15,代码来源:ext_misc.cpp

示例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;
}
开发者ID:CoolCloud,项目名称:hiphop-php,代码行数:15,代码来源:ext_class.cpp


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