本文整理汇总了C++中Utf8Str函数的典型用法代码示例。如果您正苦于以下问题:C++ Utf8Str函数的具体用法?C++ Utf8Str怎么用?C++ Utf8Str使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Utf8Str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: autoCaller
STDMETHODIMP Guest::SetCredentials(IN_BSTR aUserName, IN_BSTR aPassword,
IN_BSTR aDomain, BOOL aAllowInteractiveLogon)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/* forward the information to the VMM device */
VMMDev *pVMMDev = mParent->getVMMDev();
if (pVMMDev)
{
PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
if (pVMMDevPort)
{
uint32_t u32Flags = VMMDEV_SETCREDENTIALS_GUESTLOGON;
if (!aAllowInteractiveLogon)
u32Flags = VMMDEV_SETCREDENTIALS_NOLOCALLOGON;
pVMMDevPort->pfnSetCredentials(pVMMDevPort,
Utf8Str(aUserName).c_str(),
Utf8Str(aPassword).c_str(),
Utf8Str(aDomain).c_str(),
u32Flags);
return S_OK;
}
}
return setError(VBOX_E_VM_ERROR,
tr("VMM device is not available (is the VM running?)"));
}
示例2: RTStrPrintf
HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
const com::Utf8Str &aTrunkName,
const com::Utf8Str &aTrunkType)
{
/* Silently ignore attempts to run disabled servers. */
if (!m->enabled)
return S_OK;
/* Commmon Network Settings */
m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNetwork, aNetworkName.c_str());
if (!aTrunkName.isEmpty())
m->dhcp.setOption(NetworkServiceRunner::kNsrTrunkName, aTrunkName.c_str());
m->dhcp.setOption(NetworkServiceRunner::kNsrKeyTrunkType, aTrunkType.c_str());
/* XXX: should this MAC default initialization moved to NetworkServiceRunner? */
char strMAC[32];
Guid guid;
guid.create();
RTStrPrintf (strMAC, sizeof(strMAC), "08:00:27:%02X:%02X:%02X",
guid.raw()->au8[0],
guid.raw()->au8[1],
guid.raw()->au8[2]);
m->dhcp.setOption(NetworkServiceRunner::kNsrMacAddress, strMAC);
m->dhcp.setOption(NetworkServiceRunner::kNsrIpAddress, Utf8Str(m->IPAddress).c_str());
m->dhcp.setOption(NetworkServiceRunner::kNsrIpNetmask, Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text).c_str());
m->dhcp.setOption(DHCPServerRunner::kDsrKeyLowerIp, Utf8Str(m->lowerIP).c_str());
m->dhcp.setOption(DHCPServerRunner::kDsrKeyUpperIp, Utf8Str(m->upperIP).c_str());
/* XXX: This parameters Dhcp Server will fetch via API */
return RT_FAILURE(m->dhcp.start(!m->router /* KillProcOnExit */)) ? E_FAIL : S_OK;
//m->dhcp.detachFromServer(); /* need to do this to avoid server shutdown on runner destruction */
}
示例3: autoCaller
HRESULT HostNetworkInterface::i_setVirtualBox(VirtualBox *pVirtualBox)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AssertReturn(mVirtualBox != pVirtualBox, S_OK);
unconst(mVirtualBox) = pVirtualBox;
#if !defined(RT_OS_WINDOWS)
/* If IPv4 address hasn't been initialized */
if (m.IPAddress == 0 && mIfType == HostNetworkInterfaceType_HostOnly)
{
Bstr tmpAddr, tmpMask;
HRESULT hrc = mVirtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress",
mInterfaceName.c_str()).raw(),
tmpAddr.asOutParam());
if (FAILED(hrc) || tmpAddr.isEmpty())
tmpAddr = getDefaultIPv4Address(mInterfaceName);
hrc = mVirtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask",
mInterfaceName.c_str()).raw(),
tmpMask.asOutParam());
if (FAILED(hrc) || tmpMask.isEmpty())
tmpMask = Bstr(VBOXNET_IPV4MASK_DEFAULT);
m.IPAddress = inet_addr(Utf8Str(tmpAddr).c_str());
m.networkMask = inet_addr(Utf8Str(tmpMask).c_str());
}
if (m.IPV6Address.isEmpty())
{
Bstr bstrIPV4Addr;
Bstr tmpPrefixLen;
HRESULT hrc = mVirtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address",
mInterfaceName.c_str()).raw(),
bstrIPV4Addr.asOutParam());
if (SUCCEEDED(hrc))
{
m.IPV6Address = bstrIPV4Addr;
if (!m.IPV6Address.isEmpty())
{
hrc = mVirtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6PrefixLen",
mInterfaceName.c_str()).raw(),
tmpPrefixLen.asOutParam());
if (SUCCEEDED(hrc) && !tmpPrefixLen.isEmpty())
m.IPV6NetworkMaskPrefixLength = Utf8Str(tmpPrefixLen).toUInt32();
else
m.IPV6NetworkMaskPrefixLength = 64;
}
}
}
#endif
return S_OK;
}
示例4: LogFlowThisFunc
int GuestDirectory::init(GuestSession *aSession,
const Utf8Str &strPath, const Utf8Str &strFilter /*= ""*/, uint32_t uFlags /*= 0*/)
{
LogFlowThisFunc(("strPath=%s, strFilter=%s, uFlags=%x\n",
strPath.c_str(), strFilter.c_str(), uFlags));
/* Enclose the state transition NotReady->InInit->Ready. */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
mData.mSession = aSession;
mData.mName = strPath;
mData.mFilter = strFilter;
mData.mFlags = uFlags;
/* Start the directory process on the guest. */
GuestProcessStartupInfo procInfo;
procInfo.mName = Utf8StrFmt(tr("Reading directory \"%s\"", strPath.c_str()));
procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_LS);
procInfo.mTimeoutMS = 0; /* No timeout. */
procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
/* We want the long output format which contains all the object details. */
procInfo.mArguments.push_back(Utf8Str("-l"));
#if 0 /* Flags are not supported yet. */
if (uFlags & DirectoryOpenFlag_NoSymlinks)
procInfo.mArguments.push_back(Utf8Str("--nosymlinks")); /** @todo What does GNU here? */
#endif
/** @todo Recursion support? */
procInfo.mArguments.push_back(strPath); /* The directory we want to open. */
/*
* Start the process asynchronously and keep it around so that we can use
* it later in subsequent read() calls.
*/
ComObjPtr<GuestProcess> pProcess;
int rc = mData.mSession->processCreateExInteral(procInfo, pProcess);
if (RT_SUCCESS(rc))
rc = pProcess->startProcessAsync();
LogFlowThisFunc(("rc=%Rrc\n", rc));
if (RT_SUCCESS(rc))
{
mData.mProcess = pProcess;
/* Confirm a successful initialization when it's the case. */
autoInitSpan.setSucceeded();
return rc;
}
autoInitSpan.setFailed();
return rc;
}
示例5: DECLCALLBACK
/**
* @interface_method_impl(PDMINVRAM,pfnStoreNvramValue)
*/
DECLCALLBACK(int) drvNvram_pfnLoadNvramValue(PPDMINVRAM pInterface,
int idxVariable,
RTUUID *pVendorUuid,
char *pcszVariableName,
size_t *pcbVariableName,
uint8_t *pu8Value,
size_t *pcbValue)
{
int rc = VINF_SUCCESS;
char szExtraDataKey[256];
Bstr bstrValue;
HRESULT hrc;
LogFlowFunc(("ENTER: idxVariable:%d, *pcbVariableName:%d, *pcbValue:%d\n",
idxVariable,
*pcbVariableName,
*pcbValue));
PNVRAM pThis = RT_FROM_MEMBER(pInterface, NVRAM, INvram);
if (!pThis->fPermanentSave)
{
rc = VERR_NOT_FOUND;
LogFlowFuncLeaveRC(rc);
return rc;
}
RT_ZERO(szExtraDataKey);
RTStrPrintf(szExtraDataKey, 256, "VBoxInternal/Devices/efi/0/LUN#0/Config/NVRAM/%d/VariableName", idxVariable);
hrc = pThis->pNvram->getParent()->machine()->GetExtraData(Bstr(szExtraDataKey).raw(), bstrValue.asOutParam());
if (!SUCCEEDED(hrc))
return VERR_NOT_FOUND;
*pcbVariableName = RTStrCopy(pcszVariableName, 1024, Utf8Str(bstrValue).c_str());
RT_ZERO(szExtraDataKey);
RTStrPrintf(szExtraDataKey, 256, "VBoxInternal/Devices/efi/0/LUN#0/Config/NVRAM/%d/VendorGuid", idxVariable);
hrc = pThis->pNvram->getParent()->machine()->GetExtraData(Bstr(szExtraDataKey).raw(), bstrValue.asOutParam());
RTUuidFromStr(pVendorUuid, Utf8Str(bstrValue).c_str());
#if 0
RT_ZERO(szExtraDataKey);
RTStrPrintf(szExtraDataKey, 256, "VBoxInternal/Devices/efi/0/LUN#0/Config/NVRAM/%d/VariableValueLength", idxVariable);
hrc = pThis->pNvram->getParent()->machine()->GetExtraData(Bstr(szExtraDataKey).raw(), bstrValue.asOutParam());
*pcbValue = Utf8Str(bstrValue).toUInt32();
#endif
RT_ZERO(szExtraDataKey);
RTStrPrintf(szExtraDataKey, 256, "VBoxInternal/Devices/efi/0/LUN#0/Config/NVRAM/%d/VariableValue", idxVariable);
hrc = pThis->pNvram->getParent()->machine()->GetExtraData(Bstr(szExtraDataKey).raw(), bstrValue.asOutParam());
rc = RTBase64Decode(Utf8Str(bstrValue).c_str(), pu8Value, 1024, pcbValue, NULL);
AssertRCReturn(rc, rc);
pThis->cLoadedVariables++;
LogFlowFuncLeaveRC(rc);
return rc;
}
示例6: LogFlowThisFunc
void HostNetworkInterface::i_registerMetrics(PerformanceCollector *aCollector, ComPtr<IUnknown> objptr)
{
LogFlowThisFunc(("mShortName={%ls}, mInterfaceName={%ls}, mGuid={%s}, mSpeedMbits=%u\n",
mShortName.raw(), mInterfaceName.raw(), mGuid.toString().c_str(), m.speedMbits));
pm::CollectorHAL *hal = aCollector->getHAL();
/* Create sub metrics */
Utf8StrFmt strName("Net/%ls", mShortName.raw());
pm::SubMetric *networkLoadRx = new pm::SubMetric(strName + "/Load/Rx",
"Percentage of network interface receive bandwidth used.");
pm::SubMetric *networkLoadTx = new pm::SubMetric(strName + "/Load/Tx",
"Percentage of network interface transmit bandwidth used.");
pm::SubMetric *networkLinkSpeed = new pm::SubMetric(strName + "/LinkSpeed",
"Physical link speed.");
/* Create and register base metrics */
pm::BaseMetric *networkSpeed = new pm::HostNetworkSpeed(hal, objptr, strName + "/LinkSpeed",
Utf8Str(mShortName), Utf8Str(mInterfaceName),
m.speedMbits, networkLinkSpeed);
aCollector->registerBaseMetric(networkSpeed);
pm::BaseMetric *networkLoad = new pm::HostNetworkLoadRaw(hal, objptr, strName + "/Load",
Utf8Str(mShortName), Utf8Str(mInterfaceName),
m.speedMbits, networkLoadRx, networkLoadTx);
aCollector->registerBaseMetric(networkLoad);
aCollector->registerMetric(new pm::Metric(networkSpeed, networkLinkSpeed, 0));
aCollector->registerMetric(new pm::Metric(networkSpeed, networkLinkSpeed,
new pm::AggregateAvg()));
aCollector->registerMetric(new pm::Metric(networkSpeed, networkLinkSpeed,
new pm::AggregateMin()));
aCollector->registerMetric(new pm::Metric(networkSpeed, networkLinkSpeed,
new pm::AggregateMax()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadRx, 0));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadRx,
new pm::AggregateAvg()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadRx,
new pm::AggregateMin()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadRx,
new pm::AggregateMax()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadTx, 0));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadTx,
new pm::AggregateAvg()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadTx,
new pm::AggregateMin()));
aCollector->registerMetric(new pm::Metric(networkLoad, networkLoadTx,
new pm::AggregateMax()));
}
示例7: LogFlowThisFunc
HRESULT MachineDebugger::getOSVersion(com::Utf8Str &aOSVersion)
{
LogFlowThisFunc(("\n"));
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
Console::SafeVMPtr ptrVM(mParent);
HRESULT hrc = ptrVM.rc();
if (SUCCEEDED(hrc))
{
/*
* Do the job and try convert the name.
*/
char szVersion[256];
int vrc = DBGFR3OSQueryNameAndVersion(ptrVM.rawUVM(), NULL, 0, szVersion, sizeof(szVersion));
if (RT_SUCCESS(vrc))
{
try
{
Bstr bstrVersion(szVersion);
aOSVersion = Utf8Str(bstrVersion);
}
catch (std::bad_alloc)
{
hrc = E_OUTOFMEMORY;
}
}
else
hrc = setError(VBOX_E_VM_ERROR, tr("DBGFR3OSQueryNameAndVersion failed with %Rrc"), vrc);
}
return hrc;
}
示例8: switch
STDMETHODIMP GuestFileEventListener::HandleEvent(VBoxEventType_T aType, IEvent *aEvent)
{
switch (aType)
{
case VBoxEventType_OnGuestFileStateChanged:
{
HRESULT rc;
do
{
ComPtr<IGuestFileStateChangedEvent> pEvent = aEvent;
Assert(!pEvent.isNull());
ComPtr<IGuestFile> pProcess;
CHECK_ERROR_BREAK(pEvent, COMGETTER(File)(pProcess.asOutParam()));
AssertBreak(!pProcess.isNull());
FileStatus_T fileSts;
CHECK_ERROR_BREAK(pEvent, COMGETTER(Status)(&fileSts));
Bstr strPath;
CHECK_ERROR_BREAK(pProcess, COMGETTER(FileName)(strPath.asOutParam()));
ULONG uID;
CHECK_ERROR_BREAK(pProcess, COMGETTER(Id)(&uID));
RTPrintf("File ID=%RU32 \"%s\" changed status to [%s]\n",
uID, Utf8Str(strPath).c_str(), gctlFileStatusToText(fileSts));
} while (0);
break;
}
default:
AssertFailed();
}
return S_OK;
}
示例9: unconst
/**
* Initializes the object (called right after construction).
*
* @returns VBox status code.
*/
int USBProxyBackendSolaris::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress)
{
USBProxyBackend::init(aUsbProxyService, strId, strAddress);
unconst(m_strBackend) = Utf8Str("host");
/*
* Create semaphore.
*/
int rc = RTSemEventCreate(&mNotifyEventSem);
if (RT_FAILURE(rc))
return rc;
/*
* Initialize the USB library.
*/
rc = USBLibInit();
if (RT_FAILURE(rc))
{
/* mNotifyEventSem will be destroyed in uninit */
return rc;
}
mUSBLibInitialized = true;
/*
* Start the poller thread.
*/
start();
return VINF_SUCCESS;
}
示例10: LogFlowThisFunc
/**
* Initializes the USB device filter object (short version).
*
* @param aParent Handle of the parent object.
*/
HRESULT USBDeviceFilter::init(USBDeviceFilters *aParent, IN_BSTR aName)
{
LogFlowThisFunc(("aParent=%p\n", aParent));
ComAssertRet(aParent && aName && *aName, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
unconst(mParent) = aParent;
/* mPeer is left null */
m_fModified = false;
bd.allocate();
bd->mData.strName = Utf8Str(aName);
bd->mData.fActive = FALSE;
bd->mData.ulMaskedInterfaces = 0;
/* initialize all filters to any match using null string */
USBFilterInit(&bd->mUSBFilter, USBFILTERTYPE_CAPTURE);
bd->mRemote = NULL;
mInList = false;
/* Confirm successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例11: ComSafeArrayOut
STDMETHODIMP VFSExplorer::Exists(ComSafeArrayIn(IN_BSTR, aNames), ComSafeArrayOut(BSTR, aExists))
{
CheckComArgSafeArrayNotNull(aNames);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
com::SafeArray<IN_BSTR> sfaNames(ComSafeArrayInArg(aNames));
std::list<BSTR> listExists;
for (size_t a=0; a < sfaNames.size(); ++a)
{
std::list<VFSExplorer::Data::DirEntry>::const_iterator it;
for (it = m->entryList.begin();
it != m->entryList.end();
++it)
{
const VFSExplorer::Data::DirEntry &entry = (*it);
if (entry.name == RTPathFilename(Utf8Str(sfaNames[a]).c_str()))
{
BSTR name;
Bstr tmp(sfaNames[a]); /* gcc-3.3 cruft */
tmp.cloneTo(&name);
listExists.push_back(name);
}
}
}
com::SafeArray<BSTR> sfaExists(listExists);
sfaExists.detachTo(ComSafeArrayOutArg(aExists));
return S_OK;
}
示例12: alock
HRESULT DHCPServer::getUpperIP(com::Utf8Str &aIPAddress)
{
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
aIPAddress = Utf8Str(m->upperIP);
return S_OK;
}
示例13: Utf8Str
STDMETHODIMP DHCPServer::Start(IN_BSTR aNetworkName, IN_BSTR aTrunkName, IN_BSTR aTrunkType)
{
/* Silently ignore attempts to run disabled servers. */
if (!m.enabled)
return S_OK;
m.dhcp.setOption(DHCPCFG_NETNAME, Utf8Str(aNetworkName), true);
Bstr tmp(aTrunkName);
if (!tmp.isEmpty())
m.dhcp.setOption(DHCPCFG_TRUNKNAME, Utf8Str(tmp), true);
m.dhcp.setOption(DHCPCFG_TRUNKTYPE, Utf8Str(aTrunkType), true);
//temporary hack for testing
// DHCPCFG_NAME
char strMAC[32];
Guid guid;
guid.create();
RTStrPrintf (strMAC, sizeof(strMAC), "08:00:27:%02X:%02X:%02X",
guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
m.dhcp.setOption(DHCPCFG_MACADDRESS, strMAC, true);
m.dhcp.setOption(DHCPCFG_IPADDRESS, Utf8Str(m.IPAddress), true);
// DHCPCFG_LEASEDB,
// DHCPCFG_VERBOSE,
// DHCPCFG_GATEWAY,
m.dhcp.setOption(DHCPCFG_LOWERIP, Utf8Str(m.lowerIP), true);
m.dhcp.setOption(DHCPCFG_UPPERIP, Utf8Str(m.upperIP), true);
m.dhcp.setOption(DHCPCFG_NETMASK, Utf8Str(m.networkMask), true);
// DHCPCFG_HELP,
// DHCPCFG_VERSION,
// DHCPCFG_NOTOPT_MAXVAL
m.dhcp.setOption(DHCPCFG_BEGINCONFIG, "", true);
return RT_FAILURE(m.dhcp.start()) ? E_FAIL : S_OK;
//m.dhcp.detachFromServer(); /* need to do this to avoid server shutdown on runner destruction */
}
示例14: path
HRESULT SystemProperties::i_setDefaultAdditionsISO(const com::Utf8Str &aPath)
{
com::Utf8Str path(aPath);
if (path.isEmpty())
{
char strTemp[RTPATH_MAX];
int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
AssertRC(vrc);
Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
vrc = RTPathExecDir(strTemp, sizeof(strTemp));
AssertRC(vrc);
Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
vrc = RTPathUserHome(strTemp, sizeof(strTemp));
AssertRC(vrc);
Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%s.iso", strTemp, VirtualBox::i_getVersionNormalized().c_str());
/* Check the standard image locations */
if (RTFileExists(strSrc1.c_str()))
path = strSrc1;
else if (RTFileExists(strSrc2.c_str()))
path = strSrc2;
else if (RTFileExists(strSrc3.c_str()))
path = strSrc3;
else
return setError(E_FAIL,
tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
}
if (!RTPathStartsWithRoot(path.c_str()))
return setError(E_INVALIDARG,
tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
path.c_str());
if (!RTFileExists(path.c_str()))
return setError(E_INVALIDARG,
tr("Given default machine Guest Additions ISO file '%s' does not exist"),
path.c_str());
m->strDefaultAdditionsISO = path;
return S_OK;
}
示例15: LogFlowThisFuncEnter
HRESULT MediumAttachment::getController(com::Utf8Str &aController)
{
LogFlowThisFuncEnter();
/* m->controller is constant during life time, no need to lock */
aController = Utf8Str(m->bd->strControllerName);
LogFlowThisFuncLeave();
return S_OK;
}