本文整理汇总了C++中ptree::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::get方法的具体用法?C++ ptree::get怎么用?C++ ptree::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ptree
的用法示例。
在下文中一共展示了ptree::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromMatlab
shared_ptr<ProbabilisticSvmClassifier> ProbabilisticSvmClassifier::load(const ptree& subtree)
{
path classifierFile = subtree.get<path>("classifierFile");
shared_ptr<ProbabilisticSvmClassifier> psvm;
if (classifierFile.extension() == ".mat") {
psvm = loadFromMatlab(classifierFile.string(), subtree.get<string>("thresholdsFile"));
} else {
shared_ptr<SvmClassifier> svm = SvmClassifier::loadFromText(classifierFile.string()); // Todo: Make a ProbabilisticSvmClassifier::loadFromText(...)
if (subtree.get("logisticA", 0.0) == 0.0 || subtree.get("logisticB", 0.0) == 0.0) {
std::cout << "Warning, one or both sigmoid parameters not set in config, using default sigmoid parameters." << std::endl; // TODO use logger
}
psvm = make_shared<ProbabilisticSvmClassifier>(svm);
}
// If the user sets the logistic parameters in the config, overwrite the current settings with it
double logisticA = subtree.get("logisticA", 0.0); // TODO: This is not so good, better use the try/catch of get(...). Because: What if the user actually sets a value of 0.0 in the config...
double logisticB = subtree.get("logisticB", 0.0);
if (logisticA != 0.0 && logisticB != 0.0) {
psvm->setLogisticParameters(logisticA, logisticB);
}
psvm->getSvm()->setThreshold(subtree.get("threshold", 0.0f));
return psvm;
}
示例2: parseJsonAndGetUser
User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const {
User::Ptr result(new User);
result->id = data.get<int32_t>("id");
result->firstName = data.get<string>("first_name");
result->lastName = data.get("last_name", "");
result->username = data.get("username", "");
return result;
}
示例3: parseJsonAndGetContact
Contact::Ptr TgTypeParser::parseJsonAndGetContact(const ptree& data) const {
Contact::Ptr result(new Contact);
result->phoneNumber = data.get<string>("phone_number");
result->firstName = data.get<string>("first_name");
result->lastName = data.get("last_name", "");
result->userId = data.get("user_id", "");
return result;
}
示例4: parseJsonAndGetAudio
Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const ptree& data) const {
Audio::Ptr result(new Audio);
result->fileId = data.get<string>("file_id");
result->duration = data.get<int32_t>("duration");
result->mimeType = data.get("mime_type", "");
result->fileSize = data.get("file_size", 0);
return result;
}
示例5: parseJsonAndGetDocument
Document::Ptr TgTypeParser::parseJsonAndGetDocument(const ptree& data) const {
Document::Ptr result(new Document);
result->fileId = data.get<string>("file_id");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->fileName = data.get("file_name", "");
result->mimeType = data.get("mime_type", "");
result->fileSize = data.get("file_size", 0);
return result;
}
示例6: parseJsonAndGetVideo
Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const {
Video::Ptr result(new Video);
result->fileId = data.get<string>("file_id");
result->width = data.get<int32_t>("width");
result->height = data.get<int32_t>("height");
result->duration = data.get<int32_t>("duration");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->mimeType = data.get("mime_type", "");
result->fileSize = data.get("file_size", 0);
return result;
}
示例7: load
/*!
* \copydoc Base::Props::load
*/
void load(const ptree & pt)
{
device = pt.get("dev.device", "/dev/video0");
input = pt.get("dev.input", "Composite1");
norm = pt.get("dev.norm", "PAL-BG");
format = pt.get("dev.format", "BGR3");
width = pt.get("dev.width", 640);
height = pt.get("dev.height", 480);
brightness = pt.get("image.brightness", 0.5);
contrast = pt.get("image.contrast", 0.5);
saturation = pt.get("image.saturation", 0.5);
hue = pt.get("image.hue", 0.5);
}
示例8:
//------------------------------------------------------------------------------
void
Image::set(ptree pt)
{
if(pt.get_child_optional("UV")) this->setUV(Box(pt.get_child("UV")), getBoolFromPT(pt, "UV.normalized", false));
if(pt.get_child_optional("NinePatch")) this->setNinePatchData(NinePatchData(pt.get_child("NinePatch")));
if(pt.get_child_optional("color")) this->color = Color(pt.get("color", "#FFF"));
};
示例9: if
//------------------------------------------------------------------------------
void
WText::_set(ptree n)
{
if(n.get_child_optional("text.content"))
this->setText(n.get("text.content", this->text));
if(n.get_child_optional("text.padding"))
this->padding = n.get<FNumber>("text.padding");
if(n.get_child_optional("text.font"))
{
if(n.get_child_optional("text.font.path") && n.get_child_optional("text.font.size"))
this->setFont(this->kernel->graphicsMgr->loadFont(
n.get<string>("text.font.path"),
n.get<int> ("text.font.size")));
else if(n.get_child_optional("text.font.size"))
this->setFontSize(n.get<int>("text.font.size"));
else if(n.get_child_optional("text.font.path"))
this->setFont(this->kernel->graphicsMgr->loadFont(
n.get<string>("text.font.path"),
this->font.getSize()));
if(n.get_child_optional("text.font.color"))
this->setColor(Color(n.get<string>("text.font.color")));
if(n.get_child_optional("text.font.background_color"))
this->setBG(Color(n.get<string>("text.font.background_color")));
/// TODO: transparent [bool]
/// TODO: alignment
}
};
示例10: Vect
void
SpriteLine::set(ptree params)
{
this->to = Vect(params, "toX", "toY", this->to);
this->col = params.get("color", this->col.getString());
setBoolFromPT(params, "AA", this->AA);
};
示例11: get
template<class Type , class Translator> inline
typename boost::enable_if<detail::is_translator<Translator>, Type>::type
get(const std::string &argPath, const Type &argDefault, Translator tr) const {
Type value = ptree_.get(argPath, argDefault);
parameters_.insert(std::make_pair(argPath, value));
return value;
}
示例12: parseJsonAndGetPhotoSize
PhotoSize::Ptr TgTypeParser::parseJsonAndGetPhotoSize(const ptree& data) const {
PhotoSize::Ptr result(new PhotoSize);
result->fileId = data.get<string>("file_id");
result->width = data.get<int32_t>("width");
result->height = data.get<int32_t>("height");
result->fileSize = data.get("file_size", 0);
return result;
}
示例13: parseJsonAndGetSticker
Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const {
Sticker::Ptr result(new Sticker);
result->fileId = data.get<string>("file_id");
result->width = data.get<int32_t>("width");
result->height = data.get<int32_t>("height");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->fileSize = data.get("file_size", 0);
return result;
}
示例14: paramFromPtree
bool ConfigTree::paramFromPtree(ptree fromPtree, ConfigParameter &toParam)
{
CONFIGSYS_DEBUG_CALLS;
std::string typStr = fromPtree.get<std::string>("type");
value_type vt = stringToValueType(typStr);
toParam = ConfigParameter(vt);
toParam.setDescription(fromPtree.get("desc", ""));
std::string modStr = fromPtree.get("modified", "false");
toParam.setModified(modStr.compare("true") == 0);
std::string lockStr = fromPtree.get("locked", "false");
toParam.setLocked(lockStr.compare("true") == 0);
return addPtreeValueandRangeToParam(fromPtree, toParam);
}
示例15: loadSigmoidParamsFromMatlab
shared_ptr<ProbabilisticWvmClassifier> ProbabilisticWvmClassifier::load(const ptree& subtree)
{
pair<double, double> sigmoidParams = loadSigmoidParamsFromMatlab(subtree.get<string>("thresholdsFile"));
// Load the detector and thresholds:
shared_ptr<WvmClassifier> wvm = WvmClassifier::loadFromMatlab(subtree.get<string>("classifierFile"), subtree.get<string>("thresholdsFile"));
shared_ptr<ProbabilisticWvmClassifier> pwvm = make_shared<ProbabilisticWvmClassifier>(wvm, sigmoidParams.first, sigmoidParams.second);
pwvm->getWvm()->setLimitReliabilityFilter(subtree.get("threshold", 0.0f));
return pwvm;
}