本文整理汇总了C++中Utf8Str::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Utf8Str::append方法的具体用法?C++ Utf8Str::append怎么用?C++ Utf8Str::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8Str
的用法示例。
在下文中一共展示了Utf8Str::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: machineAdd
/**
* Adds a specified machine to the list (map) of handled machines.
* Does not do locking -- needs to be done by caller!
*
* @return IPRT status code.
* @param strUuid UUID of the specified machine.
*/
static int machineAdd(const Bstr &strUuid)
{
HRESULT rc;
/** @todo Add exception handling! */
do
{
ComPtr <IMachine> machine;
CHECK_ERROR_BREAK(g_pVirtualBox, FindMachine(strUuid.raw(), machine.asOutParam()));
Assert(!machine.isNull());
/*
* Get groups for this machine.
*/
com::SafeArray<BSTR> groups;
CHECK_ERROR_BREAK(machine, COMGETTER(Groups)(ComSafeArrayAsOutParam(groups)));
Utf8Str strGroups;
for (size_t i = 0; i < groups.size(); i++)
{
if (i != 0)
strGroups.append(",");
strGroups.append(Utf8Str(groups[i]));
}
/*
* Add machine to map.
*/
VBOXWATCHDOG_MACHINE m;
m.machine = machine;
int rc2 = groupAdd(m.groups, strGroups.c_str(), 0 /* Flags */);
AssertRC(rc2);
mapVMIter it = g_mapVM.find(strUuid);
Assert(it == g_mapVM.end());
g_mapVM.insert(std::make_pair(strUuid, m));
serviceLogVerbose(("Added machine \"%ls\"\n", strUuid.raw()));
/*
* Get the machine's VM group(s).
*/
mapGroupsIterConst itGroup = m.groups.begin();
while (itGroup != m.groups.end())
{
serviceLogVerbose(("Machine \"%ls\" is in VM group \"%s\"\n",
strUuid.raw(), itGroup->first.c_str()));
/* Add machine to group(s). */
mapGroupIter itGroups = g_mapGroup.find(itGroup->first);
if (itGroups == g_mapGroup.end())
{
vecGroupMembers vecMembers;
vecMembers.push_back(strUuid);
g_mapGroup.insert(std::make_pair(itGroup->first, vecMembers));
itGroups = g_mapGroup.find(itGroup->first);
Assert(itGroups != g_mapGroup.end());
}
else
itGroups->second.push_back(strUuid);
serviceLogVerbose(("Group \"%s\" has now %ld machine(s)\n",
itGroup->first.c_str(), itGroups->second.size()));
++itGroup;
}
/*
* Let all modules know. Typically all modules would register
* their per-machine payload here.
*/
for (unsigned j = 0; j < RT_ELEMENTS(g_aModules); j++)
if (g_aModules[j].fEnabled)
{
rc2 = g_aModules[j].pDesc->pfnOnMachineRegistered(strUuid);
if (RT_FAILURE(rc2))
serviceLog("OnMachineRegistered: Module '%s' reported an error: %Rrc\n",
g_aModules[j].pDesc->pszName, rc);
/* Keep going. */
}
} while (0);
/** @todo Add std exception handling! */
return SUCCEEDED(rc) ? VINF_SUCCESS : VERR_COM_IPRT_ERROR; /* @todo Find a better error! */
}
示例2: handleStartVM
int handleStartVM(HandlerArg *a)
{
HRESULT rc = S_OK;
std::list<const char *> VMs;
Bstr sessionType = "gui";
static const RTGETOPTDEF s_aStartVMOptions[] =
{
{ "--type", 't', RTGETOPT_REQ_STRING },
{ "-type", 't', RTGETOPT_REQ_STRING }, // deprecated
};
int c;
RTGETOPTUNION ValueUnion;
RTGETOPTSTATE GetState;
// start at 0 because main() has hacked both the argc and argv given to us
RTGetOptInit(&GetState, a->argc, a->argv, s_aStartVMOptions, RT_ELEMENTS(s_aStartVMOptions),
0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
while ((c = RTGetOpt(&GetState, &ValueUnion)))
{
switch (c)
{
case 't': // --type
if (!RTStrICmp(ValueUnion.psz, "gui"))
{
sessionType = "gui";
}
#ifdef VBOX_WITH_VBOXSDL
else if (!RTStrICmp(ValueUnion.psz, "sdl"))
{
sessionType = "sdl";
}
#endif
#ifdef VBOX_WITH_HEADLESS
else if (!RTStrICmp(ValueUnion.psz, "capture"))
{
sessionType = "capture";
}
else if (!RTStrICmp(ValueUnion.psz, "headless"))
{
sessionType = "headless";
}
#endif
else
sessionType = ValueUnion.psz;
break;
case VINF_GETOPT_NOT_OPTION:
VMs.push_back(ValueUnion.psz);
break;
default:
if (c > 0)
{
if (RT_C_IS_PRINT(c))
return errorSyntax(USAGE_STARTVM, "Invalid option -%c", c);
else
return errorSyntax(USAGE_STARTVM, "Invalid option case %i", c);
}
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
return errorSyntax(USAGE_STARTVM, "unknown option: %s\n", ValueUnion.psz);
else if (ValueUnion.pDef)
return errorSyntax(USAGE_STARTVM, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
else
return errorSyntax(USAGE_STARTVM, "error: %Rrs", c);
}
}
/* check for required options */
if (VMs.empty())
return errorSyntax(USAGE_STARTVM, "at least one VM name or uuid required");
for (std::list<const char *>::const_iterator it = VMs.begin();
it != VMs.end();
++it)
{
HRESULT rc2 = rc;
const char *pszVM = *it;
ComPtr<IMachine> machine;
CHECK_ERROR(a->virtualBox, FindMachine(Bstr(pszVM).raw(),
machine.asOutParam()));
if (machine)
{
Bstr env;
#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
/* make sure the VM process will start on the same display as VBoxManage */
Utf8Str str;
const char *pszDisplay = RTEnvGet("DISPLAY");
if (pszDisplay)
str = Utf8StrFmt("DISPLAY=%s\n", pszDisplay);
const char *pszXAuth = RTEnvGet("XAUTHORITY");
if (pszXAuth)
str.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth));
env = str;
#endif
ComPtr<IProgress> progress;
CHECK_ERROR(machine, LaunchVMProcess(a->session, sessionType.raw(),
env.raw(), progress.asOutParam()));
if (SUCCEEDED(rc) && !progress.isNull())
{
RTPrintf("Waiting for VM \"%s\" to power on...\n", pszVM);
//.........这里部分代码省略.........