本文整理汇总了C++中BStringList::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringList::Add方法的具体用法?C++ BStringList::Add怎么用?C++ BStringList::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringList
的用法示例。
在下文中一共展示了BStringList::Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settings
status_t
RepositoriesSettings::GetRepositories(int32& repoCount, BStringList& nameList,
BStringList& urlList)
{
BMessage settings(_ReadFromFile());
type_code type;
int32 count;
settings.GetInfo(key_name, &type, &count);
status_t result = B_OK;
int32 index, total = 0;
BString foundName, foundUrl;
// get each repository and add to lists
for (index = 0; index < count; index++) {
status_t result1 = settings.FindString(key_name, index, &foundName);
status_t result2 = settings.FindString(key_url, index, &foundUrl);
if (result1 == B_OK && result2 == B_OK) {
nameList.Add(foundName);
urlList.Add(foundUrl);
total++;
} else
result = B_ERROR;
}
repoCount = total;
return result;
}
示例2: pathArrayDeleter
/*static*/ status_t
BPathFinder::FindPaths(const char* architecture,
path_base_directory baseDirectory, const char* subPath, uint32 flags,
BStringList& _paths)
{
_paths.MakeEmpty();
// get the paths
char** pathArray;
size_t pathCount;
status_t error = find_paths_etc(architecture, baseDirectory, subPath, flags,
&pathArray, &pathCount);
if (error != B_OK)
return error;
MemoryDeleter pathArrayDeleter(pathArray);
// add them to BStringList
for (size_t i = 0; i < pathCount; i++) {
BString path(pathArray[i]);
if (path.IsEmpty() || !_paths.Add(path)) {
_paths.MakeEmpty();
return B_NO_MEMORY;
}
}
return B_OK;
}
示例3:
void
PackageManager::_PrintResult(InstalledRepository& installationRepository)
{
if (!installationRepository.HasChanges())
return;
printf(" in %s:\n", installationRepository.Name().String());
PackageList& packagesToActivate
= installationRepository.PackagesToActivate();
PackageList& packagesToDeactivate
= installationRepository.PackagesToDeactivate();
BStringList upgradedPackages;
for (int32 i = 0;
BSolverPackage* installPackage = packagesToActivate.ItemAt(i);
i++) {
for (int32 j = 0;
BSolverPackage* uninstallPackage = packagesToDeactivate.ItemAt(j);
j++) {
if (installPackage->Info().Name() == uninstallPackage->Info().Name()) {
upgradedPackages.Add(installPackage->Info().Name());
break;
}
}
}
for (int32 i = 0; BSolverPackage* package = packagesToActivate.ItemAt(i);
i++) {
BString repository;
if (dynamic_cast<MiscLocalRepository*>(package->Repository()) != NULL)
repository = "local file";
else
repository.SetToFormat("repository %s", package->Repository()->Name().String());
if (upgradedPackages.HasString(package->Info().Name())) {
printf(" upgrade package %s to %s from %s\n",
package->Info().Name().String(),
package->Info().Version().ToString().String(),
repository.String());
} else {
printf(" install package %s-%s from %s\n",
package->Info().Name().String(),
package->Info().Version().ToString().String(),
repository.String());
}
}
for (int32 i = 0; BSolverPackage* package = packagesToDeactivate.ItemAt(i);
i++) {
if (upgradedPackages.HasString(package->Info().Name()))
continue;
printf(" uninstall package %s\n", package->VersionedName().String());
}
// TODO: Print file/download sizes. Unfortunately our package infos don't
// contain the file size. Which is probably correct. The file size (and possibly
// other information) should, however, be provided by the repository cache in
// some way. Extend BPackageInfo? Create a BPackageFileInfo?
}
示例4:
void
LaunchDaemon::_AddRunTargets(BMessage& message, const char* name)
{
BMessage targets;
if (name != NULL && message.FindMessage(name, &targets) != B_OK)
return;
const char* target;
for (int32 index = 0; targets.FindString("target", index, &target) == B_OK;
index++) {
fRunTargets.Add(target);
}
}
示例5:
void
POP3Protocol::CheckForDeletedMessages()
{
{
// Delete things from the manifest no longer on the server
BStringList list;
NotHere(fUniqueIDs, fManifest, &list);
fManifest.Remove(list);
}
if (!fSettings.FindBool("delete_remote_when_local")
|| fManifest.CountStrings() == 0)
return;
BStringList toDelete;
BStringList queryContents;
BVolumeRoster volumes;
BVolume volume;
while (volumes.GetNextVolume(&volume) == B_OK) {
BQuery fido;
entry_ref entry;
fido.SetVolume(&volume);
fido.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
fido.PushInt32(fAccountSettings.AccountID());
fido.PushOp(B_EQ);
fido.Fetch();
BString uid;
while (fido.GetNextRef(&entry) == B_OK) {
BNode(&entry).ReadAttrString("MAIL:unique_id", &uid);
queryContents.Add(uid);
}
}
NotHere(queryContents, fManifest, &toDelete);
for (int32 i = 0; i < toDelete.CountStrings(); i++) {
printf("delete mail on server uid %s\n", toDelete.StringAt(i).String());
Delete(fUniqueIDs.IndexOf(toDelete.StringAt(i)));
}
// Don't remove ids from fUniqueIDs, the indices have to stay the same when
// retrieving new messages.
fManifest.Remove(toDelete);
// TODO: at some point the purged manifest should be written to disk
// otherwise it will grow forever
}
示例6: operator
status_t operator()(const BEntry& entry)
{
char name[B_FILE_NAME_LENGTH];
status_t result = entry.GetName(name);
if (result != B_OK)
return result;
int32 count = names.CountStrings();
for (int i = 0; i < count; ++i) {
if (names.StringAt(i).Compare(name) == 0)
return B_OK;
}
names.Add(name);
return B_OK;
}
示例7:
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);
}
示例8: messenger
thread_id
TeamDebugHandler::_EnterDebugger(bool saveReport)
{
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): team %" B_PRId32
"\n", fTeam));
// prepare a debugger handover
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): preparing "
"debugger handover for team %" B_PRId32 "...\n", fTeam));
status_t error = send_debug_message(&fDebugContext,
B_DEBUG_MESSAGE_PREPARE_HANDOVER, NULL, 0, NULL, 0);
if (error != B_OK) {
debug_printf("debug_server: Failed to prepare debugger handover: %s\n",
strerror(error));
return error;
}
BStringList arguments;
const char *argv[16];
int argc = 0;
bool debugInConsoled = _IsGUIServer() || !_AreGUIServersAlive();
#ifdef HANDOVER_USE_GDB
error = _SetupGDBArguments(arguments, debugInConsoled);
if (error != B_OK) {
debug_printf("debug_server: Failed to set up gdb arguments: %s\n",
strerror(error));
return error;
}
// start the terminal
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
"terminal (debugger) for team %" B_PRId32 "...\n", fTeam));
#elif defined(HANDOVER_USE_DEBUGGER)
if (!debugInConsoled && !saveReport
&& be_roster->IsRunning(kDebuggerSignature)) {
// for graphical handovers, check if Debugger is already running,
// and if it is, simply send it a message to attach to the requested
// team.
BMessenger messenger(kDebuggerSignature);
BMessage message(MSG_DEBUG_THIS_TEAM);
if (message.AddInt32("team", fTeam) == B_OK
&& messenger.SendMessage(&message) == B_OK) {
return 0;
}
}
// prepare the argument vector
BPath debuggerPath;
if (debugInConsoled) {
error = find_directory(B_SYSTEM_BIN_DIRECTORY, &debuggerPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-bin directory: %s\n",
strerror(error));
return error;
}
error = debuggerPath.Append("consoled");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-bin path: %s\n",
strerror(error));
return error;
}
if (!arguments.Add(debuggerPath.Path()))
return B_NO_MEMORY;
}
error = find_directory(B_SYSTEM_APPS_DIRECTORY, &debuggerPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-apps directory: %s\n",
strerror(error));
return error;
}
error = debuggerPath.Append("Debugger");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-apps path: %s\n",
strerror(error));
return error;
}
if (!arguments.Add(debuggerPath.Path()))
return B_NO_MEMORY;
if (debugInConsoled && !arguments.Add("--cli"))
return B_NO_MEMORY;
BString debuggerParam;
debuggerParam.SetToFormat("%" B_PRId32, fTeam);
if (saveReport) {
if (!arguments.Add("--save-report"))
return B_NO_MEMORY;
}
if (!arguments.Add("--team") || !arguments.Add(debuggerParam))
return B_NO_MEMORY;
// start the debugger
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
//.........这里部分代码省略.........
示例9: strerror
status_t
TeamDebugHandler::_SetupGDBArguments(BStringList &arguments, bool usingConsoled)
{
// prepare the argument vector
BString teamString;
teamString.SetToFormat("--pid=%" B_PRId32, fTeam);
status_t error;
BPath terminalPath;
if (usingConsoled) {
error = find_directory(B_SYSTEM_BIN_DIRECTORY, &terminalPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-bin directory: %s\n",
strerror(error));
return error;
}
error = terminalPath.Append("consoled");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-bin path: %s\n",
strerror(error));
return error;
}
} else {
error = find_directory(B_SYSTEM_APPS_DIRECTORY, &terminalPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-apps directory: %s\n",
strerror(error));
return error;
}
error = terminalPath.Append("Terminal");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-apps path: %s\n",
strerror(error));
return error;
}
}
arguments.MakeEmpty();
if (!arguments.Add(terminalPath.Path()))
return B_NO_MEMORY;
if (!usingConsoled) {
BString windowTitle;
windowTitle.SetToFormat("Debug of Team %" B_PRId32 ": %s", fTeam,
_LastPathComponent(fExecutablePath));
if (!arguments.Add("-t") || !arguments.Add(windowTitle))
return B_NO_MEMORY;
}
BPath gdbPath;
error = find_directory(B_SYSTEM_BIN_DIRECTORY, &gdbPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-bin directory: %s\n",
strerror(error));
return error;
}
error = gdbPath.Append("gdb");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-bin path: %s\n",
strerror(error));
return error;
}
if (!arguments.Add(gdbPath.Path()) || !arguments.Add(teamString))
return B_NO_MEMORY;
if (strlen(fExecutablePath) > 0 && !arguments.Add(fExecutablePath))
return B_NO_MEMORY;
return B_OK;
}
示例10: manager
//.........这里部分代码省略.........
const BPackageInfo& repoPackageInfo = package->Info();
PackageInfoRef modelInfo;
PackageInfoMap::iterator it = foundPackages.find(
repoPackageInfo.Name());
if (it != foundPackages.end())
modelInfo.SetTo(it->second);
else {
// Add new package info
BString publisherURL;
if (repoPackageInfo.URLList().CountStrings() > 0)
publisherURL = repoPackageInfo.URLList().StringAt(0);
BString publisherName = repoPackageInfo.Vendor();
const BStringList& rightsList = repoPackageInfo.CopyrightList();
if (rightsList.CountStrings() > 0)
publisherName = rightsList.StringAt(0);
modelInfo.SetTo(new(std::nothrow) PackageInfo(
repoPackageInfo.Name(),
repoPackageInfo.Version().ToString(),
PublisherInfo(BitmapRef(), publisherName,
"", publisherURL), repoPackageInfo.Summary(),
repoPackageInfo.Description(),
repoPackageInfo.Flags()),
true);
if (modelInfo.Get() == NULL)
return;
foundPackages[repoPackageInfo.Name()] = modelInfo;
}
modelInfo->SetIcon(defaultIcon);
modelInfo->AddListener(this);
BSolverRepository* repository = package->Repository();
if (dynamic_cast<BPackageManager::RemoteRepository*>(repository)
!= NULL) {
depots[repository->Name()].AddPackage(modelInfo);
remotePackages[modelInfo->Title()] = modelInfo;
} else {
if (repository == static_cast<const BSolverRepository*>(
manager.SystemRepository())) {
modelInfo->AddInstallationLocation(
B_PACKAGE_INSTALLATION_LOCATION_SYSTEM);
if (!modelInfo->IsSystemPackage()) {
systemInstalledPackages[repoPackageInfo.FileName()]
= modelInfo;
}
} else if (repository == static_cast<const BSolverRepository*>(
manager.HomeRepository())) {
modelInfo->AddInstallationLocation(
B_PACKAGE_INSTALLATION_LOCATION_HOME);
}
}
if (modelInfo->IsSystemPackage())
systemFlaggedPackages.Add(repoPackageInfo.FileName());
}
BAutolock lock(fModel.Lock());
fModel.Clear();
// filter remote packages from the found list
// any packages remaining will be locally installed packages
示例11: defined
thread_id
TeamDebugHandler::_EnterDebugger(bool saveReport)
{
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): team %" B_PRId32
"\n", fTeam));
// prepare a debugger handover
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): preparing "
"debugger handover for team %" B_PRId32 "...\n", fTeam));
status_t error = send_debug_message(&fDebugContext,
B_DEBUG_MESSAGE_PREPARE_HANDOVER, NULL, 0, NULL, 0);
if (error != B_OK) {
debug_printf("debug_server: Failed to prepare debugger handover: %s\n",
strerror(error));
return error;
}
BStringList arguments;
const char *argv[16];
int argc = 0;
bool debugInConsoled = _IsGUIServer() || !_AreGUIServersAlive();
#ifdef HANDOVER_USE_GDB
error = _SetupGDBArguments(arguments, debugInConsoled);
if (error != B_OK) {
debug_printf("debug_server: Failed to set up gdb arguments: %s\n",
strerror(error));
return error;
}
// start the terminal
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
"terminal (debugger) for team %" B_PRId32 "...\n", fTeam));
#elif defined(HANDOVER_USE_DEBUGGER)
if (debugInConsoled) {
error = _SetupGDBArguments(arguments, debugInConsoled);
if (error != B_OK) {
debug_printf("debug_server: Failed to set up gdb arguments: %s\n",
strerror(error));
return error;
}
} else {
// prepare the argument vector
BPath debuggerPath;
error = find_directory(B_SYSTEM_APPS_DIRECTORY, &debuggerPath);
if (error != B_OK) {
debug_printf("debug_server: can't find system-apps directory: %s\n",
strerror(error));
return error;
}
error = debuggerPath.Append("Debugger");
if (error != B_OK) {
debug_printf("debug_server: can't append to system-apps path: %s\n",
strerror(error));
return error;
}
if (!arguments.Add(debuggerPath.Path()))
return B_NO_MEMORY;
BString debuggerParam;
debuggerParam.SetToFormat("%" B_PRId32, fTeam);
if (saveReport) {
if (!arguments.Add("--save-report"))
return B_NO_MEMORY;
}
if (!arguments.Add("--team") || !arguments.Add(debuggerParam))
return B_NO_MEMORY;
// start the debugger
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
"graphical debugger for team %" B_PRId32 "...\n", fTeam));
}
#endif
for (int32 i = 0; i < arguments.CountStrings(); i++)
argv[argc++] = arguments.StringAt(i).String();
argv[argc] = NULL;
thread_id thread = load_image(argc, argv, (const char**)environ);
if (thread < 0) {
debug_printf("debug_server: Failed to start debugger: %s\n",
strerror(thread));
return thread;
}
resume_thread(thread);
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): debugger started "
"for team %" B_PRId32 ": thread: %" B_PRId32 "\n", fTeam, thread));
return thread;
}