本文整理汇总了C++中std::string::setNormalParams方法的典型用法代码示例。如果您正苦于以下问题:C++ string::setNormalParams方法的具体用法?C++ string::setNormalParams怎么用?C++ string::setNormalParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::setNormalParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: void
void Button::setParam(
std::string const &k, std::string const &v)
{
using lambda = void (*)(Button*,std::string const&);
using map = std::unordered_map<std::string, lambda>;
static map param_map
{
{"highlightLocked", [](Button *v, std::string const &str) {
v->lockHighlight(str == "true");
}},
{"normalFillColor", [](Button *v, std::string const &str) {
auto old = v->getNormalParams();
old.fillColor = std::stoul(str, NULL, 16);
v->setNormalParams(old);
}},
{"highlightFillColor", [](Button *v, std::string const &str) {
auto old = v->getHighlightParams();
old.fillColor = std::stoul(str, NULL, 16);
v->setHighlightParams(old);
}},
{"normalStrokeColor", [](Button *v, std::string const &str) {
auto old = v->getNormalParams();
old.strokeColor = std::stoul(str, NULL, 16);
v->setNormalParams(old);
}},
{"normalBorderWidth", [](Button *v, std::string const &str) {
auto old = v->getNormalParams();
old.lineWidth = std::stoi(str, NULL);
v->setNormalParams(old);
}},
{"pushedFillColor", [](Button *v, std::string const &str) {
auto old = v->getPushedParams();
old.fillColor = std::stoul(str, NULL, 16);
v->setPushedParams(old);
}},
{"pushedStrokeColor", [](Button *v, std::string const &str) {
auto old = v->getPushedParams();
old.strokeColor = std::stoul(str, NULL, 16);
v->setPushedParams(old);
}},
{"pushedBorderWidth", [](Button *v, std::string const &str) {
auto old = v->getPushedParams();
old.lineWidth = std::stoi(str, NULL);
v->setPushedParams(old);
}},
};
auto const &it = param_map.find(k);
if (it != param_map.end())
it->second(this, v);
else
AView::setParam(k, v);
}