本文整理汇总了C++中BString::ByteAt方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::ByteAt方法的具体用法?C++ BString::ByteAt怎么用?C++ BString::ByteAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::ByteAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
BUrl::_ExtractRequestAndFragment(const BString& urlString, int16* origin)
{
// Extract request field from URL
if (urlString.ByteAt(*origin) == '?') {
(*origin)++;
int16 requestEnd = urlString.FindFirst('#', *origin);
fHasRequest = true;
if (requestEnd == -1) {
urlString.CopyInto(fRequest, *origin, urlString.Length() - *origin);
return;
} else {
urlString.CopyInto(fRequest, *origin, requestEnd - *origin);
*origin = requestEnd;
}
}
// Extract fragment field if needed
if (urlString.ByteAt(*origin) == '#') {
(*origin)++;
urlString.CopyInto(fFragment, *origin, urlString.Length() - *origin);
fHasFragment = true;
}
}
示例2: if
PlatformKeyboardEvent::PlatformKeyboardEvent(BMessage* message)
: m_autoRepeat(false)
, m_isKeypad(false)
, m_shiftKey(false)
, m_ctrlKey(false)
, m_altKey(false)
, m_metaKey(false)
{
BString bytes = message->FindString("bytes");
m_nativeVirtualKeyCode = message->FindInt32("key");
m_text = String::fromUTF8(bytes.String(), bytes.Length());
m_unmodifiedText = String(bytes.String(), bytes.Length());
m_keyIdentifier = keyIdentifierForHaikuKeyCode(bytes.ByteAt(0), m_nativeVirtualKeyCode);
m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(bytes.ByteAt(0), m_nativeVirtualKeyCode);
if (message->what == B_KEY_UP)
m_type = KeyUp;
else if (message->what == B_KEY_DOWN)
m_type = KeyDown;
int32 modifiers = message->FindInt32("modifiers");
m_shiftKey = modifiers & B_SHIFT_KEY;
m_ctrlKey = modifiers & B_COMMAND_KEY;
m_altKey = modifiers & B_CONTROL_KEY;
m_metaKey = modifiers & B_OPTION_KEY;
}
示例3: operator
bool operator()(const BString& first, const BString& second)
{
// sort anything starting with '<' behind anything else
if (first.ByteAt(0) == '<') {
if (second.ByteAt(0) != '<')
return false;
} else if (second.ByteAt(0) == '<')
return true;
return fCollator.Compare(first.String(), second.String()) < 0;
}
示例4:
_EXPORT status_t
extract_from_header(const BString& header, const BString& field,
BString& target)
{
int32 headerLength = header.Length();
int32 fieldEndPos = 0;
while (true) {
int32 pos = header.IFindFirst(field, fieldEndPos);
if (pos < 0)
return B_BAD_VALUE;
fieldEndPos = pos + field.Length();
if (pos != 0 && header.ByteAt(pos - 1) != '\n')
continue;
if (header.ByteAt(fieldEndPos) == ':')
break;
}
fieldEndPos++;
int32 crPos = fieldEndPos;
while (true) {
fieldEndPos = crPos;
crPos = header.FindFirst('\n', crPos);
if (crPos < 0)
crPos = headerLength;
BString temp;
header.CopyInto(temp, fieldEndPos, crPos - fieldEndPos);
if (header.ByteAt(crPos - 1) == '\r') {
temp.Truncate(temp.Length() - 1);
temp += " ";
}
target += temp;
crPos++;
if (crPos >= headerLength)
break;
char nextByte = header.ByteAt(crPos);
if (nextByte != ' ' && nextByte != '\t')
break;
crPos++;
}
size_t bufferSize = target.Length();
char* buffer = target.LockBuffer(bufferSize);
size_t length = rfc2047_to_utf8(&buffer, &bufferSize, bufferSize);
target.UnlockBuffer(length);
return B_OK;
}
示例5:
int32_t
PTextViewDisallowChars(void *pobject, void *in, void *out, void *extraData)
{
if (!pobject || !in || !out)
return B_ERROR;
PView *parent = static_cast<PView*>(pobject);
if (!parent)
return B_BAD_TYPE;
BTextView *backend = (BTextView*)parent->GetView();
PArgs *inArgs = static_cast<PArgs*>(in);
BString string;
if (inArgs->FindString("chars", &string) != B_OK)
return B_ERROR;
if (backend->Window())
backend->Window()->Lock();
for (int32 i = 0; i < string.CountChars(); i++)
{
char c = string.ByteAt(i);
if (c)
backend->DisallowChar(c);
}
if (backend->Window())
backend->Window()->Unlock();
return B_OK;
}
示例6: progEntry
void
ShortcutsSpec::_UpdateIconBitmap()
{
BString firstWord = ParseArgvZeroFromString(fCommand);
// Only need to change if the first word has changed...
if (fLastBitmapName == NULL || firstWord.Length() == 0
|| firstWord.Compare(fLastBitmapName)) {
if (firstWord.ByteAt(0) == '*')
fBitmapValid = IsValidActuatorName(&firstWord.String()[1]);
else {
fBitmapValid = false; // default till we prove otherwise!
if (firstWord.Length() > 0) {
delete [] fLastBitmapName;
fLastBitmapName = new char[firstWord.Length() + 1];
strcpy(fLastBitmapName, firstWord.String());
BEntry progEntry(fLastBitmapName, true);
if ((progEntry.InitCheck() == B_NO_ERROR)
&& (progEntry.Exists())) {
BNode progNode(&progEntry);
if (progNode.InitCheck() == B_NO_ERROR) {
BNodeInfo progNodeInfo(&progNode);
if ((progNodeInfo.InitCheck() == B_NO_ERROR)
&& (progNodeInfo.GetTrackerIcon(&fBitmap, B_MINI_ICON)
== B_NO_ERROR)) {
fBitmapValid = fBitmap.IsValid();
}
}
}
}
}
}
}
示例7:
void
HaikuMailFormatFilter::_RemoveLeadingDots(BString& name)
{
int dots = 0;
while (dots < name.Length() && name.ByteAt(dots) == '.')
dots++;
if (dots > 0)
name.Remove(0, dots);
}
示例8: SendCommand
status_t
POP3Protocol::_RetrieveUniqueIDs()
{
fUniqueIDs.MakeEmpty();
fSizes.clear();
fTotalSize = 0;
status_t status = SendCommand("UIDL" CRLF);
if (status != B_OK)
return status;
BString result;
int32 uidOffset;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
uidOffset = result.FindFirst(' ') + 1;
result.Remove(0, uidOffset);
fUniqueIDs.Add(result);
}
if (SendCommand("LIST" CRLF) != B_OK)
return B_ERROR;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
int32 index = result.FindLast(" ");
int32 size;
if (index >= 0)
size = atol(&result.String()[index]);
else
size = 0;
fTotalSize += size;
fSizes.push_back(size);
}
return B_OK;
}
示例9: GetHash
unsigned char DataFile::GetHash(BString text)
////////////////////////////////////////////////////////////////////////
{
unsigned char result = 0;
text.ToUpper();
for (int i=0; i<text.Length(); i++)
result ^= text.ByteAt(i);
return result;
}
示例10: Trim
void DataFile::Trim(BString &result)
////////////////////////////////////////////////////////////////////////
{
if (result.Length() == 0)
return;
// Elejen a space-ek...
while (result.ByteAt(0) == ' ')
{
result.Remove(0, 1);
}
if (result.Length() == 0)
return;
// Vegen a space-ek...
while (result.ByteAt(result.Length()-1) == ' ')
{
result.Remove(result.Length()-1, 1);
}
}
示例11: SendCommand
status_t
POP3Protocol::UniqueIDs()
{
status_t ret = B_OK;
runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting UniqueIDs...",
"固有のIDを取得中..."));
ret = SendCommand("UIDL" CRLF);
if (ret != B_OK)
return ret;
BString result;
int32 uid_offset;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
uid_offset = result.FindFirst(' ') + 1;
result.Remove(0,uid_offset);
unique_ids->AddItem(result.String());
}
if (SendCommand("LIST" CRLF) != B_OK)
return B_ERROR;
int32 b;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
b = result.FindLast(" ");
if (b >= 0)
b = atol(&(result.String()[b]));
else
b = 0;
fSizes.AddItem((void *)(b));
}
return ret;
}
示例12: SendCommand
status_t
POP3Protocol::_UniqueIDs()
{
fUniqueIDs.MakeEmpty();
status_t ret = B_OK;
ret = SendCommand("UIDL" CRLF);
if (ret != B_OK)
return ret;
BString result;
int32 uid_offset;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
uid_offset = result.FindFirst(' ') + 1;
result.Remove(0,uid_offset);
fUniqueIDs.AddItem(result.String());
}
if (SendCommand("LIST" CRLF) != B_OK)
return B_ERROR;
int32 b;
while (ReceiveLine(result) > 0) {
if (result.ByteAt(0) == '.')
break;
b = result.FindLast(" ");
if (b >= 0)
b = atol(&(result.String()[b]));
else
b = 0;
fSizes.AddItem((void *)(b));
}
return ret;
}
示例13: handleKeyEvent
void BWebPage::handleKeyEvent(BMessage* message)
{
WebCore::Frame* frame = fPage->focusController()->focusedOrMainFrame();
if (!frame->view() || !frame->document())
return;
PlatformKeyboardEvent event(message);
// Try to let WebCore handle this event
if (!frame->eventHandler()->keyEvent(event) && message->what == B_KEY_DOWN) {
// Handle keyboard scrolling (probably should be extracted to a method.)
ScrollDirection direction;
ScrollGranularity granularity;
BString bytes = message->FindString("bytes");
switch (bytes.ByteAt(0)) {
case B_UP_ARROW:
granularity = ScrollByLine;
direction = ScrollUp;
break;
case B_DOWN_ARROW:
granularity = ScrollByLine;
direction = ScrollDown;
break;
case B_LEFT_ARROW:
granularity = ScrollByLine;
direction = ScrollLeft;
break;
case B_RIGHT_ARROW:
granularity = ScrollByLine;
direction = ScrollRight;
break;
case B_HOME:
granularity = ScrollByDocument;
direction = ScrollUp;
break;
case B_END:
granularity = ScrollByDocument;
direction = ScrollDown;
break;
case B_PAGE_UP:
granularity = ScrollByPage;
direction = ScrollUp;
break;
case B_PAGE_DOWN:
granularity = ScrollByPage;
direction = ScrollDown;
break;
default:
return;
}
frame->eventHandler()->scrollRecursively(direction, granularity);
}
}
示例14:
static bool
strip_port(BString& host, BString& port)
{
int32 first = host.FindFirst(':');
int32 separator = host.FindLast(':');
if (separator != first
&& (separator == 0 || host.ByteAt(separator - 1) != ']')) {
return false;
}
if (separator != -1) {
// looks like there is a port
host.CopyInto(port, separator + 1, -1);
host.Truncate(separator);
return true;
}
return false;
}
示例15: if
void
HaikuMailFormatFilter::_RemoveExtraWhitespace(BString& name)
{
int spaces = 0;
for (int i = 0; i <= name.Length();) {
if (i < name.Length() && isspace(name.ByteAt(i))) {
spaces++;
i++;
} else if (spaces > 0) {
int remove = spaces - 1;
// Also remove leading and trailing spaces
if (i == remove + 1 || i == name.Length())
remove++;
else
name[i - spaces] = ' ';
name.Remove(i - remove, remove);
i -= remove;
spaces = 0;
} else
i++;
}
}