本文整理汇总了C++中StringRef::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::IsEmpty方法的具体用法?C++ StringRef::IsEmpty怎么用?C++ StringRef::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringRef
的用法示例。
在下文中一共展示了StringRef::IsEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
IPAddress::IPAddress(StringRef ip, ushort port, bool isIP6 /*= false*/)
{
if (isIP6)
{
Memory::ClearZero(&mAddress6);
mAddress6.sin6_family = (int)SocketAddressFamily::IP6;
mAddress6.sin6_port = BitConverter::HostToNetwork(port);
if (!ip.IsEmpty()) //0.0.0.0 or "" to bind to any local ip
{
if (inet_pton(mAddress6.sin6_family, ip.c_str(), &mAddress6.sin6_addr) <= 0)
{
Log::AssertFailedFormat("Invalid ip6:{}", ip);
}
}
}
else
{
Memory::ClearZero(&mAddress);
mAddress.sin_family = (int)SocketAddressFamily::IP;
mAddress.sin_port = BitConverter::HostToNetwork(port);
if (!ip.IsEmpty())
{
if (inet_pton(mAddress.sin_family, ip.c_str(), &mAddress.sin_addr) <= 0)
{
Log::AssertFailedFormat("Invalid ip:{}", ip);
}
}
}
}
示例2: ReadToken
StringRef SirenTextParser::ReadToken(StringRef& refProto)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty())
{
return StringRef::Empty;
}
if (StdString::IsDigit(refProto[0]))
{
Log::FormatError("Token cannot begin with number:{}", refProto[0]);
return StringRef::Empty;
}
size_t tokenLength = 0;
size_t length = refProto.Length();
for (size_t i = 0; i < length - 1; ++i)
{
int c = refProto[i];
if (StdString::IsToken(c))
{
++tokenLength;
}
else
{
break;
}
}
StringRef token = refProto.SubString(0, tokenLength);
refProto = refProto.SubString(tokenLength);
return token;
}
示例3: ReadAllData
MemoryData ZipReader::ReadAllData(StringRef fileName)const
{
MemoryData result;
if (mZipFile==nullptr||fileName.IsEmpty())
{
return result;
}
const ZipFileInfo* zipEntryInfo=mFileDict.TryGetByOtherKey(fileName,fileName.HashCode());
if (zipEntryInfo==nullptr)
{
return result;
}
int err = unzGoToFilePos(mZipFile, (unz_file_pos*)&zipEntryInfo->Pos);
if (err!=UNZ_OK)
{
return result;
}
err = unzOpenCurrentFile(mZipFile);
if (err!=UNZ_OK)
{
return result;
}
result=MemoryData::Alloc(zipEntryInfo->UncompressedSize);
int readSize = unzReadCurrentFile(mZipFile, result.MutableData(), (uint)zipEntryInfo->UncompressedSize);
Log::Assert(readSize==(int)zipEntryInfo->UncompressedSize,"Invalid zip file size."); //readSize could be 0 because we may have zero file such as "StringTable-enus.bin"
unzCloseCurrentFile(mZipFile);
return result;
}
示例4: ToBool
bool StringPropertySet::ToBool(const StringRef& key, bool optional /*= false*/) const
{
StringRef val = Get(key);
if (val.IsEmpty())
{
return optional;
}
return StringParser::StringTo<bool>(val);
}
示例5: ReadExpectedChar
bool SirenTextParser::ReadExpectedChar(StringRef& refProto, char val)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty() || refProto[0] != val)
{
return false;
}
refProto = refProto.SubString(1);
return true;
}
示例6: ReadNextPrintChar
char SirenTextParser::ReadNextPrintChar(StringRef& refProto)
{
refProto = refProto.TrimBegin();
if (refProto.IsEmpty())
{
return '\0';
}
char c = refProto[0];
refProto = refProto.SubString(1);
return c;
}
示例7: IsBitmapFont
bool FontId::IsBitmapFont(const StringRef& name)
{
if (name.IsEmpty())
{
return false;
}
auto ext = Path::GetExtension(name);
if (ext == ".pvr" || ext == "fnt")
{
return true;
}
return false;
}
示例8: Parse
bool TiledImage::Parse(const pugi::xml_node& node)
{
// Read all the attribute into member variables.
mSource= FileId::ParseFrom(node.attribute("source").as_string(nullptr));
if (mSource.IsEmpty())
{
Log::AssertFailed("Invalid image xml node source attribute");
return false;
}
mSize.Width = node.attribute("width").as_int(0);
mSize.Height = node.attribute("height").as_int(0);
const char* transparentColorStr = node.attribute("trans").as_string(nullptr);
mTransparentColor = TiledMap::ParseColor(transparentColorStr);
StringRef formatStr = node.attribute("format").as_string(nullptr);
if (formatStr == "png")
{
mEmbeddedFileType=FileType::png;
}
else if (formatStr == "jpg")
{
mEmbeddedFileType=FileType::jpeg;
}
else if (!formatStr.IsEmpty())
{
Log::FormatError("Unsupported image type:{}", formatStr.c_str());
return false;
}
pugi::xml_node dataNode = node.child("data");
if (!dataNode.empty())
{
StringRef encodingStr = node.attribute("encoding").as_string(nullptr);
StringRef compressionStr = node.attribute("compression").as_string(nullptr);
if (encodingStr != "base64")
{
Log::FormatError("Unsupported encoding type:{}", encodingStr.c_str());
return false;
}
const char* text = dataNode.value();
Base64Decoder decoder;
mEmbeddedImageData = decoder.Code(text);
}
return true;
}
示例9: DeleteWork
void ThreadPool::DeleteWork(ThreadPoolWork* work)
{
RETURN_IF_NULL(work);
StringRef name = work->Name();
if (name.IsEmpty())
{
mUnnamedWorks.Remove(work);
}
else
{
mNamedWorks.RemoveKey(name);
}
SAFE_RELEASE(work);
}
示例10: LoadFromData
bool BehaviorConfig::LoadFromData(const FileIdRef& fileId, const MemoryData& data, uint format /*= 0*/)
{
Unload();
RETURN_FALSE_IF(data.IsNull());
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_buffer(data.Data(), data.Size());
if (!result)
{
Log::AssertFailedFormat("Cannot parse xml:{} because {}", fileId, result.description());
return false;
}
for (const auto& child : doc.first_child().children())
{
StringRef typeName = child.name();
StringRef id = child.attribute("Id").value();
if (id.IsEmpty())
{
id = typeName;
}
#ifdef MEDUSA_SAFE_CHECK
if (ContainsId(id))
{
Log::AssertFailedFormat("Duplicate id:{} in {}", id.c_str(), typeName.c_str());
}
#endif
IBehavior* behavior = BehaviorFactory::Instance().SmartCreate(typeName);
behavior->LoadFromXmlNode(child);
behavior->Initialize();
if (id.EndWith("Behavior"))
{
Add(id, behavior);
}
else
{
Add(id + "Behavior", behavior);
}
}
return true;
}
示例11: LoadFromXmlNode
bool IActBehavior::LoadFromXmlNode(pugi::xml_node node)
{
RETURN_FALSE_IF_FALSE(IBehavior::LoadFromXmlNode(node));
StringRef typeName = node.name();
StringRef predicateId = node.attribute("Predicate").value();
if (!predicateId.IsEmpty())
{
Log::FormatError("Invalid predicate:{} on {}", predicateId.c_str(), typeName.c_str());
return false;
}
if (node.first_child() != nullptr)
{
Log::FormatError("Act behavior cannot have children. {}", typeName.c_str());
return false;
}
return true;
}
示例12: SetAttachment
void SkeletonSlot::SetAttachment(const StringRef& attachmentName)
{
if (attachmentName.IsEmpty())
{
SetAttachment(nullptr);
return;
}
if (mAttachment != nullptr&&mAttachment->Name() == attachmentName)
{
return;
}
ISkeletonAttachmentModel* attachment = mSkeleton->AvatarModel()->FindAttachment(mModel, attachmentName);
if (attachment == nullptr)
{
Log::AssertFailedFormat("Cannot find slot attachment:{}", attachmentName.c_str());
return;
}
SetAttachment(attachment);
}
示例13: RemoveAllChilds
void INode::RemoveAllChilds(NodeRemoveFlags flags /*= NodeRemoveFlags::OnlyChildren*/)
{
RETURN_IF_EMPTY(mNodes);
if (mManagedNodes.Count() == mNodes.Count())
{
flags = NodeRemoveFlags::All;
}
bool hasManaged = !mManagedNodes.IsEmpty();
switch (flags.ToInt())
{
case NodeRemoveFlags::OnlyChildren.IntValue:
if (hasManaged)
{
List<size_t> removedIndices;
size_t count = mNodes.Count();
FOR_EACH_SIZE(i, count)
{
INode* node = mNodes[i];
if (!mManagedNodes.Contains(node))
{
node->SetParent(nullptr);
removedIndices.Add(i);
StringRef name = node->Name();
if (!name.IsEmpty())
{
mNodeDict.RemoveKey(name);
}
}
}
mNodes.RemoveIndexes(removedIndices);
}
else
{