本文整理汇总了C++中poco::json::object::Ptr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::get方法的具体用法?C++ Ptr::get怎么用?C++ Ptr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::json::object::Ptr
的用法示例。
在下文中一共展示了Ptr::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extract_token
string ExposerConfig::extract_token(string response_string) {
try
{
//Try to extract token
Poco::JSON::Parser parser;
Poco::Dynamic::Var result = parser.parse(response_string);
Poco::JSON::Object::Ptr object = result.extract<Poco::JSON::Object::Ptr>();
string tmptoken = object->get("token");
ostringstream tmpmsg;
//tmpmsg << " ===== Got a token: " << tmptoken;
tmpmsg << " ===== Got a token.";
Log::log(Log::INFO, tmpmsg.str());
return tmptoken;
}
catch (std::exception &ex)
{
ostringstream tmpmsg;
tmpmsg << "Exception when trying to read token: " << ex.what();
Log::log(Log::ERROR, tmpmsg.str());
return "";
}
}
示例2: blockDescMatchesFilter
bool BlockTreeWidget::blockDescMatchesFilter(const Poco::JSON::Object::Ptr &blockDesc)
{
if (_filter.isEmpty()) return true;
const auto path = blockDesc->get("path").extract<std::string>();
const auto name = blockDesc->get("name").extract<std::string>();
//construct a candidate string from path, name, categories, and keywords.
std::string candidate = path+name;
if (blockDesc->isArray("categories")) for (auto categoryObj : *blockDesc->getArray("categories"))
{
candidate += categoryObj.extract<std::string>();
}
if(blockDesc->isArray("keywords"))
{
const auto keywords = blockDesc->getArray("keywords");
for(auto keyword : *keywords) candidate += keyword.extract<std::string>();
}
//reject if filter string not found in candidate
candidate = Poco::toLower(candidate);
const auto searchToken = Poco::toLower(_filter.toStdString());
return (candidate.find(searchToken) != std::string::npos);
}
示例3: extract_sessionid
string ExposerConfig::extract_sessionid(string json_string) {
try
{
//Try to extract sessionid
Poco::JSON::Parser parser;
Poco::Dynamic::Var result = parser.parse(json_string);
Poco::JSON::Object::Ptr object = result.extract<Poco::JSON::Object::Ptr>();
string tmpsessionid = object->get("id");
ostringstream tmpmsg;
tmpmsg << " ===== Got a sessionid: " << tmpsessionid;
Log::log(Log::INFO, tmpmsg.str());
return tmpsessionid;
}
catch (Poco::Exception &ex)
{
ostringstream tmpmsg;
tmpmsg << "Exception when trying to read sessionid: " << ex.displayText();
Log::log(Log::ERROR, tmpmsg.str());
return "";
}
}
示例4: loadDocument
bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTokenizer& tokens)
{
Poco::Mutex::ScopedLock lock(_mutex);
int part = -1;
if (tokens.count() < 2)
{
sendTextFrame("error: cmd=load kind=syntax");
return false;
}
std::string timestamp;
parseDocOptions(tokens, part, timestamp);
assert(!_docURL.empty());
assert(!_jailedFilePath.empty());
if (_loKitDocument == nullptr)
Log::info("Loading new document from URI: [" + _jailedFilePath + "].");
else
Log::info("Loading view to document from URI: [" + _jailedFilePath + "].");
if (_loKitDocument != nullptr)
{
_viewId = _loKitDocument->pClass->createView(_loKitDocument);
}
else
{
if ( LIBREOFFICEKIT_HAS(_loKit, registerCallback))
_loKit->pClass->registerCallback(_loKit, myCallback, this);
if ((_loKitDocument = _loKit->pClass->documentLoad(_loKit, _jailedFilePath.c_str())) == nullptr)
{
Log::error("Failed to load: " + _jailedFilePath + ", error: " + _loKit->pClass->getError(_loKit));
sendTextFrame("error: cmd=load kind=failed");
return false;
}
}
_loKitDocument->pClass->setView(_loKitDocument, _viewId);
std::string renderingOptions;
if (!_docOptions.empty())
{
Poco::JSON::Parser parser;
Poco::Dynamic::Var var = parser.parse(_docOptions);
Poco::JSON::Object::Ptr object = var.extract<Poco::JSON::Object::Ptr>();
renderingOptions = object->get("rendering").toString();
}
_loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
if (_docType != "text" && part != -1)
{
_clientPart = part;
_loKitDocument->pClass->setPart(_loKitDocument, part);
}
_loKitDocument->pClass->registerCallback(_loKitDocument, myCallback, this);
if (!getStatus(buffer, length))
return false;
_onLoad(_loKitDocument, _viewId);
return true;
}