本文整理汇总了C++中llvm::StringRef::consume_front方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::consume_front方法的具体用法?C++ StringRef::consume_front怎么用?C++ StringRef::consume_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::consume_front方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemapPath
bool PathMappingList::RemapPath(llvm::StringRef path,
std::string &new_path) const {
if (m_pairs.empty() || path.empty())
return false;
const_iterator pos, end = m_pairs.end();
for (pos = m_pairs.begin(); pos != end; ++pos) {
if (!path.consume_front(pos->first.GetStringRef()))
continue;
new_path = pos->second.GetStringRef();
new_path.append(path);
return true;
}
return false;
}
示例2: Connect
lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path,
Error *error_ptr) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("%p ConnectionGenericFile::Connect (url = '%s')",
static_cast<void *>(this), path.str().c_str());
if (!path.consume_front("file://")) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat("unsupported connection URL: '%s'",
path.str().c_str());
return eConnectionStatusError;
}
if (IsConnected()) {
ConnectionStatus status = Disconnect(error_ptr);
if (status != eConnectionStatusSuccess)
return status;
}
// Open the file for overlapped access. If it does not exist, create it. We
// open it overlapped so that we can issue asynchronous reads and then use
// WaitForMultipleObjects to allow the read to be interrupted by an event
// object.
std::wstring wpath;
if (!llvm::ConvertUTF8toWide(path, wpath)) {
if (error_ptr)
error_ptr->SetError(1, eErrorTypeGeneric);
return eConnectionStatusError;
}
m_file = ::CreateFileW(wpath.c_str(), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_ALWAYS,
FILE_FLAG_OVERLAPPED, NULL);
if (m_file == INVALID_HANDLE_VALUE) {
if (error_ptr)
error_ptr->SetError(::GetLastError(), eErrorTypeWin32);
return eConnectionStatusError;
}
m_owns_file = true;
m_uri.assign(path);
return eConnectionStatusSuccess;
}
示例3: BreakpointID
llvm::Optional<BreakpointID>
BreakpointID::ParseCanonicalReference(llvm::StringRef input) {
break_id_t bp_id;
break_id_t loc_id = LLDB_INVALID_BREAK_ID;
if (input.empty())
return llvm::None;
// If it doesn't start with an integer, it's not valid.
if (input.consumeInteger(0, bp_id))
return llvm::None;
// period is optional, but if it exists, it must be followed by a number.
if (input.consume_front(".")) {
if (input.consumeInteger(0, loc_id))
return llvm::None;
}
// And at the end, the entire string must have been consumed.
if (!input.empty())
return llvm::None;
return BreakpointID(bp_id, loc_id);
}