本文整理汇总了C++中StringView::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ StringView::isEmpty方法的具体用法?C++ StringView::isEmpty怎么用?C++ StringView::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringView
的用法示例。
在下文中一共展示了StringView::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseField
bool AbstractParser::parseField(StringView words)
{
#define PARSE_FIELD(X) \
for (const auto x : DEFINED_ROOM_##X##_TYPES) { \
if (getParserCommandName(x).matches(firstWord)) { \
setRoomFieldCommand(x, RoomField::X##_TYPE); \
return true; \
} \
}
if (words.isEmpty())
return false;
// REVISIT: support "set room field XXX" ?
const auto firstWord = words.takeFirstWord();
if (!words.isEmpty())
return false;
PARSE_FIELD(LIGHT);
PARSE_FIELD(SUNDEATH);
PARSE_FIELD(PORTABLE);
PARSE_FIELD(RIDABLE);
PARSE_FIELD(ALIGN);
return false;
#undef PARSE
}
示例2: parseName
void AbstractParser::parseName(StringView view)
{
if (!view.isEmpty()) {
auto dir = tryGetDir(view);
if (!view.isEmpty()) {
auto name = view.takeFirstWord();
nameDoorCommand(name.toQString(), dir);
return;
}
}
showSyntax("name <dir> <name>");
}
示例3: lexIdentifier
IDBKeyPathLexer::TokenType IDBKeyPathLexer::lexIdentifier(String& element)
{
StringView start = m_remainingText;
if (!m_remainingText.isEmpty() && isIdentifierStartCharacter(m_remainingText[0]))
m_remainingText = m_remainingText.substring(1);
else
return TokenError;
while (!m_remainingText.isEmpty() && isIdentifierCharacter(m_remainingText[0]))
m_remainingText = m_remainingText.substring(1);
element = start.substring(0, start.length() - m_remainingText.length()).toString();
return TokenIdentifier;
}
示例4: remove
void Settings::remove(const StringView& _name) const
{
ini_t* ini = INI_T(m_ini);
FilePath uri(_name);
const StringView path = strTrim(uri.getPath(), "/");
const StringView& fileName = uri.getFileName();
int32_t section = INI_GLOBAL_SECTION;
if (!path.isEmpty() )
{
section = ini_find_section(ini, path.getPtr(), path.getLength() );
if (INI_NOT_FOUND == section)
{
section = INI_GLOBAL_SECTION;
}
}
int32_t property = ini_find_property(ini, section, fileName.getPtr(), fileName.getLength() );
if (INI_NOT_FOUND == property)
{
return;
}
ini_property_remove(ini, section, property);
if (INI_GLOBAL_SECTION != section
&& 0 == ini_property_count(ini, section) )
{
ini_section_remove(ini, section);
}
}
示例5: get
const char* Settings::get(const StringView& _name) const
{
ini_t* ini = INI_T(m_ini);
FilePath uri(_name);
const StringView path(strTrim(uri.getPath(), "/") );
const StringView& fileName(uri.getFileName() );
int32_t section = INI_GLOBAL_SECTION;
if (!path.isEmpty() )
{
section = ini_find_section(ini, path.getPtr(), path.getLength() );
if (INI_NOT_FOUND == section)
{
section = INI_GLOBAL_SECTION;
}
}
int32_t property = ini_find_property(ini, section, fileName.getPtr(), fileName.getLength() );
if (INI_NOT_FOUND == property)
{
return NULL;
}
return ini_property_value(ini, section, property);
}
示例6: encodingFromMetaAttributes
TextEncoding HTMLMetaCharsetParser::encodingFromMetaAttributes(const AttributeList& attributes)
{
bool gotPragma = false;
enum { None, Charset, Pragma } mode = None;
StringView charset;
for (auto& attribute : attributes) {
const String& attributeName = attribute.first;
const String& attributeValue = attribute.second;
if (attributeName == http_equivAttr) {
if (equalIgnoringCase(attributeValue, "content-type"))
gotPragma = true;
} else if (charset.isEmpty()) {
if (attributeName == charsetAttr) {
charset = attributeValue;
mode = Charset;
} else if (attributeName == contentAttr) {
charset = extractCharset(attributeValue);
if (charset.length())
mode = Pragma;
}
}
}
if (mode == Charset || (mode == Pragma && gotPragma))
return TextEncoding(stripLeadingAndTrailingHTMLSpaces(charset.toStringWithoutCopying()));
return TextEncoding();
}
示例7: setWindowFeature
static void setWindowFeature(WindowFeatures& features, StringView key, StringView value)
{
// Listing a key with no value is shorthand for key=yes
int numericValue;
if (value.isEmpty() || equalLettersIgnoringASCIICase(value, "yes"))
numericValue = 1;
else
numericValue = value.toInt();
// We treat key of "resizable" here as an additional feature rather than setting resizeable to true.
// This is consistent with Firefox, but could also be handled at another level.
if (equalLettersIgnoringASCIICase(key, "left") || equalLettersIgnoringASCIICase(key, "screenx"))
features.x = numericValue;
else if (equalLettersIgnoringASCIICase(key, "top") || equalLettersIgnoringASCIICase(key, "screeny"))
features.y = numericValue;
else if (equalLettersIgnoringASCIICase(key, "width") || equalLettersIgnoringASCIICase(key, "innerwidth"))
features.width = numericValue;
else if (equalLettersIgnoringASCIICase(key, "height") || equalLettersIgnoringASCIICase(key, "innerheight"))
features.height = numericValue;
else if (equalLettersIgnoringASCIICase(key, "menubar"))
features.menuBarVisible = numericValue;
else if (equalLettersIgnoringASCIICase(key, "toolbar"))
features.toolBarVisible = numericValue;
else if (equalLettersIgnoringASCIICase(key, "location"))
features.locationBarVisible = numericValue;
else if (equalLettersIgnoringASCIICase(key, "status"))
features.statusBarVisible = numericValue;
else if (equalLettersIgnoringASCIICase(key, "fullscreen"))
features.fullscreen = numericValue;
else if (equalLettersIgnoringASCIICase(key, "scrollbars"))
features.scrollbarsVisible = numericValue;
else if (numericValue == 1)
features.additionalFeatures.append(key.toString());
}
示例8: parseDirections
void AbstractParser::parseDirections(StringView view)
{
if (view.isEmpty())
showSyntax("dirs [-(name|desc|dyncdesc|note|exits|all)] pattern");
else
doGetDirectionsCommand(view);
}
示例9: resolveRelativeVirtualPath
// https://wicg.github.io/entries-api/#resolve-a-relative-path
static String resolveRelativeVirtualPath(StringView baseVirtualPath, StringView relativeVirtualPath)
{
ASSERT(baseVirtualPath[0] == '/');
if (!relativeVirtualPath.isEmpty() && relativeVirtualPath[0] == '/')
return relativeVirtualPath.length() == 1 ? relativeVirtualPath.toString() : resolveRelativeVirtualPath("/", relativeVirtualPath.substring(1));
Vector<StringView> virtualPathSegments;
for (auto segment : baseVirtualPath.split('/'))
virtualPathSegments.append(segment);
for (auto segment : relativeVirtualPath.split('/')) {
ASSERT(!segment.isEmpty());
if (segment == ".")
continue;
if (segment == "..") {
if (!virtualPathSegments.isEmpty())
virtualPathSegments.removeLast();
continue;
}
virtualPathSegments.append(segment);
}
if (virtualPathSegments.isEmpty())
return "/"_s;
StringBuilder builder;
for (auto& segment : virtualPathSegments) {
builder.append('/');
builder.append(segment);
}
return builder.toString();
}
示例10: parseSearch
void AbstractParser::parseSearch(StringView view)
{
if (view.isEmpty())
showSyntax("search [-(name|desc|dyncdesc|note|exits|all)] pattern");
else
doSearchCommand(view);
}
示例11: parseWindowFeatures
WindowFeatures parseWindowFeatures(StringView featuresString)
{
// The IE rule is: all features except for channelmode and fullscreen default to YES, but
// if the user specifies a feature string, all features default to NO. (There is no public
// standard that applies to this method.)
//
// <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>
// We always allow a window to be resized, which is consistent with Firefox.
WindowFeatures features;
if (featuresString.isEmpty())
return features;
features.menuBarVisible = false;
features.statusBarVisible = false;
features.toolBarVisible = false;
features.locationBarVisible = false;
features.scrollbarsVisible = false;
processFeaturesString(featuresString, [&features](StringView key, StringView value) {
setWindowFeature(features, key, value);
});
return features;
}
示例12: parseExitFlag
bool AbstractParser::parseExitFlag(const ExitFlag flag, StringView words)
{
const auto dir = tryGetDir(words);
if (!words.isEmpty())
return false;
toggleExitFlagCommand(flag, dir);
return true;
}
示例13: parseLoadFlags
bool AbstractParser::parseLoadFlags(StringView words)
{
if (words.isEmpty())
return false;
const auto firstWord = words.takeFirstWord();
if (!words.isEmpty())
return false;
for (const RoomLoadFlag loadFlag : ALL_LOAD_FLAGS) {
if (getParserCommandName(loadFlag).matches(firstWord)) {
toggleRoomFlagCommand(loadFlag, RoomField::LOAD_FLAGS);
return true;
}
}
return false;
}
示例14: parseDoorAction
bool AbstractParser::parseDoorAction(const DoorActionType dat, StringView words)
{
const auto dir = tryGetDir(words);
if (!words.isEmpty())
return false;
performDoorCommand(dir, dat);
return true;
}
示例15: parseGroupTell
void AbstractParser::parseGroupTell(const StringView &view)
{
if (view.isEmpty())
sendToUser("What do you want to tell the group?\r\n");
else {
emit sendGroupTellEvent(view.toQByteArray());
sendToUser("OK.\r\n");
}
}