本文整理汇总了C++中ustring::Rep::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Rep::size方法的具体用法?C++ Rep::size怎么用?C++ Rep::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring::Rep
的用法示例。
在下文中一共展示了Rep::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toJS
size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string)
{
UString::Rep* rep = toJS(string);
// Any UTF8 character > 3 bytes encodes as a UTF16 surrogate pair.
return rep->size() * 3 + 1; // + 1 for terminating '\0'
}
示例2: find
AtomicStringImpl* AtomicString::find(const KJS::Identifier& identifier)
{
if (identifier.isNull())
return 0;
UString::Rep* string = identifier.ustring().rep();
unsigned length = string->size();
if (!length)
return static_cast<AtomicStringImpl*>(StringImpl::empty());
HashAndCharacters buffer = { string->computedHash(), string->data(), length };
HashSet<StringImpl*>::iterator iterator = stringTable->find<HashAndCharacters, HashAndCharactersTranslator>(buffer);
if (iterator == stringTable->end())
return 0;
return static_cast<AtomicStringImpl*>(*iterator);
}
示例3: empty
PassRefPtr<StringImpl> AtomicString::add(const KJS::UString& ustring)
{
if (ustring.isNull())
return 0;
UString::Rep* string = ustring.rep();
unsigned length = string->size();
if (!length)
return StringImpl::empty();
HashAndCharacters buffer = { string->hash(), string->data(), length };
pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable->add<HashAndCharacters, HashAndCharactersTranslator>(buffer);
if (!addResult.second)
return *addResult.first;
return adoptRef(*addResult.first);
}
示例4: JSStringGetLength
EXPORT
size_t JSStringGetLength(JSStringRef string)
{
UString::Rep* rep = toJS(string);
return rep->size();
}
示例5: JSStringCopyCFString
CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string)
{
UString::Rep* rep = toJS(string);
return CFStringCreateWithCharacters(alloc, reinterpret_cast<const UniChar*>(rep->data()), rep->size());
}
示例6: resolveRope
// Overview: this methods converts a JSString from holding a string in rope form
// down to a simple UString representation. It does so by building up the string
// backwards, since we want to avoid recursion, we expect that the tree structure
// representing the rope is likely imbalanced with more nodes down the left side
// (since appending to the string is likely more common) - and as such resolving
// in this fashion should minimize work queue size. (If we built the queue forwards
// we would likely have to place all of the constituent UString::Reps into the
// Vector before performing any concatenation, but by working backwards we likely
// only fill the queue with the number of substrings at any given level in a
// rope-of-ropes.)
void JSString::resolveRope(ExecState* exec) const
{
ASSERT(isRope());
// Allocate the buffer to hold the final string, position initially points to the end.
UChar* buffer;
if (PassRefPtr<UStringImpl> newImpl = UStringImpl::tryCreateUninitialized(m_stringLength, buffer))
m_value = newImpl;
else {
for (unsigned i = 0; i < m_ropeLength; ++i) {
m_fibers[i].deref();
m_fibers[i] = static_cast<void*>(0);
}
m_ropeLength = 0;
ASSERT(!isRope());
ASSERT(m_value == UString());
throwOutOfMemoryError(exec);
return;
}
UChar* position = buffer + m_stringLength;
// Start with the current Rope.
Vector<Rope::Fiber, 32> workQueue;
Rope::Fiber currentFiber;
for (unsigned i = 0; i < (m_ropeLength - 1); ++i)
workQueue.append(m_fibers[i]);
currentFiber = m_fibers[m_ropeLength - 1];
while (true) {
if (currentFiber.isRope()) {
Rope* rope = currentFiber.rope();
// Copy the contents of the current rope into the workQueue, with the last item in 'currentFiber'
// (we will be working backwards over the rope).
unsigned ropeLengthMinusOne = rope->ropeLength() - 1;
for (unsigned i = 0; i < ropeLengthMinusOne; ++i)
workQueue.append(rope->fibers(i));
currentFiber = rope->fibers(ropeLengthMinusOne);
} else {
UString::Rep* string = currentFiber.string();
unsigned length = string->size();
position -= length;
UStringImpl::copyChars(position, string->data(), length);
// Was this the last item in the work queue?
if (workQueue.isEmpty()) {
// Create a string from the UChar buffer, clear the rope RefPtr.
ASSERT(buffer == position);
for (unsigned i = 0; i < m_ropeLength; ++i) {
m_fibers[i].deref();
m_fibers[i] = static_cast<void*>(0);
}
m_ropeLength = 0;
ASSERT(!isRope());
return;
}
// No! - set the next item up to process.
currentFiber = workQueue.last();
workQueue.removeLast();
}
}
}