本文整理汇总了C++中Any::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::ToString方法的具体用法?C++ Any::ToString怎么用?C++ Any::ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Any
的用法示例。
在下文中一共展示了Any::ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: manifestRes
ModulePrivate::ModulePrivate(Module* qq, CoreModuleContext* coreCtx,
ModuleInfo* info)
: coreCtx(coreCtx)
, info(*info)
, resourceContainer(info)
, moduleContext(0)
, moduleActivator(0)
, q(qq)
{
// Check if the module provides a manifest.json file and if yes, parse it.
if (resourceContainer.IsValid())
{
ModuleResource manifestRes("/manifest.json", resourceContainer);
if (manifestRes)
{
ModuleResourceStream manifestStream(manifestRes);
try
{
moduleManifest.Parse(manifestStream);
}
catch (const std::exception& e)
{
US_ERROR << "Parsing of manifest.json for module " << info->location << " failed: " << e.what();
}
}
}
// Check if we got version information and validate the version identifier
if (moduleManifest.Contains(Module::PROP_VERSION()))
{
Any versionAny = moduleManifest.GetValue(Module::PROP_VERSION());
std::string errMsg;
if (versionAny.Type() != typeid(std::string))
{
errMsg = std::string("The version identifier must be a string");
}
try
{
version = ModuleVersion(versionAny.ToString());
}
catch (const std::exception& e)
{
errMsg = std::string("The version identifier is invalid: ") + e.what();
}
if (!errMsg.empty())
{
throw std::invalid_argument(std::string("The Json value for ") + Module::PROP_VERSION() + " for module " +
info->location + " is not valid: " + errMsg);
}
}
std::stringstream propId;
propId << this->info.id;
moduleManifest.SetValue(Module::PROP_ID(), propId.str());
moduleManifest.SetValue(Module::PROP_LOCATION(), this->info.location);
moduleManifest.SetValue(Module::PROP_NAME(), this->info.name);
if (moduleManifest.Contains(Module::PROP_AUTOLOAD_DIR()))
{
this->info.autoLoadDir = moduleManifest.GetValue(Module::PROP_AUTOLOAD_DIR()).ToString();
}
else
{
this->info.autoLoadDir = this->info.name;
moduleManifest.SetValue(Module::PROP_AUTOLOAD_DIR(), Any(this->info.autoLoadDir));
}
}