本文整理汇总了C++中BString::CopyInto方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::CopyInto方法的具体用法?C++ BString::CopyInto怎么用?C++ BString::CopyInto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::CopyInto方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadDataFile
bool DataFile::LoadDataFile(BString filename)
////////////////////////////////////////////////////////////////////////
{
BString line;
int sign; // itt van az '=' jel
int len;
BString key;
BString value;
if (Read(filename))
{
while (GetLine(line))
{
RemoveComment(line);
sign = line.FindFirst('=');
if (sign >= 1)
{
len = line.Length();
line.CopyInto(key, 0, sign);
line.CopyInto(value, sign+1, len-sign-1);
Trim(key);
Trim(value);
AddEntry(key, value);
}
}
}
else
return false;
return true;
}
示例2:
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;
}
}
示例3:
void
BHttpRequest::_ParseStatus()
{
// Status line should be formatted like: HTTP/M.m SSS ...
// With: M = Major version of the protocol
// m = Minor version of the protocol
// SSS = three-digit status code of the response
// ... = additional text info
BString statusLine;
if (_GetLine(statusLine) == B_ERROR)
return;
if (statusLine.CountChars() < 12)
return;
fRequestStatus = kRequestStatusReceived;
BString statusCodeStr;
BString statusText;
statusLine.CopyInto(statusCodeStr, 9, 3);
_SetResultStatusCode(atoi(statusCodeStr.String()));
statusLine.CopyInto(_ResultStatusText(), 13, statusLine.Length() - 13);
_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, "Status line received: Code %d (%s)",
atoi(statusCodeStr.String()), _ResultStatusText().String());
}
示例4: UpdateFileList
void AddTorrentWindow::UpdateFileList()
{
//
//
int fileCount = fTorrent->Info()->fileCount;
tr_file* fileList = fTorrent->Info()->files;
for( int i = 0; i < fileCount; i++ )
{
char FormatBuffer[128] = { 0 };
BRow* row = new BRow(FILE_COLUMN_HEIGHT);
const char* name = fTorrent->IsFolder() ? (strchr(fileList[i].name, '/') + 1) : fileList[i].name;
//
//
//
BString FileExtension = B_EMPTY_STRING;
BString FilePath = fileList[i].name;
FilePath.CopyInto(FileExtension, FilePath.FindLast('.') + 1, FilePath.CountChars());
const char* info = tr_formatter_mem_B(FormatBuffer, fileList[i].length, sizeof(FormatBuffer));;
const BBitmap* icon = GetIconFromExtension(FileExtension);
row->SetField(new FileField(icon, name, info), COLUMN_FILE_NAME);
row->SetField(new CheckBoxField(true), COLUMN_FILE_DOWNLOAD);
////row->SetField(new BIntegerField(PeerStatus[i].progress * 100.0), COLUMN_PEER_PROGRESS);
fFileList->AddRow(row, i);
}
}
示例5: ExtractXMLNode
status_t ExtractXMLNode(const BString &xml, const BString &element, const BString &attr,
const BString &attrValue, BString &value) {
status_t result = B_ERROR;
BString temp = "<";
temp << element;
if ((attr.Length() > 0) && (attrValue.Length() > 0)) {
temp << " " << attr << "=\"" << attrValue << "\"";
};
temp << ">";
int32 open = xml.IFindFirst(temp);
if (open != B_ERROR) {
int start = open + temp.Length();
temp = "";
temp << "</" << element << ">";
int32 end = xml.IFindFirst(temp, start);
if (end != B_ERROR) {
xml.CopyInto(value, start, end - start);
result = B_OK;
};
};
return result;
};
示例6: ExtractXMLChunk
status_t ExtractXMLChunk(const BString &xml, const BString &element, const BString &childElement,
const BString &childElementValue, BString &value) {
status_t result = B_ERROR;
int32 start = B_ERROR;
int32 offset = 0;
BString startElement = "<";
BString endElement = "</";
BString child = "<";
startElement << element << ">";
endElement << element << ">";
child << childElement << ">" << childElementValue << "</" << childElement << ">";
while ((start = xml.IFindFirst(startElement, offset)) != B_ERROR) {
int32 end = xml.IFindFirst(endElement, start);
value = "";
if (end != B_ERROR) {
xml.CopyInto(value, start, end - start);
if (value.IFindFirst(child) != B_ERROR) {
result = B_OK;
return result;
}
};
offset = start + startElement.Length();
};
return result;
};
示例7: commandReference
bool
CommandLineUserInterface::_RegisterCommand(const BString& name,
CliCommand* command)
{
BReference<CliCommand> commandReference(command, true);
if (name.IsEmpty() || command == NULL)
return false;
BString nextName;
int32 startIndex = 0;
int32 spaceIndex;
do {
spaceIndex = name.FindFirst(' ', startIndex);
if (spaceIndex == B_ERROR)
spaceIndex = name.Length();
name.CopyInto(nextName, startIndex, spaceIndex - startIndex);
CommandEntry* entry = new(std::nothrow) CommandEntry(nextName,
command);
if (entry == NULL || !fCommands.AddItem(entry)) {
delete entry;
return false;
}
startIndex = spaceIndex + 1;
} while (startIndex < name.Length());
return true;
}
示例8: urlMatcher
void
BUrl::_ExplodeUrlString(const BString& url)
{
// The regexp is provided in RFC3986 (URI generic syntax), Appendix B
static RegExp urlMatcher(
"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
_ResetFields();
RegExp::MatchResult match = urlMatcher.Match(url.String());
if (!match.HasMatched())
return; // TODO error reporting
// Scheme/Protocol
url.CopyInto(fProtocol, match.GroupStartOffsetAt(1),
match.GroupEndOffsetAt(1) - match.GroupStartOffsetAt(1));
if (!_IsProtocolValid()) {
fHasProtocol = false;
fProtocol.Truncate(0);
} else
fHasProtocol = true;
// Authority (including user credentials, host, and port
url.CopyInto(fAuthority, match.GroupStartOffsetAt(3),
match.GroupEndOffsetAt(3) - match.GroupStartOffsetAt(3));
SetAuthority(fAuthority);
// Path
url.CopyInto(fPath, match.GroupStartOffsetAt(4),
match.GroupEndOffsetAt(4) - match.GroupStartOffsetAt(4));
if (!fPath.IsEmpty())
fHasPath = true;
// Query
url.CopyInto(fRequest, match.GroupStartOffsetAt(6),
match.GroupEndOffsetAt(6) - match.GroupStartOffsetAt(6));
if (!fRequest.IsEmpty())
fHasRequest = true;
// Fragment
url.CopyInto(fFragment, match.GroupStartOffsetAt(8),
match.GroupEndOffsetAt(8) - match.GroupStartOffsetAt(8));
if (!fFragment.IsEmpty())
fHasFragment = true;
}
示例9: SyncMailbox
void BMailRemoteStorageProtocol::SyncMailbox(const char *mailbox) {
BPath path(runner->Chain()->MetaData()->FindString("path"));
path.Append(mailbox);
BDirectory folder(path.Path());
BEntry entry;
BFile snoodle;
BString string;
uint32 chain;
bool append;
while (folder.GetNextEntry(&entry) == B_OK) {
if (!entry.IsFile())
continue;
while (snoodle.SetTo(&entry,B_READ_WRITE) == B_BUSY) snooze(100);
append = false;
while (snoodle.Lock() != B_OK) snooze(100);
snoodle.Unlock();
if (snoodle.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain)) < B_OK)
append = true;
if (chain != runner->Chain()->ID())
append = true;
if (snoodle.ReadAttrString("MAIL:unique_id",&string) < B_OK)
append = true;
BString folder(string), id("");
int32 j = string.FindLast('/');
if ((!append) && (j >= 0)) {
folder.Truncate(j);
string.CopyInto(id,j + 1,string.Length());
if (folder == mailbox)
continue;
} else {
append = true;
}
if (append)
AddMessage(mailbox,&snoodle,&id); //---We should check for partial messages here
else
CopyMessage(folder.String(),mailbox,&id);
string = mailbox;
string << '/' << id;
/*snoodle.RemoveAttr("MAIL:unique_id");
snoodle.RemoveAttr("MAIL:chain");*/
chain = runner->Chain()->ID();
snoodle.WriteAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain));
snoodle.WriteAttrString("MAIL:unique_id",&string);
(*manifest) += string.String();
(*unique_ids) += string.String();
string = runner->Chain()->Name();
snoodle.WriteAttrString("MAIL:account",&string);
}
}
示例10:
void
truncate_string(BString &name, int32 length)
{
if (name.Length() <= length)
return;
if (length < 6)
length = 6;
int32 beginLength = length / 3 - 1;
int32 endLength = length - 3 - beginLength;
BString begin, end;
name.CopyInto(begin, 0, beginLength);
name.CopyInto(end, name.Length() - endLength, endLength);
name = begin;
name.Append("...").Append(end);
}
示例11: rgetcomment
// --------------------------------------------------------------------------------------------- rgetcomment -
BString rgetcomment(BString str)
{
BString tmp;
if (str.FindFirst('#')>=0)
{
str.CopyInto(tmp,0,str.FindFirst('#'));
} else tmp=str;
return tmp;
}
示例12:
void
Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols ,int16 font ,int16 cols2 ,int16 font2)
{
//******************************************
// "Iteration is human, recursion is divine"
//******************************************
int32 newindex = 0;
BString cur;
int i=tokenstart;
while(config->FindString("face",i,&cur)==B_OK)
//for(int i=tokenstart;i<config->numfaces;i++)
{
i++;
//if(config->FindString("face",i,&cur)!=B_OK) return;
newindex=0;
while(true)
{
newindex=text.IFindFirst(cur.String(),0);
//printf("Try %d %s -- match %d\n",i,cur->original.String(),newindex);
if(newindex!=B_ERROR)
{
//take a walk on the left side ;)
//printf("Found at %ld \n",newindex);
if(newindex-1>=0)
{
BString left;
text.CopyInto(left,0,newindex);
//printf("ready to recourse! [%s]\n",left.String());
_findTokens(fTextView,left,tokenstart+1,cols,font,cols2,font2);
}
text.Remove(0,newindex+cur.Length());
//printf("remaning [%s] printed [%s]\n",text.String(),cur->original.String());
fTextView->Append(cur.String(),cols2,cols2,font2);
if(text.Length()==0) return; //useless stack
}
else
break;
}
}
fTextView->Append(text.String(),cols,cols,font);
}
示例13: GetName
status_t BVolume::GetName(char *name, size_t nameSize) const
{
BString str;
status_t status = GetName(&str);
if (status == B_OK) str.CopyInto(name, nameSize, 0, -1);
return status;
}
示例14:
void
BaseJob::_ParseExportVariable(BStringList& environment, const BString& line)
{
if (!line.StartsWith("export "))
return;
int separator = line.FindFirst("=\"");
if (separator < 0)
return;
BString variable;
line.CopyInto(variable, 7, separator - 7);
BString value;
line.CopyInto(value, separator + 2, line.Length() - separator - 3);
variable << "=" << value;
environment.Add(variable);
}
示例15:
BString
FormatResultString(const BString& resultPath)
{
BString result;
int32 end = resultPath.FindFirst("CodeName") - 2;
int32 start = resultPath.FindLast('/', end) + 1;
if (end - start > 1) {
resultPath.CopyInto(result, start, end - start + 1);
result += "::";
result += &resultPath.String()[resultPath.FindLast('/',
resultPath.Length()) + 1];
} else {
int32 secbegin = resultPath.FindLast('/', resultPath.Length()) + 1;
resultPath.CopyInto(result, secbegin, resultPath.Length() - secbegin);
}
return result;
}