当前位置: 首页>>代码示例>>C++>>正文


C++ LLWString类代码示例

本文整理汇总了C++中LLWString的典型用法代码示例。如果您正苦于以下问题:C++ LLWString类的具体用法?C++ LLWString怎么用?C++ LLWString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LLWString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
	}
开发者ID:HizWylder,项目名称:GIS,代码行数:37,代码来源:lltextvalidate.cpp

示例2: 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;
	}
开发者ID:HizWylder,项目名称:GIS,代码行数:34,代码来源:lltextvalidate.cpp

示例3: validateNonNegativeS32

	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;
	}
开发者ID:HizWylder,项目名称:GIS,代码行数:33,代码来源:lltextvalidate.cpp

示例4: if

// 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;
	}
}
开发者ID:Ratany,项目名称:SingularityViewer,代码行数:59,代码来源:llchatbar.cpp

示例5: if

bool GrowlManager::onLLNotification(const LLSD& notice)
{
	if (notice["sigtype"].asString() != "add")
	{
		return false;
	}

	LLNotificationPtr notification = LLNotifications::instance().find(notice["id"].asUUID());
	std::string name = notification->getName();
	LLSD substitutions = notification->getSubstitutions();
	if (gGrowlManager->mNotifications.find(name) != gGrowlManager->mNotifications.end())
	{
		GrowlNotification* growl_notification = &gGrowlManager->mNotifications[name];
		std::string body = "";
		std::string title = "";
		if (growl_notification->useDefaultTextForTitle)
		{
			title = notification->getMessage();
		}
		else if (!growl_notification->growlTitle.empty())
		{
			title = growl_notification->growlTitle;
			LLStringUtil::format(title, substitutions);
		}
		if (growl_notification->useDefaultTextForBody)
		{
			body = notification->getMessage();
		}
		else if (!growl_notification->growlBody.empty())
		{
			body = growl_notification->growlBody;
			LLStringUtil::format(body, substitutions);
		}
		//TM:FS no need to log whats sent to growl
		//LL_INFOS("GrowlLLNotification") << "Notice: " << title << ": " << body << LL_ENDL;
		if (name == "ObjectGiveItem" || name == "OwnObjectGiveItem" || name == "ObjectGiveItemUnknownUser" || name == "UserGiveItem" || name == "SystemMessageTip")
		{
			LLUrlMatch urlMatch;
			LLWString newLine = utf8str_to_wstring(body);
			LLWString workLine = utf8str_to_wstring(body);
			while (LLUrlRegistry::instance().findUrl(workLine, urlMatch) && !urlMatch.getUrl().empty())
			{
				LLWStringUtil::replaceString(newLine, utf8str_to_wstring(urlMatch.getUrl()), utf8str_to_wstring(urlMatch.getLabel()));

				// Remove the URL from the work line so we don't end in a loop in case of regular URLs!
				// findUrl will always return the very first URL in a string
				workLine = workLine.erase(0, urlMatch.getEnd() + 1);
			}
			body = wstring_to_utf8str(newLine);
		}
		gGrowlManager->notify(title, body, growl_notification->growlName);
	}
	return false;
}
开发者ID:gabeharms,项目名称:firestorm,代码行数:54,代码来源:growlmanager.cpp

示例6: 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());
}
开发者ID:Boy,项目名称:rainbow,代码行数:13,代码来源:llfixedbuffer.cpp

示例7: sendChat

// <dogmode>
void LLChatBar::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();

			S32 channel = 0;
			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);//+" and read is "+llformat("%f",readChan)+" and undone is "+llformat("%d",undoneChan)+" but actualy channel is "+llformat("%d",channel);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				convert_roleplay_text(utf8text);
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);
			EChatType nType(type == CHAT_TYPE_OOC ? CHAT_TYPE_NORMAL : type);
			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, nType))
			{
				// Chat with animation
#if SHY_MOD //Command handler
				if(!SHCommandHandler::handleCommand(true, utf8_revised_text, gAgentID, (LLViewerObject*)gAgentAvatarp))//returns true if handled
#endif //shy_mod
				sendChatFromViewer(utf8_revised_text, nType, TRUE);
			}
		}
	}

	childSetValue("Chat Editor", LLStringUtil::null);

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
开发者ID:Apelsin,项目名称:EffervescenceViewer,代码行数:52,代码来源:llchatbar.cpp

示例8: execute

	virtual BOOL execute( LLTextEditor* editor, S32* delta )
	{
		LLViewerTextEditor* viewer_editor = (LLViewerTextEditor*)editor;
		// Take this opportunity to remove any unused embedded items from this editor
		viewer_editor->mEmbeddedItemList->removeUnusedChars();
		if(viewer_editor->mEmbeddedItemList->insertEmbeddedItem( mItem, &mExtCharValue, true ) )
		{
			LLWString ws;
			ws.assign(1, mExtCharValue);
			*delta = insert(editor, getPosition(), ws );
			return (*delta != 0);
		}
		return FALSE;
	}
开发者ID:Ratany,项目名称:SingularityViewer,代码行数:14,代码来源:llviewertexteditor.cpp

示例9: utf8str_to_wstring

void LLViewerTextEditor::setEmbeddedText(const std::string& instr)
{
	LLWString wtext = utf8str_to_wstring(instr);
	for (S32 i=0; i<(S32)wtext.size(); i++)
	{
		llwchar wch = wtext[i];
		if( wch >= FIRST_EMBEDDED_CHAR && wch <= LAST_EMBEDDED_CHAR )
		{
			S32 index = wch - FIRST_EMBEDDED_CHAR;
			wtext[i] = mEmbeddedItemList->getEmbeddedCharFromIndex(index);
		}
	}
	setWText(wtext);
}
开发者ID:Ratany,项目名称:SingularityViewer,代码行数:14,代码来源:llviewertexteditor.cpp

