本文整理汇总了C++中fstring类的典型用法代码示例。如果您正苦于以下问题:C++ fstring类的具体用法?C++ fstring怎么用?C++ fstring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fstring类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: seekLowerBound
int seekLowerBound(fstring key, llong* id, valvec<byte>* retKey) override {
assert(key.size() == sizeof(Int));
if (key.size() != sizeof(Int)) {
THROW_STD(invalid_argument,
"key.size must be sizeof(Int)=%d", int(sizeof(Int)));
}
auto owner = static_cast<const SeqNumIndex*>(m_index.get());
Int keyId = unaligned_load<Int>(key.udata());
if (keyId <= owner->m_min) {
m_curr = 0;
return -1;
}
else if (keyId > owner->m_min + owner->m_cnt) {
m_curr = owner->m_cnt;
*id = owner->m_cnt - 1;
Int forwardMax = owner->m_min + owner->m_cnt - 1;
retKey->assign((const byte*)&forwardMax, sizeof(Int));
return 1;
}
else {
keyId -= owner->m_min;
m_curr = keyId;
*id = keyId;
retKey->assign(key.udata(), key.size());
return 0;
}
}
开发者ID:Strongc,项目名称:nark-db,代码行数:27,代码来源:seq_num_index.cpp
示例2: make_pair
std::pair<size_t, bool>
ZipIntKeyIndex::IntVecLowerBound(fstring binkey) const {
assert(binkey.size() == sizeof(Int));
Int rawkey = unaligned_load<Int>(binkey.data());
if (rawkey < Int(m_minKey)) {
return std::make_pair(0, false);
}
auto indexData = m_index.data();
auto indexBits = m_index.uintbits();
auto indexMask = m_index.uintmask();
auto keysData = m_keys.data();
auto keysBits = m_keys.uintbits();
auto keysMask = m_keys.uintmask();
size_t key = size_t(rawkey - Int(m_minKey));
size_t hitPos = 0;
size_t hitKey = 0;
size_t i = 0, j = m_index.size();
while (i < j) {
size_t mid = (i + j) / 2;
hitPos = UintVecMin0::fast_get(indexData, indexBits, indexMask, mid);
hitKey = UintVecMin0::fast_get(keysData, keysBits, keysMask, hitPos);
if (hitKey < key)
i = mid + 1;
else
j = mid;
}
if (i < m_index.size()) {
hitPos = UintVecMin0::fast_get(indexData, indexBits, indexMask, i);
hitKey = UintVecMin0::fast_get(keysData, keysBits, keysMask, hitPos);
return std::make_pair(i, key == hitKey);
}
return std::make_pair(i, false);
}
开发者ID:rockeet,项目名称:nark-db,代码行数:33,代码来源:intkey_index.cpp
示例3: min
fstring FUFileManager::ExtractNetworkHostname(fstring& filename)
{
fstring hostname;
#ifdef WIN32
// UNC network paths are only supported on WIN32, right now.
if (filename.size() > 2 && (filename[0] == '/' || filename[0] == '\\') && filename[1] == filename[0])
{
size_t nextSlash = min(filename.find('/', 2), filename.find('\\', 2));
FUAssert(nextSlash != fstring::npos, return hostname); // The UNC patch should always have at least one network path
hostname = filename.substr(2, nextSlash - 2);
filename.erase(0, nextSlash); // Keep the slash to indicate absolute path.
}
开发者ID:tweakoz,项目名称:orkid,代码行数:12,代码来源:FUFileManager.cpp
示例4: operator
void operator()(int len, int idx, fstring value) {
if (strnlen(value.p, value.n) < value.size()) {
printf("%-20.*s idx=%08d bin=", len, text, idx);
for (int i = 0; i < value.n; ++i)
printf("%02X", (byte_t)value.p[i]);
printf("\n");
}
else {
printf("%-20.*s idx=%08d val=%.*s\n"
, len, text, idx, value.ilen(), value.data());
}
klen = len;
}
开发者ID:career-tankles,项目名称:scrawl,代码行数:13,代码来源:match_key_l.cpp
示例5: indexInsert
bool indexInsert(size_t indexId, fstring key, llong recId) override {
assert(started == m_status);
assert(indexId < m_indices.size());
WT_ITEM item;
WT_SESSION* ses = m_session.ses;
const Schema& schema = m_sconf.getIndexSchema(indexId);
WT_CURSOR* cur = m_indices[indexId].insert;
WtWritableIndex::setKeyVal(schema, cur, key, recId, &item, &m_wrtBuf);
int err = cur->insert(cur);
m_sizeDiff += sizeof(llong) + key.size();
if (schema.m_isUnique) {
if (WT_DUPLICATE_KEY == err) {
return false;
}
if (err) {
THROW_STD(invalid_argument
, "ERROR: wiredtiger insert unique index: %s", ses->strerror(ses, err));
}
}
else {
if (WT_DUPLICATE_KEY == err) {
assert(0); // assert in debug
return true; // ignore in release
}
if (err) {
THROW_STD(invalid_argument
, "ERROR: wiredtiger insert multi index: %s", ses->strerror(ses, err));
}
}
return true;
}
开发者ID:CovariantStudio,项目名称:terark-db,代码行数:31,代码来源:wt_db_segment.cpp
示例6: append
llong MockWritableSegment::append(fstring row, DbContext*) {
llong id = m_rows.size();
m_rows.push_back();
m_rows.back().assign(row);
m_dataSize += row.size();
return id;
}
开发者ID:Strongc,项目名称:nark-db,代码行数:7,代码来源:mock_db_engine.cpp
示例7: sizeof
bool SeqNumIndex<Int>::insert(fstring key, llong id, DbContext*) {
assert(key.size() == sizeof(Int));
assert(id >= 0);
if (key.size() != sizeof(Int)) {
THROW_STD(invalid_argument,
"key.size must be sizeof(Int)=%d", int(sizeof(Int)));
}
Int keyId = unaligned_load<Int>(key.udata());
if (keyId != m_min + id) {
THROW_STD(invalid_argument,
"key must be consistent with id in SeqNumIndex");
}
if (llong(m_cnt) < id + 1) {
m_cnt = id + 1;
}
return 1;
}
开发者ID:Strongc,项目名称:nark-db,代码行数:17,代码来源:seq_num_index.cpp
示例8: append
llong MockWritableStore::append(fstring row, DbContext*) {
SpinRwLock lock(m_rwMutex, true);
llong id = m_rows.size();
m_rows.push_back();
m_rows.back().assign(row);
m_dataSize += row.size();
return id;
}
开发者ID:GreatStone,项目名称:terark-db,代码行数:8,代码来源:mock_db_engine.cpp
示例9: replace
void MockWritableSegment::replace(llong id, fstring row, DbContext*) {
assert(id >= 0);
assert(id < llong(m_rows.size()));
size_t oldsize = m_rows[id].size();
m_rows[id].assign(row);
m_dataSize -= oldsize;
m_dataSize += row.size();
}
开发者ID:Strongc,项目名称:nark-db,代码行数:8,代码来源:mock_db_engine.cpp
示例10: scheme
FUUri::FUUri(const fstring uri, bool escape)
: scheme(FUUri::NONE),
port(0),
path(FC(""))
{
if (uri.empty()) return;
fstring _uri;
if (escape)
{
_uri = Escape(uri);
}
else
{
_uri = uri;
}
// Replace all '\\' characters by '/' so the path is only using them
//_uri.replace(FC('\\'), FC('/'));
_uri = FixFuxedUpColladaPaths( _uri );
// Find the scheme from its ':' delimiter
size_t schemeDelimiterIndex = _uri.find(FC(':'));
size_t hostIndex = 0;
if (schemeDelimiterIndex != fstring::npos && schemeDelimiterIndex > 1)
{
fstring _scheme = _uri.substr(0, schemeDelimiterIndex);
if (IsEquivalent(_scheme, FC("FILE")) || IsEquivalent(_scheme, FC("file")))
{
scheme = FUUri::FILE;
}
else if (IsEquivalent(_scheme, FC("FTP")) || IsEquivalent(_scheme, FC("ftp")))
{
scheme = FUUri::FTP;
}
else if (IsEquivalent(_scheme, FC("HTTP")) || IsEquivalent(_scheme, FC("http")))
{
scheme = FUUri::HTTP;
}
else if (IsEquivalent(_scheme, FC("HTTPS")) || IsEquivalent(_scheme, FC("https")))
{
scheme = FUUri::HTTPS;
}
else
{
#ifdef WIN32
// Scheme not supported (could be a NFS path)
FUFail(return);
#endif // WIN32
}
schemeDelimiter = _uri.substr(schemeDelimiterIndex, 3);
hostIndex = schemeDelimiterIndex + 3;
}
开发者ID:tweakoz,项目名称:orkid,代码行数:58,代码来源:FUUri.cpp
示例11: split_by_any
size_t split_by_any(fstring delims, Vec* F, size_t max_fields = ~size_t(0)) {
size_t dlen = delims.size();
if (0 == dlen) // empty delims redirect to blank delim
return split(' ', F);
if (1 == dlen)
return split(delims[0], F);
F->resize(0);
char *col = p, *end = p + n;
while (col <= end && F->size()+1 < max_fields) {
char* next = col;
while (next < end && memchr(delims.data(), *next, dlen) == NULL) ++next;
F->push_back(typename Vec::value_type(col, next));
*next = 0;
col = next + 1;
}
if (col <= end)
F->push_back(typename Vec::value_type(col, end));
return F->size();
}
开发者ID:CovariantStudio,项目名称:terark-db,代码行数:19,代码来源:linebuf.hpp
示例12: split
size_t split(fstring delims, Vec* F, size_t max_fields = ~size_t(0)) {
size_t dlen = delims.size();
if (0 == dlen) // empty delims redirect to blank delim
return split(' ', F);
if (1 == dlen)
return split(delims[0], F);
F->resize(0);
char *col = p, *end = p + n;
while (col <= end && F->size()+1 < max_fields) {
char* next = (char*)memmem(col, end-col, delims.data(), dlen);
if (NULL == next) next = end;
F->push_back(typename Vec::value_type(col, next));
*next = 0;
col = next + dlen;
}
if (col <= end)
F->push_back(typename Vec::value_type(col, end));
return F->size();
}
开发者ID:CovariantStudio,项目名称:terark-db,代码行数:19,代码来源:linebuf.hpp
示例13: fstrncpy
// Strip a full filename of its filename, returning the path
fstring FUFileManager::StripFileFromPath(const fstring& filename)
{
fchar fullPath[MAX_PATH + 1];
fstrncpy(fullPath, filename.c_str(), MAX_PATH);
fullPath[MAX_PATH] = 0;
fchar* lastSlash = fstrrchr(fullPath, FC('/'));
fchar* lastBackslash = fstrrchr(fullPath, FC('\\'));
lastSlash = max(lastSlash, lastBackslash);
if (lastSlash != NULL) *(lastSlash + 1) = 0;
return fstring(fullPath);
}
开发者ID:tweakoz,项目名称:orkid,代码行数:12,代码来源:FUFileManager.cpp
示例14: update
void MockWritableStore::update(llong id, fstring row, DbContext* ctx) {
assert(id >= 0);
assert(id <= llong(m_rows.size()));
if (llong(m_rows.size()) == id) {
append(row, ctx);
return;
}
SpinRwLock lock(m_rwMutex, true);
size_t oldsize = m_rows[id].size();
m_rows[id].assign(row);
m_dataSize -= oldsize;
m_dataSize += row.size();
}
开发者ID:GreatStone,项目名称:terark-db,代码行数:13,代码来源:mock_db_engine.cpp
示例15: seekLowerBound
int seekLowerBound(fstring key, llong* id, valvec<byte>* retKey) override {
std::pair<size_t, bool> ib;
if (key.empty())
ib = std::make_pair(0, false);
else
ib = m_owner->searchLowerBound(key);
m_keyIdx = ib.first;
if (ib.first < m_owner->m_index.size()) {
*id = m_owner->m_index.get(ib.first);
if (retKey) {
retKey->erase_all();
m_owner->getValueAppend(*id, retKey, nullptr);
}
m_keyIdx++;
return ib.second ? 0 : 1;
}
return -1;
}
开发者ID:rockeet,项目名称:nark-db,代码行数:18,代码来源:intkey_index.cpp
示例16: assert
//static
int MockReadonlyIndex::forwardLowerBound(fstring key, size_t* pLower) const {
const uint32_t* index = m_ids.data();
const size_t rows = m_ids.size();
const size_t fixlen = m_fixedLen;
if (fixlen) {
assert(m_keys.size() == 0);
assert(key.size() == fixlen);
FixedLenKeyCompare cmp;
cmp.fixedLen = fixlen;
cmp.strpool = m_keys.strpool.data();
cmp.schema = m_schema;
size_t lo = nark::lower_bound_0(index, rows, key, cmp);
*pLower = lo;
if (lo < rows) {
size_t jj = m_ids[lo];
if (key == fstring(cmp.strpool + fixlen*jj, fixlen))
return 0;
else
return 1;
}
}
else {
VarLenKeyCompare cmp;
cmp.offsets = m_keys.offsets.data();
cmp.strpool = m_keys.strpool.data();
cmp.schema = m_schema;
size_t lo = nark::lower_bound_0(index, rows, key, cmp);
*pLower = lo;
if (lo < rows) {
size_t jj = m_ids[lo];
if (key == m_keys[jj])
return 0;
else
return 1;
}
}
return -1;
}
开发者ID:Strongc,项目名称:nark-db,代码行数:39,代码来源:mock_db_engine.cpp
示例17: assert
//static
int MockReadonlyIndex::forwardLowerBound(fstring key, size_t* pLower) const {
const uint32_t* index = m_ids.data();
const size_t rows = m_ids.size();
const size_t fixlen = m_fixedLen;
const auto cmp = m_schema->compareData_less();
if (fixlen) {
assert(m_keys.size() == 0);
assert(key.size() == fixlen);
FixedLenKeyExtractor keyEx;
keyEx.fixedLen = fixlen;
keyEx.strpool = m_keys.strpool.data();
size_t lo = lower_bound_ex_0(index, rows, key, keyEx, cmp);
*pLower = lo;
if (lo < rows) {
size_t jj = m_ids[lo];
if (key == fstring(keyEx.strpool + fixlen*jj, fixlen))
return 0;
else
return 1;
}
}
else {
VarLenKeyExtractor keyEx;
keyEx.offsets = m_keys.offsets.data();
keyEx.strpool = m_keys.strpool.data();
size_t lo = lower_bound_ex_0(index, rows, key, keyEx, cmp);
*pLower = lo;
if (lo < rows) {
size_t jj = m_ids[lo];
if (key == m_keys[jj])
return 0;
else
return 1;
}
}
return -1;
}
开发者ID:GreatStone,项目名称:terark-db,代码行数:38,代码来源:mock_db_engine.cpp
示例18: while
// Split a fstring into multiple substrings
void FUStringConversion::ToFStringList(const fstring& value, FStringList& array)
{
const fchar* s = value.c_str();
// Skip beginning white spaces
fchar c;
while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; }
size_t index = 0;
while (*s != 0)
{
const fchar* word = s;
// Find next white space
while ((c = *s) != 0 && c != ' ' && c != '\t' && c != '\r' && c != '\n') { ++s; }
if (index < array.size()) array[index++].append(word, s - word);
else { array.push_back(fstring(word, s - word)); ++index; }
// Skip all white spaces
while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; }
}
array.resize(index);
}
开发者ID:righnatios,项目名称:0ad,代码行数:25,代码来源:FUStringConversion.cpp
示例19: operator
bool operator()(fstring name, obj** x) const {
if (path.end() == name.end() && NULL == *x) {
*x = new typename obj_val<Obj>::type(val);
}
return true;
}
开发者ID:GreatStone,项目名称:terark-db,代码行数:6,代码来源:ptree.cpp
示例20: BadChecksumException
BadChecksumException::
BadChecksumException(fstring msg, uint64_t Old, uint64_t New)
: super(msg.c_str()), m_old(Old), m_new(New) {}
开发者ID:GreatStone,项目名称:terark-db,代码行数:3,代码来源:checksum_exception.cpp
注:本文中的fstring类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论