本文整理汇总了C++中st::string::left方法的典型用法代码示例。如果您正苦于以下问题:C++ string::left方法的具体用法?C++ string::left怎么用?C++ string::left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st::string
的用法示例。
在下文中一共展示了string::left方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ILog
void plResponderModifier::ILog(uint32_t color, const char* format, ...)
{
#ifdef STATUS_LOG
if (!gLog)
gLog = plStatusLogMgr::GetInstance().CreateStatusLog(15, "Responder", plStatusLog::kFilledBackground | plStatusLog::kDeleteForMe | plStatusLog::kDontWriteFile | plStatusLog::kAlignToTop);
if (!format || *format == '\0')
return;
ST::string keyName = GetKeyName();
// Make sure this key isn't in our list of keys to deny
for (const auto& it : gNoLogStrings) {
if (keyName.starts_with(it))
return;
}
// Format the log text
char buf[256];
va_list args;
va_start(args, format);
int numWritten = hsVsnprintf(buf, sizeof(buf), format, args);
hsAssert(numWritten > 0, "Buffer too small");
va_end(args);
// Strip the redundant part off the key name
ST_ssize_t modPos = keyName.find("_ResponderModifier");
if (modPos != -1)
keyName = keyName.left(modPos);
ST::string logLine = ST::format("{}: {}", keyName, buf);
gLog->AddLine(logLine.c_str(), color);
#endif // STATUS_LOG
}
示例2: cdUp
ST::string cdUp(ST::string path) {
// Check for root paths, we can't go up from there!
#ifdef _WIN32
if (path.substr(1) == ":\\")
return path;
#else
if (path == "/")
return path;
#endif
// Not very robust, but it works for one level of parent scanning
if (path.is_empty())
return ".." PATHSEPSTR;
// Strip the ending slash, if necessary, and then go up one dir
if (path.char_at(path.size()-1) == PATHSEP)
path = path.left(path.size() - 1);
ST::string up = path.before_last(PATHSEP);
if (path.char_at(0) == PATHSEP) {
// Absolute path specified -- make sure we keep it that way
return up + PATHSEPSTR;
} else {
// Relative path specified
return up.is_empty() ? "" : up + PATHSEPSTR;
}
}
示例3: getOutputDir
ST::string getOutputDir(const ST::string& filename, plPageInfo* page) {
ST::string odir = filename;
ST_ssize_t sepLoc = odir.find_last(PATHSEP);
if (sepLoc < 0)
odir = ST::string();
else
odir = odir.left(sepLoc + 1);
return odir + ST::format("{}_{}_PRP" PATHSEPSTR, page->getAge(), page->getPage());
}