本文整理汇总了C++中WT_USTRING::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_USTRING::empty方法的具体用法?C++ WT_USTRING::empty怎么用?C++ WT_USTRING::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_USTRING
的用法示例。
在下文中一共展示了WT_USTRING::empty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeSpaces
// Remove spaces, only for input masks
WT_USTRING WLineEdit::removeSpaces(const WT_USTRING& text) const
{
if (!raw_.empty() && !text.empty()) {
std::u32string result = text;
std::size_t i = 0;
for (std::size_t j = 0; j < raw_.length(); ++i, ++j) {
while (j < raw_.length() &&
result[j] == spaceChar_ &&
mask_[j] != '_') {
++j;
}
if (j < raw_.length()) {
if (i != j) {
result[i] = result[j];
}
} else {
--i;
}
}
result = result.substr(0, i);
return WT_USTRING(result);
} else {
return text;
}
}
示例2: validate
WValidator::Result WTimeValidator::validate(const WT_USTRING& input) const
{
if (input.empty())
return WValidator::validate(input);
for (unsigned i = 0; i < formats_.size(); ++i) {
try {
WTime d = WTime::fromString(input, formats_[i]);
if (d.isValid()) {
if (!bottom_.isNull())
if (d < bottom_)
return Result(Invalid, invalidTooEarlyText());
if (!top_.isNull())
if (d > top_)
return Result(Invalid, invalidTooLateText());
return Result(Valid);
}
} catch (std::exception& e) {
LOG_WARN("validate(): " << e.what());
}
}
return Result(Invalid, invalidNotATimeText());
}
示例3: validate
WValidator::Result WRegExpValidator::validate(const WT_USTRING& input) const
{
if (input.empty())
return WValidator::validate(input);
if (std::regex_match(input.toUTF8(), regex_))
return Result(ValidationState::Valid);
else
return Result(ValidationState::Invalid, invalidNoMatchText());
}
示例4: validate
WValidator::Result WRegExpValidator::validate(const WT_USTRING& input) const
{
if (input.empty())
return WValidator::validate(input);
if (!regexp_ || regexp_->exactMatch(input))
return Result(Valid);
else
return Result(Invalid, invalidNoMatchText());
}
示例5: validate
WValidator::Result WMatchValidator::validate(const WT_USTRING& strInput) const
{
if(0 == m_pCompareWidget) {
return Result(Invalid, invalidDataText());
}
if(strInput.empty()) {
return WValidator::validate(strInput);
}
if(strInput != m_pCompareWidget->valueText()) {
return Result(Invalid, mismatchText());
}
return Result(Valid);
}
示例6: validate
WValidator::Result WIntValidator::validate(const WT_USTRING& input) const
{
if (input.empty())
return WValidator::validate(input);
std::string text = input.toUTF8();
try {
int i = WLocale::currentLocale().toInt(text);
if (i < bottom_)
return Result(Invalid, invalidTooSmallText());
else if (i > top_)
return Result(Invalid, invalidTooLargeText());
else
return Result(Valid);
} catch (boost::bad_lexical_cast& e) {
return Result(Invalid, invalidNotANumberText());
}
}
示例7: inputText
// Unless the given text is empty, input the text as if it was
// entered character by character on the client side, applying
// the input mask, if present.
WT_USTRING WLineEdit::inputText(const WT_USTRING& text) const
{
if (!raw_.empty() && !text.empty()) {
std::u32string newText = text;
std::u32string result = raw_;
char32_t chr;
bool hadIgnoredChar = false;
std::size_t j = 0, i = 0;
for (i = 0; i < newText.length(); ++i) {
std::size_t previousJ = j;
chr = newText[i];
while (j < mask_.length() && !acceptChar(chr, j)) {
++j; /* Try to move forward as long as this characer is not
* accepted in this position
*/
}
if (j == mask_.length()) {
j = previousJ;
hadIgnoredChar = true;
} else {
if (raw_[j] != chr) {
if (case_[j] == '>') {
chr = toupper(chr);
} else if (case_[j] == '<') {
chr = tolower(chr);
}
result[j] = chr;
}
++j;
}
}
if (hadIgnoredChar) {
LOG_INFO("Input mask: not all characters in input '" + text + "' complied with "
"input mask " + inputMask_ + " and were ignored. Result is '" + result + "'.");
}
return WT_USTRING(result);
}
return text;
}
示例8: updateDom
void WLineEdit::updateDom(DomElement& element, bool all)
{
if (all || flags_.test(BIT_CONTENT_CHANGED)) {
WT_USTRING t = content_;
if (!mask_.empty() && (inputMaskFlags_.test(
InputMaskFlag::KeepMaskWhileBlurred)))
t = displayContent_;
if (!all || !t.empty())
element.setProperty(Wt::Property::Value, t.toUTF8());
flags_.reset(BIT_CONTENT_CHANGED);
}
if (all || flags_.test(BIT_ECHO_MODE_CHANGED)) {
element.setAttribute("type", echoMode_ == EchoMode::Normal
? "text" : "password");
flags_.reset(BIT_ECHO_MODE_CHANGED);
}
if (all || flags_.test(BIT_AUTOCOMPLETE_CHANGED)) {
if (!all || !autoComplete_) {
element.setAttribute("autocomplete",
autoComplete_ == true ? "on" : "off");
}
flags_.reset(BIT_AUTOCOMPLETE_CHANGED);
}
if (all || flags_.test(BIT_TEXT_SIZE_CHANGED)) {
element.setAttribute("size", std::to_string(textSize_));
flags_.reset(BIT_TEXT_SIZE_CHANGED);
}
if (all || flags_.test(BIT_MAX_LENGTH_CHANGED)) {
if (!all || maxLength_ > 0)
element.setAttribute("maxLength", std::to_string(maxLength_));
flags_.reset(BIT_MAX_LENGTH_CHANGED);
}
WFormWidget::updateDom(element, all);
}
示例9: validate
WValidator::Result WLengthValidator::validate(const WT_USTRING& input) const
{
if (input.empty())
return WValidator::validate(input);
#ifndef WT_TARGET_JAVA
#ifndef WT_NO_STD_WSTRING
std::wstring text = input.value();
#else
std::string text = input.narrow();
#endif
#else
std::string text = input;
#endif
if ((int)text.length() < minLength_)
return Result(Invalid, invalidTooShortText());
else if ((int)text.length() > maxLength_)
return Result(Invalid, invalidTooLongText());
else
return Result(Valid);
}