本文整理汇总了C++中nglString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ nglString::GetLength方法的具体用法?C++ nglString::GetLength怎么用?C++ nglString::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nglString
的用法示例。
在下文中一共展示了nglString::GetLength方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetConstraint
void nuiLayout::SetConstraint(nuiWidget* pWidget, const nglString& rDescription)
{
nuiLayoutConstraint constraintH, constraintV;
int pos = rDescription.Find('/');
if (pos < 0)
{
nglString desc(rDescription);
desc.Trim();
constraintH.Set(desc);
}
else if (pos == 0)
{
nglString desc2 = rDescription.Extract(pos+1, rDescription.GetLength() - (pos + 1));
desc2.Trim();
constraintV.Set(desc2);
}
else
{
nglString desc1 = rDescription.Extract(0, pos);
nglString desc2 = rDescription.Extract(pos+1, rDescription.GetLength() - (pos + 1));
desc1.Trim();
desc2.Trim();
constraintH.Set(desc1);
constraintV.Set(desc2);
}
SetConstraint(pWidget, constraintH, constraintV);
}
示例2: MIN
// Stolen from nglPath!
static int32 GetRootPart(const nglString& rStr)
{
if (rStr[0] == _T('/'))
{
if (rStr[1] != _T('/'))
return 1;
// //host[/path] (network address)
// or /volume[/path] (standard unix like path)
int32 end = rStr.Find(_T('/'), 2);
return ((end > 0) ? end : rStr.GetLength());
}
// Find the protocol name:
int col = rStr.Find(_T("://"), 0, true);
return MIN(col + 3, rStr.GetLength());
}
示例3: Canonize
static bool Canonize(nglString& rStr)
{
nglString canon;
int32 len = rStr.GetLength();
int32 root_part = GetRootPart(rStr);
int32 last_slash = root_part;
int32 slash = 0;
canon = rStr.GetLeft(root_part);
while (slash < len)
{
slash = rStr.Find(_T('/'), last_slash);
if (slash == - 1)
slash = len;
if (((slash - last_slash) == 1) && (rStr.GetChar(last_slash) == _T('.')))
{
// Ignore '.'
}
else
if (((slash - last_slash) == 2) && (!rStr.Compare(_T(".."), last_slash, 2)))
{
// Interpret '..'
int32 prev_slash = canon.FindLast(_T('/'));
if (prev_slash < root_part)
prev_slash = root_part;
if (!canon.IsEmpty() && canon.Compare(_T(".."), canon.GetLength() - 2, 2))
canon.Delete(prev_slash);
else
{
if (canon.GetLength() > root_part)
canon += _T('/');
canon += _T("..");
}
}
else
{
// Simply append path node
nglString node = rStr.Extract(last_slash, (slash - last_slash));
if (canon.GetLength() > root_part)
canon += _T('/');
canon += node;
}
last_slash = slash + 1;
}
rStr = canon;
return true;
}
示例4: SetClipboard
bool nglKernel::SetClipboard(const nglString& rString)
{
if (OpenClipboard(mHWnd))
{
EmptyClipboard();
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, rString.GetLength()+1);
if (hglbCopy == NULL)
{
CloseClipboard();
return false;
}
char* lptstrCopy = (char*)GlobalLock(hglbCopy);
memcpy(lptstrCopy, rString.GetChars(), rString.GetLength()+1);
GlobalUnlock(hglbCopy);
SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard();
return true;
}
return false;
}
示例5: ExtensionMatch
bool nglImageCodecInfo::ExtensionMatch(nglString& rFileName)
{
std::vector<nglString>::iterator ext;
int filename_len = rFileName.GetLength();
for (ext = mExtensions.begin(); ext < mExtensions.end(); ++ext)
{
int ext_size = (*ext).GetLength();
if (!rFileName.Compare (*ext, filename_len - ext_size, ext_size, false))
return true;
}
return false;
}
示例6: OnOutput
void nglConsole::OnOutput(const nglString& rText)
{
// 'char' mode : string buffer is considered to use the locale's encoding
Append(rText.GetChars());
// Write to the standard win32 console:
#ifdef USE_STANDARD_WIN32_CONSOLE
unsigned long res = 0;
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),rText.GetChars(),rText.GetLength(),&res,NULL);
#endif
// I don't care if this is slow, its really mandatory in win32.
vector<nglString> vec;
uint ret=rText.Tokenize(vec, _T('\n'));
for (uint i=0; i<ret; i++)
{
OutputDebugString(vec[i].GetChars()); // fixme! to be removed ?
OutputDebugString(_T("\n"));
}
}
示例7: GetHistory
int nglConsole::GetHistory (list<const nglString*>& rMatches, nglString& rFilter, bool IsCaseSensitive)
{
#if NGL_DISABLE_CONSOLE
return 0;
#else
int count = 0;
list<nglString*>::reverse_iterator h_entry;
list<nglString*>::reverse_iterator h_begin = mHistory.rbegin();
rMatches.clear();
int size = rFilter.GetLength();
for (h_entry = mHistory.rend(); h_entry != h_begin; h_entry--)
if (!rFilter.Compare(**h_entry, 0, size, IsCaseSensitive))
{
rMatches.push_front(*h_entry);
count++;
}
return count;
#endif
}
示例8: AddToHistory
void nglConsole::AddToHistory (const nglString& rLine)
{
#if NGL_DISABLE_CONSOLE
return;
#else
nglString* newline;
uint new_linecnt, new_charcnt;
if (!mUseHistory) return;
// Filter empty lines
nglString trimmed = rLine;
trimmed.Trim();
if (trimmed.GetLength() == 0) return;
new_linecnt = mLineCnt + 1;
new_charcnt = mCharCnt + rLine.GetLength();
// Adjust history size according user-set limits
while ((!mHistory.empty()) &&
(((mLineMax > 0) && (new_linecnt > mLineMax)) ||
((mCharMax > 0) && (new_charcnt > mCharMax))))
{
list<nglString*>::iterator tail = mHistory.end();
tail--; // mHistory.end() return an iterator just past the last element
if (*tail)
{
new_charcnt -= (*tail)->GetLength();
new_linecnt--;
delete (*tail);
mHistory.erase (tail);
}
}
newline = new nglString (rLine);
mHistory.push_front (newline);
mLineCnt = new_linecnt;
mCharCnt = new_charcnt;
#endif
}
示例9: nuiSplitText
bool nuiSplitText(const nglString& rSourceString, nuiTextRangeList& rRanges, nuiSplitTextFlag flags)
{
uint32 size = rSourceString.GetLength();
rRanges.clear();
if (!size)
return true;
const bool scriptchange = flags & nuiST_ScriptChange;
const bool rangechange = flags & nuiST_RangeChange;
const bool wordboundary = flags & nuiST_WordBoundary;
const bool directionchange = flags & nuiST_DirectionChange;
const bool mergecommonscript = flags & nuiST_MergeCommonScript;
uint32 lastpos = 0;
uint32 curpos = 0;
const nglChar& ch = rSourceString[curpos];
int32 direction = nuiGetUnicodeDirection(ch);
int32 newdirection = direction;
nglChar scriptlow = 0;
nglChar scripthi = 0;
nuiUnicodeScript script = nuiGetUnicodeScript(ch, scriptlow, scripthi);
nuiUnicodeScript newscript = script;
nglChar rangelow = 0;
nglChar rangehi = 0;
nuiUnicodeRange range = nuiGetUnicodeRange(ch, rangelow, rangehi);
nuiUnicodeRange newrange = range;
bool blank = nuiIsUnicodeBlank(ch);
bool newblank = blank;
curpos++;
while (curpos != size)
{
bool brk = false;
const nglChar& ch = rSourceString[curpos];
if (wordboundary)
{
newblank = nuiIsUnicodeBlank(ch);
if (newblank != blank)
brk = true;
}
if (scriptchange)
{
if (ch < scriptlow || ch > scripthi) // still in the last range?
{
if (!wordboundary)
newblank = nuiIsUnicodeBlank(ch);
if (!newblank)
{
newscript = nuiGetUnicodeScript(ch, scriptlow, scripthi);
if ((newscript != script) && !(mergecommonscript && newscript == eScriptCommon))
{
brk = true;
}
}
}
}
if (rangechange)
{
if (ch < rangelow || ch > rangehi) // still in the last range?
{
if (!wordboundary)
newblank = nuiIsUnicodeBlank(ch);
if (!newblank)
{
newrange = nuiGetUnicodeRange(ch, rangelow, rangehi);
if (newrange != range)
brk = true;
}
}
}
if (directionchange)
{
newdirection = nuiGetUnicodeDirection(ch);
if (newdirection != direction)
brk = true;
}
if (brk)
{
nuiTextRange r;
r.mLength = curpos - lastpos; // count of unicode code points
r.mDirection = direction; // even: Left to right, odd: right to left
r.mScript = script; // What script if this range of text
r.mRange = range; // What script if this range of text
r.mBlank = blank; // Does this range contains strictly blank (space, tab, return, etc.) code points.
rRanges.push_back(r);
lastpos = curpos;
direction = newdirection;
script = newscript;
range = newrange;
blank = newblank;
//.........这里部分代码省略.........
示例10: Layout
bool nuiTextLayout::Layout(const nglString& rString)
{
// Transform the string in a vector of nglUChar, also keep the offsets from the original chars to the nglUChar and vice versa
int32 len = rString.GetLength();
int32 i = 0;
//printf("layout ");
while (i < len)
{
nglUChar ch = rString.GetNextUChar(i);
//printf("'%c' (%d) ", (char)ch, ch);
mUnicode.push_back(ch);
mOffsetInString.push_back(i);
mOffsetInUnicode.push_back(mUnicode.size() - 1);
}
//printf("\n");
// General algorithm:
// 1. Split text into paragraphs (LayoutText)
// 2. Split paragraphs into ranges (LayoutParagraph)
// 3. Split ranges into fonts
// 4. Split ranges into lines / words if needed
int32 start = 0;
int32 position = 0;
int32 count = mUnicode.size();
while (position < count)
{
// Scan through the text and look for end of line markers
nglUChar ch = mUnicode[position];
if (ch == '\n' || ch == 0xb || ch == 0x2028 || ch == 0x2029)
{
// Found a paragraph
//printf("Paragraph %d -> %d (%d chars)\n", start, position, position - start);
LayoutParagraph(start, position - start); // Eat the \n char
start = position + 1;
}
position++;
}
if (start < position)
{
//printf("last Paragraph %d -> %d (%d chars)\n", start, position, position - start);
LayoutParagraph(start, position - start); // Eat the \n char
start = position;
}
mAscender = 0;
mDescender = 0;
//printf("Map scripts to fonts:\n");
int32 c = 0;
// Find the needed fonts for each script:
std::map<nuiUnicodeScript, nuiFontBase*> FontSet;
{
std::map<nuiUnicodeScript, std::set<nglUChar> >::iterator it = mCharsets.begin();
std::map<nuiUnicodeScript, std::set<nglUChar> >::iterator end = mCharsets.end();
while (it != end)
{
//printf("%d %s -> ", c, nuiGetUnicodeScriptName(it->first).GetChars());
const std::set<nglUChar>& charset(it->second);
nuiFontBase* pFont = NULL;
// First try the requested font
{
std::set<nglUChar>::const_iterator it = charset.begin();
std::set<nglUChar>::const_iterator end = charset.end();
while (it != end && mStyle.GetFont()->GetGlyphIndex(*it) > 0)
++it;
// If all the glyphs are available in the font we're done...
if (it == end)
pFont = mStyle.GetFont();
else
{
//printf("[couldn't find glyph %d '%c' in requested font] ", *it, *it);
}
}
// If the requested font doesn't work, try to find one that does:
if (!pFont)
{
nuiFontRequest request(mStyle.GetFont());
request.MustHaveGlyphs(charset, 500, false);
pFont = nuiFontManager::GetManager().GetFont(request);
}
FontSet[it->first] = pFont;
//printf("%s\n", pFont->GetFamilyName().GetChars());
++it;
c++;
}
}
//printf("Map scripts to fonts DONE\n");
i = 0;
nuiRect rect;
//.........这里部分代码省略.........
示例11: Send
int nuiTCPClient::Send(const nglString& rString)
{
return Send((uint8*)rString.GetChars(), rString.GetLength());
}
示例12: Write
size_t nuiPipe::Write(const nglString& rString)
{
return Write((const uint8*)rString.GetChars(), rString.GetLength());
}
示例13: BufferedSend
size_t nuiTCPClient::BufferedSend(const nglString& rString, bool BufferOnly)
{
return BufferedSend((uint8*)rString.GetChars(), rString.GetLength(), BufferOnly);
}
示例14: Send
bool AMXClient::Send(const nglString& rData)
{
return (mpClient->Send(rData) == rData.GetLength());
}