本文整理汇总了C++中mgString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ mgString::length方法的具体用法?C++ mgString::length怎么用?C++ mgString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mgString
的用法示例。
在下文中一共展示了mgString::length方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCursorX
//--------------------------------------------------------------
// get cursor X coordinate
int mgSimpleField::getCursorX(
const mgString& displayStr)
{
int cursorX = 0;
int posn = m_cursorPosn - m_scrollPosn;
// if cursor position within displayed text
if (posn <= displayStr.length())
{
// measure string from scroll position up to cursor
cursorX = m_font->stringWidth(displayStr, posn);
}
else
{
// measure string from scroll position, plus blanks to cursor position
cursorX = m_font->stringWidth(displayStr, displayStr.length());
cursorX += m_font->stringWidth(" ", 1) * (posn - displayStr.length());
}
return cursorX;
}
示例2: mgOSResolveRelativeName
//--------------------------------------------------------------
// resolve possibly relative file name.
void mgOSResolveRelativeName(
const char* sourceFile,
const char* relName,
mgString& absName)
{
mgString name(relName);
mgOSFixFileName(name);
// if relative name starts with /, we're done
if (name.startsWith("/"))
{
absName = name;
return;
}
// assume it's really relative. strip last directory in source file
absName = sourceFile;
int lastSlash = absName.reverseFind(absName.length(), "/");
if (lastSlash != -1)
absName.deleteAt(lastSlash+1, absName.length()-(lastSlash+1));
else absName.empty(); // source file has no dir
absName += name;
}
示例3: mgOSFixFileName
//--------------------------------------------------------------
// set slashes appropriately for OS
void mgOSFixFileName(
mgString& name)
{
name.trim();
// convert any backslashes to forward slashes
mgString bs("/");
char letter[MG_MAX_LETTER];
int posn = 0;
while (posn < name.length())
{
int next = name.nextLetter(posn, letter);
if (strcmp(letter, "\\") == 0)
next = name.setLetter(posn, bs);
posn = next;
}
}