示例10: sendChat

void LLNearbyChatBar::sendChat( EChatType type )
{
	if (mChatBox)
	{
		LLWString text = mChatBox->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			mChatBox->updateHistory();
			// Check if this is destined for another channel
			S32 channel = 0;
			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);

			type = processChatTypeTriggers(type, utf8_revised_text);

			if (!utf8_revised_text.empty())
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, TRUE);
			}
		}

		mChatBox->setText(LLStringExplicit(""));
	}

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
开发者ID:Katharine,项目名称:kittyviewer,代码行数:49,代码来源:llnearbychatbar.cpp

示例11: sendChat

void LLChatBar::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();
			// Check if this is destined for another channel
			S32 channel = mChanCtrlEnabled ? (S32)(mChannelControl->get()) : 0;

			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				// discard returned "found" boolean
				gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);

			if (!utf8_revised_text.empty())
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, TRUE);
			}
		}
	}

	childSetValue("Chat Editor", LLStringUtil::null);

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
开发者ID:meta7,项目名称:Meta7-Viewer-Imprud-refactor,代码行数:48,代码来源:llchatbar.cpp

示例12: 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;
	}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:28,代码来源:lltextvalidate.cpp

示例13: sendMsg

void LLFloaterIMPanel::sendMsg()
{
	if (!gAgent.isGodlike() 
		&& (mDialog == IM_NOTHING_SPECIAL)
		&& mOtherParticipantUUID.isNull())
	{
		llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
		return;
	}

	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if(!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();
			// Truncate and convert to UTF8 for transport
			std::string utf8_text = wstring_to_utf8str(text);
			utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1);
			
			if ( mSessionInitialized )
			{
				LLIMModel::sendMessage(utf8_text,
								mSessionUUID,
								mOtherParticipantUUID,
								mDialog);

			}
			else
			{
				//queue up the message to send once the session is
				//initialized
				mQueuedMsgsForInit.append(utf8_text);
			}
		}

		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT);

		mInputEditor->setText(LLStringUtil::null);
	}

	// Don't need to actually send the typing stop message, the other
	// client will infer it from receiving the message.
	mTyping = FALSE;
	mSentTypingState = TRUE;
}
开发者ID:HyangZhao,项目名称:NaCl-main,代码行数:47,代码来源:llimpanel.cpp

示例14: utf8str_to_wstring

void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width)
{
	if (max_width < 0.0)
	{
		max_width = (F32)getRect().getWidth();
	}

	LLWString wtext = utf8str_to_wstring(in_text);
	LLWString final_wtext;

	LLWString::size_type  cur = 0;;
	LLWString::size_type  len = wtext.size();

	while (cur < len)
	{
		LLWString::size_type end = wtext.find('\n', cur);
		if (end == LLWString::npos)
		{
			end = len;
		}
		
		LLWString::size_type runLen = end - cur;
		if (runLen > 0)
		{
			LLWString run(wtext, cur, runLen);
			LLWString::size_type useLen =
				mFontGL->maxDrawableChars(run.c_str(), max_width, runLen, TRUE);

			final_wtext.append(wtext, cur, useLen);
			cur += useLen;
		}

		if (cur < len)
		{
			if (wtext[cur] == '\n')
			{
				cur += 1;
			}
			final_wtext += '\n';
		}
	}

	std::string final_text = wstring_to_utf8str(final_wtext);
	setText(final_text);
}
开发者ID:VirtualReality,项目名称:Viewer,代码行数:45,代码来源:lltextbox.cpp

示例15: perform_autoreplace

void LLAutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
{
	static LLCachedControl<bool> perform_autoreplace(gSavedSettings, "AutoReplace");
	if(perform_autoreplace)
	{
		S32 wordEnd = cursorPos-1;
		LLWString text = inputText.getWString();

		bool atSpace  = (text[wordEnd] == ' ');
		bool haveWord = (LLWStringUtil::isPartOfWord(text[wordEnd]));

		if (atSpace || haveWord)
		{
			if (atSpace && wordEnd > 0)
			{
				// find out if this space immediately follows a word
				wordEnd--;
				haveWord  = (LLWStringUtil::isPartOfWord(text[wordEnd]));
			}
			if (haveWord)
			{
				// wordEnd points to the end of a word, now find the start of the word
				std::string word;
				S32 wordStart = wordEnd;
				for ( S32 backOne = wordStart - 1;
					  backOne >= 0 && LLWStringUtil::isPartOfWord(text[backOne]);
					  backOne--
					 )
				{
					wordStart--; // walk wordStart back to the beginning of the word
				}
				LL_DEBUGS("AutoReplace")<<"wordStart: "<<wordStart<<" wordEnd: "<<wordEnd<<LL_ENDL;
				std::string strText  = std::string(text.begin(), text.end());
				std::string lastWord = strText.substr(wordStart, wordEnd-wordStart+1);
				std::string replacementWord( mSettings.replaceWord( lastWord ) );

				if ( replacementWord != lastWord )
				{
					// The last word is one for which we have a replacement
					if (atSpace)
					{
						// replace the last word in the input
						LLWString strNew = utf8str_to_wstring(replacementWord);
						LLWString strOld = utf8str_to_wstring(lastWord);
						int size_change = strNew.size() - strOld.size();

						text.replace(wordStart,lastWord.length(),strNew);
						inputText = wstring_to_utf8str(text);
						cursorPos+=size_change;
					}
				}
			}
		}
	}
}
开发者ID:OS-Development,项目名称:VW.Dolphin_v3,代码行数:55,代码来源:llautoreplace.cpp


注:本文中的LLWString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。