本文整理汇总了C++中LLWString::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ LLWString::substr方法的具体用法?C++ LLWString::substr怎么用?C++ LLWString::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLWString
的用法示例。
在下文中一共展示了LLWString::substr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: copyFromPrimarySubstring
void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id )
{
mSourceID = source_id;
mString = src.substr(pos, len);
LLView::getWindow()->copyTextToPrimary( mString );
}
示例4: 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;
}
}
示例5: addToClipboard
// Concatenate the input string to the LL and the system clipboard
bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary)
{
mString = src.substr(pos, len);
return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString));
}
示例6: draw
//.........这里部分代码省略.........
// shadow_imagep->draw( background_box_left + 2,
// background_box_bottom - 2,
// background_box_width,
// background_box_height,
// gColors.getColor( "LoginProgressBoxShadowColor" ) );
// bar_outline_imagep->draw( background_box_left,
// background_box_bottom,
// background_box_width,
// background_box_height,
// gColors.getColor("LoginProgressBoxBorderColor") );
bar_imagep->draw( background_box_left + 1,
background_box_bottom + 1,
background_box_width - 2,
background_box_height - 2,
gColors.getColor("LoginProgressBoxCenterColor") );
// we'll need this later for catching a click if it looks like it contains a link
if ( mMessage.find( "http://" ) != std::string::npos )
mOutlineRect.set( background_box_left, background_box_top, background_box_right, background_box_bottom );
else
mOutlineRect.set( 0, 0, 0, 0 );
// draw loading bar
font->renderUTF8(top_line, 0,
line_x, line_one_y,
//LLColor4::white,
gColors.getColor("LoginProgressBoxTextColor"),
LLFontGL::HCENTER, LLFontGL::BASELINE,
LLFontGL::DROP_SHADOW);
font->renderUTF8(mText, 0,
line_x, line_two_y,
//LLColor4::white,
gColors.getColor("LoginProgressBoxTextColor"),
LLFontGL::HCENTER, LLFontGL::BASELINE,
LLFontGL::DROP_SHADOW);
// shadow_imagep->draw(
// bar_left + 2,
// bar_bottom - 2,
// bar_width,
// bar_height,
// gColors.getColor("LoginProgressBoxShadowColor"));
// bar_imagep->draw(
// bar_left,
// bar_bottom,
// bar_width,
// bar_height,
// LLColor4(0.7f, 0.7f, 0.8f, 1.0f));
bar_bg_imagep->draw(
bar_left + 2,
bar_bottom + 2,
bar_width - 4,
bar_height - 4,
background_color);
LLColor4 bar_color = gColors.getColor("LoginProgressBarFgColor");
bar_color.mV[3] = alpha;
bar_fg_imagep->draw(
bar_left + 2,
bar_bottom + 2,
llround((bar_width - 4) * (mPercentDone / 100.f)),
bar_height - 4,
bar_color);
S32 line_three_y = line_two_y - LINE_SPACING * 3;
// draw the message if there is one
if(!mMessage.empty())
{
LLColor4 text_message_color = gColors.getColor("LoginProgressBoxTextColor");
LLWString wmessage = utf8str_to_wstring(mMessage);
const F32 MAX_PIXELS = 640.0f;
S32 chars_left = wmessage.length();
S32 chars_this_time = 0;
S32 msgidx = 0;
while(chars_left > 0)
{
chars_this_time = font->maxDrawableChars(wmessage.substr(msgidx).c_str(),
MAX_PIXELS,
MAX_STRING - 1,
TRUE);
LLWString wbuffer = wmessage.substr(msgidx, chars_this_time);
font->render(wbuffer, 0,
(F32)line_x, (F32)line_three_y,
//LLColor4::white,
gColors.getColor("LoginProgressBoxTextColor"),
LLFontGL::HCENTER, LLFontGL::BASELINE,
LLFontGL::DROP_SHADOW);
msgidx += chars_this_time;
chars_left -= chars_this_time;
line_three_y -= LINE_SPACING;
}
}
// draw children
LLView::draw();
}