本文整理汇总了C++中VM::Run方法的典型用法代码示例。如果您正苦于以下问题:C++ VM::Run方法的具体用法?C++ VM::Run怎么用?C++ VM::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VM
的用法示例。
在下文中一共展示了VM::Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderFile
string CViewRenderer::renderFile(const IRenderingContext * context, const string & sourceFile, CDT & data, bool ret) throw (CException)
{
boost::filesystem::path sourcePath(sourceFile);
if (!boost::filesystem::exists(sourcePath)) {
throw CException("View file \"" + sourceFile + "\" does not exist.");
}
string viewFile = getViewFile(sourceFile);
boost::filesystem::path viewPath(viewFile);
if (!boost::filesystem::exists(viewPath) || boost::filesystem::last_write_time(sourcePath) > boost::filesystem::last_write_time(viewPath)) {
if (generateViewFile(sourceFile, viewFile)) {
chmod(viewFile.c_str(), filePermission);
} else {
throw CException("Can't generate view file \"" + viewFile + "\" from source file \"" + sourceFile + "\".");
}
}
if (context != 0) {
return context->renderInternal(viewFile, data, ret);
}
stringstream os;
StreamOutputCollector outputCollector(os);
TDynamicTemplateCacheMap::const_iterator found = _templateCache.find(viewFile);
VMLoader * oLoader = 0;
if (found == _templateCache.end()) {
oLoader = new VMFileLoader(viewFile.c_str());
_templateCache[viewFile.c_str()] = boost::shared_ptr<VMLoader>(oLoader);
} else {
oLoader = found->second.get();
}
PROFILE_BEGIN("CViewRenderer::rendering template bytecode of \"" + viewFile + "\"")
UINT_32 iIP = 0;
VM * vm = Cws::app()->getTemplateEngine()->getVM();
const VMMemoryCore * pVMMemoryCore = oLoader->GetCore();
vm->Init(pVMMemoryCore, &outputCollector, 0);
vm->Run(pVMMemoryCore, &outputCollector, iIP, data, 0);
PROFILE_END()
if (ret) {
return os.str();
} else {
Cws::app()->getOutputStack().top()->echo(os.str());
return "";
}
}