本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例7:
MismatchedConfigException::MismatchedConfigException(StringData message, StringData path)
: std::runtime_error(util::format(message.data(), path)) { }
示例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();
}
示例9: compare
static bool compare(StringData v1, StringData v2, bool = false, bool = false)
{
bool ret = utf8_compare(v1.data(), v2.data());
return ret;
}
示例10:
MismatchedRealmException::MismatchedRealmException(StringData message)
: std::logic_error(message.data()) { }
示例11: appendStr
void appendStr(const StringData &str , bool includeEndingNull = true ) {
const int len = str.size() + ( includeEndingNull ? 1 : 0 );
memcpy(grow(len), str.data(), len);
}
示例12: ScopedLock
Lock::DBRead::DBRead( const StringData& ns )
: ScopedLock( 'r' ), _what(ns.data()), _nested(false) {
lockDB( _what );
}
示例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);
}
示例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);
}
示例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);
}
}