本文整理汇总了C++中DialogFeaturesMap类的典型用法代码示例。如果您正苦于以下问题:C++ DialogFeaturesMap类的具体用法?C++ DialogFeaturesMap怎么用?C++ DialogFeaturesMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DialogFeaturesMap类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseDialogFeaturesMap
static DialogFeaturesMap parseDialogFeaturesMap(const String& string)
{
// FIXME: Not clear why we take such a different approach to parsing dialog features
// as opposed to window features (using a map, different parsing quirks).
DialogFeaturesMap features;
Vector<String> vector;
string.split(';', vector);
for (auto& featureString : vector) {
size_t separatorPosition = featureString.find('=');
size_t colonPosition = featureString.find(':');
if (separatorPosition != notFound && colonPosition != notFound)
continue; // ignore strings that have both = and :
if (separatorPosition == notFound)
separatorPosition = colonPosition;
String key = featureString.left(separatorPosition).stripWhiteSpace();
// Null string for value indicates key without value.
String value;
if (separatorPosition != notFound) {
value = featureString.substring(separatorPosition + 1).stripWhiteSpace();
value = value.left(value.find(' '));
}
features.set(key, value);
}
return features;
}
示例2: boolFeature
bool WindowFeatures::boolFeature(const DialogFeaturesMap& features, const char* key, bool defaultValue)
{
DialogFeaturesMap::const_iterator it = features.find(key);
if (it == features.end())
return defaultValue;
const String& value = it->value;
return value.isNull() || value == "1" || value == "yes" || value == "on";
}
示例3: boolFeature
static Optional<bool> boolFeature(const DialogFeaturesMap& features, const char* key)
{
auto it = features.find(key);
if (it == features.end())
return Nullopt;
auto& value = it->value;
return value.isNull()
|| value == "1"
|| equalLettersIgnoringASCIICase(value, "yes")
|| equalLettersIgnoringASCIICase(value, "on");
}
示例4: intFeature
int WindowFeatures::intFeature(const DialogFeaturesMap& features, const char* key, int min, int max, int defaultValue)
{
DialogFeaturesMap::const_iterator it = features.find(key);
if (it == features.end())
return defaultValue;
bool ok;
int parsedNumber = it->value.toInt(&ok);
if (!ok)
return defaultValue;
if (parsedNumber < min || max <= min)
return min;
if (parsedNumber > max)
return max;
return parsedNumber;
}
示例5: parseDialogFeatures
void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap& map)
{
Vector<String> vector;
string.split(';', vector);
size_t size = vector.size();
for (size_t i = 0; i < size; ++i) {
const String& featureString = vector[i];
size_t separatorPosition = featureString.find('=');
size_t colonPosition = featureString.find(':');
if (separatorPosition != kNotFound && colonPosition != kNotFound)
continue; // ignore strings that have both = and :
if (separatorPosition == kNotFound)
separatorPosition = colonPosition;
String key = featureString.left(separatorPosition).stripWhiteSpace().lower();
// Null string for value indicates key without value.
String value;
if (separatorPosition != kNotFound) {
value = featureString.substring(separatorPosition + 1).stripWhiteSpace().lower();
value = value.left(value.find(' '));
}
map.set(key, value);
}
}
示例6: floatFeature
float WindowFeatures::floatFeature(const DialogFeaturesMap& features, const char* key, float min, float max, float defaultValue)
{
DialogFeaturesMap::const_iterator it = features.find(key);
if (it == features.end())
return defaultValue;
// FIXME: The toDouble function does not offer a way to tell "0q" from string with no digits in it: Both
// return the number 0 and false for ok. But "0q" should yield the minimum rather than the default.
bool ok;
double parsedNumber = it->value.toDouble(&ok);
if ((!parsedNumber && !ok) || std::isnan(parsedNumber))
return defaultValue;
if (parsedNumber < min || max <= min)
return min;
if (parsedNumber > max)
return max;
// FIXME: Seems strange to cast a double to int and then convert back to a float. Why is this a good idea?
return static_cast<int>(parsedNumber);
}