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


C++ StringData::data方法代码示例

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


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

示例1: get

HOT_FUNC_HPHP
CVarRef ZendArray::get(CVarRef k, bool error /* = false */) const {
  Bucket *p;
  TypedValueAccessor tva = k.getTypedAccessor();
  if (isIntKey(tva)) {
    p = find(getIntKey(tva));
  } else {
    ASSERT(k.isString());
    StringData *strkey = getStringKey(tva);
    int64 prehash = strkey->hash();
    p = find(strkey->data(), strkey->size(), prehash);
  }
  if (p) {
    return p->data;
  }
  if (error) {
    raise_notice("Undefined index: %s", k.toString().data());
  }
  return null_variant;
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:20,代码来源:zend_array.cpp

示例2: tvCanBeCoercedToNumber

bool tvCanBeCoercedToNumber(TypedValue* tv) {
  switch (tv->m_type) {
  case KindOfStaticString:
  case KindOfString:
    StringData* s;
    DataType type;
    s = tv->m_data.pstr;
    type = is_numeric_string(s->data(), s->size(), nullptr, nullptr);
    if (type != KindOfDouble && type != KindOfInt64) {
      return false;
    }
    break;
  case KindOfArray:
  case KindOfObject:
    return false;
  default:
    break;
  }
  return true;
}
开发者ID:floreal,项目名称:hiphop-php,代码行数:20,代码来源:tv_helpers.cpp

示例3: string_to_hex

static string string_to_hex(const string& message, StringData& str, const char* in_begin, const char* in_end,
                            jchar* out_curr, jchar* out_end, size_t retcode, size_t error_code)
{
    ostringstream ret;

    const char* s = str.data();
    ret << message << " ";
    ret << "error_code = " << error_code << "; ";
    ret << "retcode = " << retcode << "; ";
    ret << "StringData.size = " << str.size() << "; ";
    ret << "StringData.data = " << str << "; ";
    ret << "StringData as hex = ";
    for (string::size_type i = 0; i < str.size(); ++i)
        ret << " 0x" << std::hex << std::setfill('0') << std::setw(2) << (int)s[i];
    ret << "; ";
    ret << "in_begin = " << in_begin << "; ";
    ret << "in_end = " << in_end << "; ";
    ret << "out_curr = " << out_curr << "; ";
    ret << "out_end = " << out_end << ";";
    return ret.str();
}
开发者ID:anggrayudi,项目名称:realm-java,代码行数:21,代码来源:util.cpp

示例4: copyImpl

ArrayData *ZendArray::lvalPtr(CStrRef k, Variant *&ret, bool copy,
                              bool create) {
  StringData *key = k.get();
  int64 prehash = key->hash();
  ZendArray *a = 0, *t = this;
  if (UNLIKELY(copy)) {
    a = t = copyImpl();
  }

  if (create) {
    t->addLvalImpl(key, prehash, &ret);
  } else {
    Bucket *p = t->find(key->data(), key->size(), prehash);
    if (p) {
      ret = &p->data;
    } else {
      ret = NULL;
    }
  }
  return a;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:21,代码来源:zend_array.cpp

示例5: tvAsVariant

static inline void
tvPairToCString(DataType t, uint64_t v,
                const char** outStr,
                size_t* outSz,
                bool* outMustFree) {
  if (IS_STRING_TYPE(t)) {
    StringData *strd = (StringData*)v;
    *outStr = strd->data();
    *outSz = strd->size();
    *outMustFree = false;
    return;
  }
  Cell c;
  c.m_type = t;
  c.m_data.num = v;
  String s = tvAsVariant(&c).toString();
  *outStr = (const char*)malloc(s.size());
  TRACE(1, "t-x64: stringified: %s -> %s\n", s.data(), *outStr);
  memcpy((char*)*outStr, s.data(), s.size());
  *outSz = s.size();
  *outMustFree = true;
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:22,代码来源:runtime.cpp

示例6: addLvalImpl

ArrayData *ZendArray::lval(CStrRef k, Variant *&ret, bool copy,
                           bool checkExist /* = false */) {
  StringData *key = k.get();
  int64 prehash = key->hash();
  if (!copy) {
    addLvalImpl(key, prehash, &ret);
    return NULL;
  }
  if (!checkExist) {
    ZendArray *a = copyImpl();
    a->addLvalImpl(key, prehash, &ret);
    return a;
  }
  Bucket *p = find(key->data(), key->size(), prehash);
  if (p &&
      (p->data.isReferenced() || p->data.isObject())) {
    ret = &p->data;
    return NULL;
  }
  ZendArray *a = copyImpl();
  a->addLvalImpl(key, prehash, &ret, p);
  return a;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:23,代码来源:zend_array.cpp

示例7:

MismatchedConfigException::MismatchedConfigException(StringData message, StringData path)
: std::runtime_error(util::format(message.data(), path)) { }
开发者ID:acondense,项目名称:realm-js,代码行数:2,代码来源:shared_realm.cpp

示例8: table_name_for_object_type

std::string ObjectStore::table_name_for_object_type(StringData object_type) {
    return std::string(c_object_table_prefix) + object_type.data();
}
开发者ID:0atme0,项目名称:tutu1,代码行数:3,代码来源:object_store.cpp

示例9: compare

 static bool compare(StringData v1, StringData v2, bool = false, bool = false)
 {
     bool ret = utf8_compare(v1.data(), v2.data());
     return ret;
 }
开发者ID:HackSteinsGate,项目名称:Dai-Hentai,代码行数:5,代码来源:query_conditions.hpp

示例10:

MismatchedRealmException::MismatchedRealmException(StringData message)
: std::logic_error(message.data()) { }
开发者ID:chrisortman,项目名称:EntrefestDemo,代码行数:2,代码来源:shared_realm.cpp

示例11: appendStr

 void appendStr(const StringData &str , bool includeEndingNull = true ) {
     const int len = str.size() + ( includeEndingNull ? 1 : 0 );
     memcpy(grow(len), str.data(), len);
 }
开发者ID:maciekgajewski,项目名称:falcondb,代码行数:4,代码来源:buf_builder.hpp

示例12: ScopedLock

 Lock::DBRead::DBRead( const StringData& ns )   
     : ScopedLock( 'r' ), _what(ns.data()), _nested(false) {
     lockDB( _what );
 }
开发者ID:dampier,项目名称:mongo,代码行数:4,代码来源:d_concurrency.cpp

示例13: insert_string

inline void ArrayBigBlobs::insert_string(std::size_t ndx, StringData value)
{
    BinaryData bin(value.data(), value.size());
    bool add_zero_term = true;
    insert(ndx, bin, add_zero_term);
}
开发者ID:410900345,项目名称:DemoBackgroundLocationUpdate,代码行数:6,代码来源:array_blobs_big.hpp

示例14: add_string

inline void ArrayBigBlobs::add_string(StringData value)
{
    BinaryData bin(value.data(), value.size());
    bool add_zero_term = true;
    add(bin, add_zero_term);
}
开发者ID:410900345,项目名称:DemoBackgroundLocationUpdate,代码行数:6,代码来源:array_blobs_big.hpp

示例15: to_jstring

jstring to_jstring(JNIEnv* env, StringData str)
{
    if (str.is_null()) {
        return NULL;
    }

    // For efficiency, if the incoming UTF-8 string is sufficiently
    // small, we will attempt to store the UTF-16 output into a stack
    // allocated buffer of static size. Otherwise we will have to
    // dynamically allocate the output buffer after calculating its
    // size.

    const size_t stack_buf_size = 48;
    jchar stack_buf[stack_buf_size];
    std::unique_ptr<jchar[]> dyn_buf;

    const char* in_begin = str.data();
    const char* in_end = str.data() + str.size();
    jchar* out_begin = stack_buf;
    jchar* out_curr = stack_buf;
    jchar* out_end = stack_buf + stack_buf_size;

    typedef Utf8x16<jchar, JcharTraits> Xcode;

    if (str.size() <= stack_buf_size) {
        size_t retcode = Xcode::to_utf16(in_begin, in_end, out_curr, out_end);
        if (retcode != 0) {
            throw std::runtime_error(string_to_hex("Failure when converting short string to UTF-16", str, in_begin, in_end,
                                              out_curr, out_end, size_t(0), retcode));
        }
        if (in_begin == in_end) {
            goto transcode_complete;
        }
    }

    {
        const char* in_begin2 = in_begin;
        size_t error_code;
        size_t size = Xcode::find_utf16_buf_size(in_begin2, in_end, error_code);
        if (in_begin2 != in_end) {
            throw std::runtime_error(string_to_hex("Failure when computing UTF-16 size", str, in_begin, in_end, out_curr,
                                              out_end, size, error_code));
        }
        if (int_add_with_overflow_detect(size, stack_buf_size)) {
            throw std::runtime_error("String size overflow");
        }
        dyn_buf.reset(new jchar[size]);
        out_curr = copy(out_begin, out_curr, dyn_buf.get());
        out_begin = dyn_buf.get();
        out_end = dyn_buf.get() + size;
        size_t retcode = Xcode::to_utf16(in_begin, in_end, out_curr, out_end);
        if (retcode != 0) {
            throw std::runtime_error(string_to_hex("Failure when converting long string to UTF-16", str, in_begin, in_end,
                                              out_curr, out_end, size_t(0), retcode));
        }
        REALM_ASSERT(in_begin == in_end);
    }

transcode_complete : {
    jsize out_size;
    if (int_cast_with_overflow_detect(out_curr - out_begin, out_size)) {
        throw std::runtime_error("String size overflow");
    }

    return env->NewString(out_begin, out_size);
}
}
开发者ID:anggrayudi,项目名称:realm-java,代码行数:67,代码来源:util.cpp


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