本文整理汇总了C++中LLWString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ LLWString::length方法的具体用法?C++ LLWString::length怎么用?C++ LLWString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLWString
的用法示例。
在下文中一共展示了LLWString::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stripChannelNumber
// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20.
// Otherwise returns input and channel 0.
LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel)
{
if (mesg[0] == '/'
&& mesg[1] == '/')
{
// This is a "repeat channel send"
*channel = mLastSpecialChatChannel;
return mesg.substr(2, mesg.length() - 2);
}
else if (mesg[0] == '/'
&& mesg[1]
&& ( LLStringOps::isDigit(mesg[1])
// <edit>
|| mesg[1] == '-' ))
// </edit>
{
// This a special "/20" speak on a channel
S32 pos = 0;
// <edit>
if(mesg[1] == '-')
pos++;
// </edit>
// Copy the channel number into a string
LLWString channel_string;
llwchar c;
do
{
c = mesg[pos+1];
channel_string.push_back(c);
pos++;
}
while(c && pos < 64 && LLStringOps::isDigit(c));
// Move the pointer forward to the first non-whitespace char
// Check isspace before looping, so we can handle "/33foo"
// as well as "/33 foo"
while(c && iswspace(c))
{
c = mesg[pos+1];
pos++;
}
mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10);
// <edit>
if(mesg[1] == '-')
mLastSpecialChatChannel = -mLastSpecialChatChannel;
// </edit>
*channel = mLastSpecialChatChannel;
return mesg.substr(pos, mesg.length() - pos);
}
else
{
// This is normal chat.
*channel = 0;
return mesg;
}
}
示例2: addLabel
void LLHUDNameTag::addLabel(const std::string& label_utf8)
{
LLWString wstr = utf8string_to_wstring(label_utf8);
if (!wstr.empty())
{
LLWString seps(utf8str_to_wstring("\r\n"));
LLWString empty;
typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer;
boost::char_separator<llwchar> sep(seps.c_str(), empty.c_str(), boost::keep_empty_tokens);
tokenizer tokens(wstr, sep);
tokenizer::iterator iter = tokens.begin();
while (iter != tokens.end())
{
U32 line_length = 0;
do
{
S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(),
HUD_TEXT_MAX_WIDTH, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
LLHUDTextSegment segment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor, mFontp);
mLabelSegments.push_back(segment);
line_length += segment_length;
}
while (line_length != iter->size());
++iter;
}
}
}
示例3: locale
bool validateNonNegativeS32(const LLWString &str)
{
LLLocale locale(LLLocale::USER_LOCALE);
LLWString trimmed = str;
LLWStringUtil::trim(trimmed);
S32 len = trimmed.length();
bool success = TRUE;
if(0 < len)
{
if('-' == trimmed[0])
{
success = FALSE;
}
S32 i = 0;
while(success && (i < len))
{
if(!LLStringOps::isDigit(trimmed[i++]))
{
success = FALSE;
}
}
}
if (success)
{
S32 val = strtol(wstring_to_utf8str(trimmed).c_str(), NULL, 10);
if (val < 0)
{
success = FALSE;
}
}
return success;
}
示例4: validateASCIIPrintableNoPipe
// Used for most names of things stored on the server, due to old file-formats
// that used the pipe (|) for multiline text storage. Examples include
// inventory item names, parcel names, object names, etc.
bool validateASCIIPrintableNoPipe(const LLWString &str)
{
bool rv = TRUE;
S32 len = str.length();
if(len == 0) return rv;
while(len--)
{
llwchar wc = str[len];
if (wc < 0x20
|| wc > 0x7f
|| wc == '|')
{
rv = FALSE;
break;
}
if(!(wc == ' '
|| LLStringOps::isAlnum((char)wc)
|| LLStringOps::isPunct((char)wc) ) )
{
rv = FALSE;
break;
}
}
return rv;
}
示例5: validateInt
// Limits what characters can be used to [1234567890-] with [-] only valid in the first position.
// Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
// the simple reasons that intermediate states may be invalid even if the final result is valid.
//
bool validateInt(const LLWString &str)
{
LLLocale locale(LLLocale::USER_LOCALE);
bool success = TRUE;
LLWString trimmed = str;
LLWStringUtil::trim(trimmed);
S32 len = trimmed.length();
if( 0 < len )
{
S32 i = 0;
// First character can be a negative sign
if( '-' == trimmed[0] )
{
i++;
}
for( ; i < len; i++ )
{
if( !LLStringOps::isDigit( trimmed[i] ) )
{
success = FALSE;
break;
}
}
}
return success;
}
示例6: validateFloat
// Limits what characters can be used to [1234567890.-] with [-] only valid in the first position.
// Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
// the simple reasons that intermediate states may be invalid even if the final result is valid.
//
bool validateFloat(const LLWString &str)
{
LLLocale locale(LLLocale::USER_LOCALE);
bool success = TRUE;
LLWString trimmed = str;
LLWStringUtil::trim(trimmed);
S32 len = trimmed.length();
if( 0 < len )
{
// May be a comma or period, depending on the locale
llwchar decimal_point = (llwchar)LLResMgr::getInstance()->getDecimalPoint();
S32 i = 0;
// First character can be a negative sign
if( '-' == trimmed[0] )
{
i++;
}
for( ; i < len; i++ )
{
if( (decimal_point != trimmed[i] ) && !LLStringOps::isDigit( trimmed[i] ) )
{
success = FALSE;
break;
}
}
}
return success;
}
示例7: addLine
void LLFixedBuffer::addLine(const LLWString& line)
{
if (line.empty())
{
return;
}
removeExtraLines();
mLines.push_back(line);
mLineLengths.push_back((S32)line.length());
mAddTimes.push_back(mTimer.getElapsedTimeF32());
}
示例8: validateASCIIWithNewLine
// Used for multiline text stored on the server.
// Example is landmark description in Places SP.
bool validateASCIIWithNewLine(const LLWString &str)
{
bool rv = TRUE;
S32 len = str.length();
while(len--)
{
if ((str[len] < 0x20 && str[len] != 0xA) || str[len] > 0x7f)
{
rv = FALSE;
break;
}
}
return rv;
}
示例9: validateASCII
bool validateASCII(const LLWString &str)
{
bool rv = TRUE;
S32 len = str.length();
while(len--)
{
if (str[len] < 0x20 || str[len] > 0x7f)
{
rv = FALSE;
break;
}
}
return rv;
}
示例10: validateAlphaNumSpace
bool validateAlphaNumSpace(const LLWString &str)
{
LLLocale locale(LLLocale::USER_LOCALE);
bool rv = TRUE;
S32 len = str.length();
if(len == 0) return rv;
while(len--)
{
if(!(LLStringOps::isAlnum((char)str[len]) || (' ' == str[len])))
{
rv = FALSE;
break;
}
}
return rv;
}
示例11: addQueuedLines
void LLConsole::addQueuedLines()
{
for (line_queue_t::iterator iter = mLineQueue.begin();
iter != mLineQueue.end(); ++iter)
{
LineInfo& line_info = *iter;
LLWString wline = line_info.wline;
//F32 size = line_info.size;
LLColor4 color = line_info.color;
if (!wline.empty() && mFont != NULL)
{
// Wrap lines that are longer than the view is wide.
S32 offset = 0;
while( offset < (S32)wline.length() )
{
S32 skip_chars; // skip '\n'
// Figure out if a word-wrapped line fits here.
LLWString::size_type line_end = wline.find_first_of(llwchar('\n'), offset);
if (line_end != LLWString::npos)
{
skip_chars = 1; // skip '\n'
}
else
{
line_end = wline.size();
skip_chars = 0;
}
U32 drawable = mFont->maxDrawableChars(wline.c_str()+offset, (F32)mRect.getWidth(), line_end-offset, TRUE);
if (drawable != 0)
{
LLFixedBuffer::addLine(wline.substr(offset, drawable));
mAddTimes[mAddTimes.size()-1] = line_info.add_time;
}
else
{
// force a blank line
LLFixedBuffer::addLine(" ");
}
mColors.push_back(color);
offset += (drawable + skip_chars);
}
}
}
mLineQueue.clear();
}
示例12: copy
void DOHexEditor::copy()
{
if(!canCopy()) return;
std::string text;
if(mInData)
{
U32 start = getProperSelectionStart();
U32 end = getProperSelectionEnd();
for(U32 i = start; i < end; i++)
text.append(llformat("%02X", mValue[i]));
}
else
{
U32 start = getProperSelectionStart();
U32 end = getProperSelectionEnd();
for(U32 i = start; i < end; i++)
text.append(llformat("%c", mValue[i]));
}
LLWString wtext = utf8str_to_wstring(text);
gClipboard.copyFromSubstring(wtext, 0, wtext.length());
}
示例13: onBtnCopyToClipboard
// Checked: 2011-05-26 (RLVa-1.3.1c) | Added: RLVa-1.3.1c
void RlvFloaterBehaviours::onBtnCopyToClipboard() const
{
std::ostringstream strRestrictions;
strRestrictions << RlvStrings::getVersion() << "\n";
const RlvHandler::rlv_object_map_t* pObjects = gRlvHandler.getObjectMap();
for (RlvHandler::rlv_object_map_t::const_iterator itObj = pObjects->begin(), endObj = pObjects->end(); itObj != endObj; ++itObj)
{
strRestrictions << "\n" << rlvGetItemNameFromObjID(itObj->first) << ":\n";
const rlv_command_list_t* pCommands = itObj->second.getCommandList();
for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd)
{
std::string strOption; LLUUID idOption;
if ( (itCmd->hasOption()) && (idOption.set(itCmd->getOption(), FALSE)) && (idOption.notNull()) )
{
LLAvatarName avName;
if (gObjectList.findObject(idOption))
strOption = rlvGetItemNameFromObjID(idOption, true);
else if (LLAvatarNameCache::get(idOption, &avName))
strOption = (!avName.getAccountName().empty()) ? avName.getAccountName() : avName.getDisplayName();
else if (!gCacheName->getGroupName(idOption, strOption))
strOption = itCmd->getOption();
}
strRestrictions << " -> " << itCmd->asString();
if ( (!strOption.empty()) && (strOption != itCmd->getOption()) )
strRestrictions << " [" << strOption << "]";
if (RLV_RET_SUCCESS != itCmd->getReturnType())
strRestrictions << " (" << RlvStrings::getStringFromReturnCode(itCmd->getReturnType()) << ")";
strRestrictions << "\n";
}
}
LLWString wstrRestrictions = utf8str_to_wstring(strRestrictions.str());
gClipboard.copyFromSubstring(wstrRestrictions, 0, wstrRestrictions.length());
}
示例14: llmin
F32 LLFontGL::getWidthF32(const LLWString& utf32text, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
{
const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL;
const S32 max_index = llmin(llmax(max_chars, begin_offset + max_chars), S32(utf32text.length()));
if (max_index <= 0 || begin_offset >= max_index)
return 0;
F32 cur_x = 0;
const LLFontGlyphInfo* next_glyph = NULL;
F32 width_padding = 0.f;
for (S32 i = begin_offset; i < max_index; i++)
{
const llwchar wch = utf32text[i];
const embedded_data_t* ext_data = use_embedded ? getEmbeddedCharData(wch) : NULL;
if (ext_data)
{
// Handle crappy embedded hack
cur_x += getEmbeddedCharAdvance(ext_data);
if(i+1 < max_index)
{
cur_x += EXT_KERNING * sScaleX;
}
}
else
{
const LLFontGlyphInfo* fgi = next_glyph;
next_glyph = NULL;
if(!fgi)
{
fgi = mFontFreetype->getGlyphInfo(wch);
}
F32 advance = mFontFreetype->getXAdvance(fgi);
// for the last character we want to measure the greater of its width and xadvance values
// so keep track of the difference between these values for the each character we measure
// so we can fix things up at the end
width_padding = llmax( 0.f, // always use positive padding amount
width_padding - advance, // previous padding left over after advance of current character
(F32)(fgi->mWidth + fgi->mXBearing) - advance); // difference between width of this character and advance to next character
cur_x += advance;
if ((i + 1) < max_index)
{
llwchar next_char = utf32text[i+1];
if (next_char < LAST_CHARACTER)
{
// Kern this puppy.
next_glyph = mFontFreetype->getGlyphInfo(next_char);
cur_x += mFontFreetype->getXKerning(fgi, next_glyph);
}
}
// Round after kerning.
cur_x = (F32)ll_round(cur_x);
}
}
// add in extra pixels for last character's width past its xadvance
cur_x += width_padding;
return cur_x / sScaleX;
}
示例15: stripChannelNumber
// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20.
// Otherwise returns input and channel 0.
LLWString FSNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel, S32* last_channel, bool* is_set)
{
*is_set = false;
if (mesg[0] == '/'
&& mesg[1] == '/')
{
// This is a "repeat channel send"
*is_set = true;
*channel = *last_channel;
return mesg.substr(2, mesg.length() - 2);
}
else if (mesg[0] == '/'
&& mesg[1]
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
// (this code was here; documenting for the future)
//&& LLStringOps::isDigit(mesg[1]))
&& (LLStringOps::isDigit(mesg[1])
|| (mesg[1] == '-'
&& mesg[2]
&& LLStringOps::isDigit(mesg[2]))))
//</FS:TS> FIRE-11412
{
// This a special "/20" speak on a channel
*is_set = true;
S32 pos = 0;
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
// (this code was here; documenting for the future)
if (mesg[1] == '-')
{
pos++;
}
//</FS:TS> FIRE-11412
// Copy the channel number into a string
LLWString channel_string;
llwchar c;
do
{
c = mesg[pos + 1];
channel_string.push_back(c);
pos++;
}
while (c && pos < 64 && LLStringOps::isDigit(c));
// Move the pointer forward to the first non-whitespace char
// Check isspace before looping, so we can handle "/33foo"
// as well as "/33 foo"
while (c && iswspace(c))
{
c = mesg[pos+1];
pos++;
}
*last_channel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10);
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
// (this code was here; documenting for the future)
if (mesg[1] == '-')
{
*last_channel = -(*last_channel);
}
//</FS:TS> FIRE-11412
*channel = *last_channel;
return mesg.substr(pos, mesg.length() - pos);
}
else
{
// This is normal chat.
*channel = 0;
return mesg;
}
}