本文整理汇总了C++中ustring::Rep类的典型用法代码示例。如果您正苦于以下问题:C++ Rep类的具体用法?C++ Rep怎么用?C++ Rep使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rep类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spliceSubstringsWithSeparators
UString UString::spliceSubstringsWithSeparators(const Range *substringRanges, int rangeCount, const UString *separators, int separatorCount) const
{
int totalLength = 0;
for (int i = 0; i < rangeCount; i++) {
totalLength += substringRanges[i].length;
}
for (int i = 0; i < separatorCount; i++) {
totalLength += separators[i].size();
}
UChar *buffer = static_cast<UChar *>(malloc(totalLength * sizeof(UChar)));
int maxCount = MAX(rangeCount, separatorCount);
int bufferPos = 0;
for (int i = 0; i < maxCount; i++) {
if (i < rangeCount) {
memcpy(buffer + bufferPos, data() + substringRanges[i].position, substringRanges[i].length * sizeof(UChar));
bufferPos += substringRanges[i].length;
}
if (i < separatorCount) {
memcpy(buffer + bufferPos, separators[i].data(), separators[i].size() * sizeof(UChar));
bufferPos += separators[i].size();
}
}
UString::Rep *rep = UString::Rep::create(buffer, totalLength);
UString result = UString(rep);
rep->deref();
return result;
}
开发者ID:BackupTheBerlios,项目名称:wxwebcore-svn,代码行数:32,代码来源:ustring.cpp
示例2: clear
void PropertyMap::clear()
{
if (!_table) {
#if USE_SINGLE_ENTRY
UString::Rep *key = _singleEntry.key;
if (key) {
key->deref();
_singleEntry.key = 0;
}
#endif
return;
}
int size = _table->size;
Entry *entries = _table->entries;
for (int i = 0; i < size; i++) {
UString::Rep *key = entries[i].key;
if (isValid(key)) {
key->deref();
entries[i].key = 0;
entries[i].value = 0;
}
}
_table->keyCount = 0;
_table->sentinelCount = 0;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:26,代码来源:property_map.cpp
示例3: checkConsistency
void PropertyMap::checkConsistency()
{
if (!_table)
return;
int count = 0;
int sentinelCount = 0;
for (int j = 0; j != _table->size; ++j) {
UString::Rep *rep = _table->entries[j].key;
if (!rep)
continue;
if (rep == deletedSentinel()) {
++sentinelCount;
continue;
}
unsigned h = rep->hash();
int i = h & _table->sizeMask;
int k = 0;
while (UString::Rep *key = _table->entries[i].key) {
if (rep == key)
break;
if (k == 0)
k = 1 | (h % _table->sizeMask);
i = (i + k) & _table->sizeMask;
}
assert(i == j);
++count;
}
assert(count == _table->keyCount);
assert(sentinelCount == _table->sentinelCount);
assert(_table->size >= 16);
assert(_table->sizeMask);
assert(_table->size == _table->sizeMask + 1);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:34,代码来源:property_map.cpp
示例4: 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'
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:7,代码来源:JSStringRef.cpp
示例5: JSStringRelease
EXPORT
void JSStringRelease(JSStringRef string)
{
JSLock lock;
UString::Rep* rep = toJS(string);
rep->deref();
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:7,代码来源:JSStringRef.cpp
示例6: translate
static void translate(UString::Rep*& location, const UCharBuffer& buf, unsigned hash)
{
UChar* d;
UString::Rep* r = UString::Rep::createUninitialized(buf.length, d).releaseRef();
for (unsigned i = 0; i != buf.length; i++)
d[i] = buf.s[i];
r->setHash(hash);
location = r;
}
开发者ID:chrisguan,项目名称:Olympia_on_Desktop,代码行数:9,代码来源:Identifier.cpp
示例7: despecifyFunction
bool Structure::despecifyFunction(const Identifier& propertyName)
{
ASSERT(!propertyName.isNull());
materializePropertyMapIfNecessary();
if (!m_propertyTable)
return false;
UString::Rep* rep = propertyName._ustring.rep();
unsigned i = rep->existingHash();
#if DUMP_PROPERTYMAP_STATS
++numProbes;
#endif
unsigned entryIndex = m_propertyTable->entryIndices[i & m_propertyTable->sizeMask];
if (entryIndex == emptyEntryIndex)
return false;
if (rep == m_propertyTable->entries()[entryIndex - 1].key) {
ASSERT(m_propertyTable->entries()[entryIndex - 1].specificValue);
m_propertyTable->entries()[entryIndex - 1].specificValue = 0;
return true;
}
#if DUMP_PROPERTYMAP_STATS
++numCollisions;
#endif
unsigned k = 1 | doubleHash(rep->existingHash());
while (1) {
i += k;
#if DUMP_PROPERTYMAP_STATS
++numRehashes;
#endif
entryIndex = m_propertyTable->entryIndices[i & m_propertyTable->sizeMask];
if (entryIndex == emptyEntryIndex)
return false;
if (rep == m_propertyTable->entries()[entryIndex - 1].key) {
ASSERT(m_propertyTable->entries()[entryIndex - 1].specificValue);
m_propertyTable->entries()[entryIndex - 1].specificValue = 0;
return true;
}
}
}
开发者ID:chrisguan,项目名称:Olympia_on_Desktop,代码行数:50,代码来源:Structure.cpp
示例8: 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);
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:16,代码来源:AtomicString.cpp
示例9: 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);
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:16,代码来源:AtomicString.cpp
示例10: createTable
void HashTable::createTable(JSGlobalData* globalData) const
{
ASSERT(!table);
HashEntry* entries = new HashEntry[hashSizeMask + 1];
for (int i = 0; i <= hashSizeMask; ++i)
entries[i].key = 0;
for (int i = 0; values[i].key; ++i) {
UString::Rep* identifier = Identifier::add(globalData, values[i].key).releaseRef();
int hashIndex = identifier->computedHash() & hashSizeMask;
ASSERT(!entries[hashIndex].key);
entries[hashIndex].key = identifier;
entries[hashIndex].integerValue = values[i].value;
entries[hashIndex].attributes = values[i].attributes;
entries[hashIndex].length = values[i].length;
}
table = entries;
}
开发者ID:acss,项目名称:owb-mirror,代码行数:17,代码来源:lookup.cpp
示例11: substr
UString UString::substr(int pos, int len) const
{
if (pos < 0)
pos = 0;
else if (pos >= (int) size())
pos = size();
if (len < 0)
len = size();
if (pos + len >= (int) size())
len = size() - pos;
UString::Rep *newRep = Rep::create(rep, pos, len);
UString result(newRep);
newRep->deref();
return result;
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:17,代码来源:ustring.cpp
示例12: assert
JSValue *PropertyMap::get(const Identifier &name, unsigned &attributes) const
{
assert(!name.isNull());
UString::Rep *rep = name._ustring.rep();
if (!_table) {
#if USE_SINGLE_ENTRY
UString::Rep *key = _singleEntry.key;
if (rep == key) {
attributes = _singleEntry.attributes;
return _singleEntry.value;
}
#endif
return 0;
}
unsigned h = rep->hash();
int sizeMask = _table->sizeMask;
Entry *entries = _table->entries;
int i = h & sizeMask;
int k = 0;
#if DUMP_STATISTICS
++numProbes;
numCollisions += entries[i].key && entries[i].key != rep;
#endif
while (UString::Rep *key = entries[i].key) {
if (rep == key) {
attributes = entries[i].attributes;
return entries[i].value;
}
if (k == 0)
k = 1 | (h % sizeMask);
i = (i + k) & sizeMask;
#if DUMP_STATISTICS
++numRehashes;
#endif
}
return 0;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:40,代码来源:property_map.cpp
示例13: substr
UString UString::substr(int pos, int len) const
{
int s = size();
if (pos < 0)
pos = 0;
else if (pos >= s)
pos = s;
if (len < 0)
len = s;
if (pos + len >= s)
len = s - pos;
if (pos == 0 && len == s)
return *this;
UString::Rep *newRep = Rep::create(rep, pos, len);
UString result(newRep);
newRep->deref();
return result;
}
开发者ID:BackupTheBerlios,项目名称:wxwebcore-svn,代码行数:22,代码来源:ustring.cpp
示例14: createTable
void HashTable::createTable(JSGlobalData* globalData) const
{
#if ENABLE(PERFECT_HASH_SIZE)
ASSERT(!table);
HashEntry* entries = new HashEntry[hashSizeMask + 1];
for (int i = 0; i <= hashSizeMask; ++i)
entries[i].setKey(0);
for (int i = 0; values[i].key; ++i) {
UString::Rep* identifier = Identifier::add(globalData, values[i].key).releaseRef();
int hashIndex = identifier->computedHash() & hashSizeMask;
ASSERT(!entries[hashIndex].key());
entries[hashIndex].initialize(identifier, values[i].attributes, values[i].value1, values[i].value2);
}
table = entries;
#else
ASSERT(!table);
int linkIndex = compactHashSizeMask + 1;
HashEntry* entries = new HashEntry[compactSize];
for (int i = 0; i < compactSize; ++i)
entries[i].setKey(0);
for (int i = 0; values[i].key; ++i) {
UString::Rep* identifier = Identifier::add(globalData, values[i].key).releaseRef();
int hashIndex = identifier->computedHash() & compactHashSizeMask;
HashEntry* entry = &entries[hashIndex];
if (entry->key()) {
while (entry->next()) {
entry = entry->next();
}
ASSERT(linkIndex < compactSize);
entry->setNext(&entries[linkIndex++]);
entry = entry->next();
}
entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2);
}
table = entries;
#endif
}
开发者ID:Fale,项目名称:qtmoko,代码行数:39,代码来源:Lookup.cpp
示例15: fastFree
PropertyMap::~PropertyMap()
{
if (!_table) {
#if USE_SINGLE_ENTRY
UString::Rep *key = _singleEntry.key;
if (key)
key->deref();
#endif
return;
}
int minimumKeysToProcess = _table->keyCount + _table->sentinelCount;
Entry *entries = _table->entries;
for (int i = 0; i < minimumKeysToProcess; i++) {
UString::Rep *key = entries[i].key;
if (key) {
if (key != deletedSentinel())
key->deref();
} else
++minimumKeysToProcess;
}
fastFree(_table);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:23,代码来源:property_map.cpp
示例16: 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();
}
}
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:72,代码来源:JSString.cpp
示例17: JSStringCopyCFString
CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string)
{
UString::Rep* rep = toJS(string);
return CFStringCreateWithCharacters(alloc, reinterpret_cast<const UniChar*>(rep->data()), rep->size());
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:5,代码来源:JSStringRefCF.cpp
示例18: JSStringRetain
JSStringRef JSStringRetain(JSStringRef string)
{
JSLock lock;
UString::Rep* rep = toJS(string);
return toRef(rep->ref());
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:6,代码来源:JSStringRef.cpp
示例19: JSStringGetLength
EXPORT
size_t JSStringGetLength(JSStringRef string)
{
UString::Rep* rep = toJS(string);
return rep->size();
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:6,代码来源:JSStringRef.cpp
示例20: JSStringGetCharactersPtr
EXPORT
const JSChar* JSStringGetCharactersPtr(JSStringRef string)
{
UString::Rep* rep = toJS(string);
return reinterpret_cast<const JSChar*>(rep->data());
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:6,代码来源:JSStringRef.cpp
注:本文中的ustring::Rep类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论