llstring.cpp File Reference

String utility functions and the LLString class. More...

#include "linden_common.h"
#include "llstring.h"
#include "llerror.h"

Include dependency graph for llstring.cpp:

Go to the source code of this file.

Namespaces

namespace  LLStringFn

Functions

std::string ll_safe_string (const char *in)
 Return a string constructed from in without crashing if the pointer is NULL.
U8 hex_as_nybble (char hex)
 This translates a nybble stored as a hex value from 0-f back to a nybble in the low order bits of the return byte.
bool _read_file_into_string (std::string &str, const char *filename)
 read the contents of a file into a string.
std::ostream & operator<< (std::ostream &s, const LLWString &wstr)
std::string rawstr_to_utf8 (const std::string &raw)
S32 wchar_to_utf8chars (llwchar in_char, char *outchars)
S32 utf16chars_to_wchar (const U16 *inchars, llwchar *outchar)
S32 utf16chars_to_utf8chars (const U16 *inchars, char *outchars, S32 *nchars8p)
llutf16string wstring_to_utf16str (const LLWString &utf32str, S32 len)
llutf16string wstring_to_utf16str (const LLWString &utf32str)
llutf16string utf8str_to_utf16str (const LLString &utf8str)
LLWString utf16str_to_wstring (const llutf16string &utf16str, S32 len)
LLWString utf16str_to_wstring (const llutf16string &utf16str)
S32 wchar_utf8_length (const llwchar wc)
S32 wstring_utf8_length (const LLWString &wstr)
LLWString utf8str_to_wstring (const std::string &utf8str, S32 len)
LLWString utf8str_to_wstring (const std::string &utf8str)
std::string wstring_to_utf8str (const LLWString &utf32str, S32 len)
std::string wstring_to_utf8str (const LLWString &utf32str)
std::string utf16str_to_utf8str (const llutf16string &utf16str)
std::string utf16str_to_utf8str (const llutf16string &utf16str, S32 len)
std::string utf8str_trim (const std::string &utf8str)
std::string utf8str_tolower (const std::string &utf8str)
S32 utf8str_compare_insensitive (const std::string &lhs, const std::string &rhs)
std::string utf8str_truncate (const std::string &utf8str, const S32 max_len)
 Properly truncate a utf8 string to a maximum byte count.
std::string utf8str_substChar (const std::string &utf8str, const llwchar target_char, const llwchar replace_char)
 Replace all occurences of target_char with replace_char.
std::string utf8str_makeASCII (const std::string &utf8str)
std::string mbcsstring_makeASCII (const std::string &wstr)
std::string utf8str_removeCRLF (const std::string &utf8str)
void LLStringFn::replace_nonprintable (std::basic_string< char > &string, char replacement)
 Replace all non-printable characters with replacement in string.
void LLStringFn::replace_nonprintable (std::basic_string< llwchar > &string, llwchar replacement)
 Replace all non-printable characters with replacement in a wide string.
void LLStringFn::replace_nonprintable_and_pipe (std::basic_string< char > &str, char replacement)
 Replace all non-printable characters and pipe characters with replacement in a string.
void LLStringFn::replace_nonprintable_and_pipe (std::basic_string< llwchar > &str, llwchar replacement)
 Replace all non-printable characters and pipe characters with replacement in a wide string.


Detailed Description

String utility functions and the LLString class.

LicenseInfo
firstyear=2001&license=viewergpl

Copyright (c) 2001-2007, Linden Research, Inc.

Second Life Viewer Source Code The source code in this file ("Source Code") is provided by Linden Lab to you under the terms of the GNU General Public License, version 2.0 ("GPL"), unless you have obtained a separate licensing agreement ("Other License"), formally executed by you and Linden Lab. Terms of the GPL can be found in doc/GPL-license.txt in this distribution, or online at http://secondlife.com/developers/opensource/gplv2

There are special exceptions to the terms and conditions of the GPL as it is applied to this Source Code. View the full text of the exception in the file doc/FLOSS-exception.txt in this software distribution, or online at http://secondlife.com/developers/opensource/flossexception

By copying, modifying or distributing this software, you acknowledge that you have read and understood your obligations described above, and agree to abide by those obligations.

ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. $/LicenseInfo$

Definition in file llstring.cpp.


Function Documentation

bool _read_file_into_string ( std::string &  str,
const char *  filename 
)

read the contents of a file into a string.

Since this function has no concept of character encoding, most anything you do with this method ill-advised. Please avoid.

Parameters:
str [out] The string which will have.
filename The full name of the file to read.
Returns:
Returns true on success. If false, str is unmodified.

Definition at line 61 of file llstring.cpp.

References llendl, llifstream, and llinfos.

Referenced by LLMessageSystem::loadTemplateFile(), and main().

U8 hex_as_nybble ( char  hex  ) 

This translates a nybble stored as a hex value from 0-f back to a nybble in the low order bits of the return byte.

Definition at line 43 of file llstring.cpp.

Referenced by deserialize_string_delim(), LLSDNotationParser::parseBinary(), and LLURI::unescape().

std::string ll_safe_string ( const char *  in  ) 

Return a string constructed from in without crashing if the pointer is NULL.

Definition at line 37 of file llstring.cpp.

Referenced by build_transfer_message_to_destination(), build_transfer_message_to_source(), and LLPrefsIM::setPersonalInfo().

std::string mbcsstring_makeASCII ( const std::string &  wstr  ) 

Definition at line 686 of file llstring.cpp.

References i, LL_UNKNOWN_CHAR, and S32.

std::ostream& operator<< ( std::ostream &  s,
const LLWString wstr 
)

Definition at line 86 of file llstring.cpp.

std::string rawstr_to_utf8 ( const std::string &  raw  ) 

Unicode support

Definition at line 93 of file llstring.cpp.

References utf8str_to_wstring(), and wstring_to_utf8str().

Referenced by LLParcel::setDesc().

S32 utf16chars_to_utf8chars ( const U16 inchars,
char *  outchars,
S32 nchars8p 
)

Definition at line 170 of file llstring.cpp.

References S32, utf16chars_to_wchar(), and wchar_to_utf8chars().

S32 utf16chars_to_wchar ( const U16 inchars,
llwchar outchar 
)

Definition at line 150 of file llstring.cpp.

References base.

Referenced by utf16chars_to_utf8chars(), and utf16str_to_wstring().

std::string utf16str_to_utf8str ( const llutf16string utf16str,
S32  len 
)

Definition at line 405 of file llstring.cpp.

std::string utf16str_to_utf8str ( const llutf16string utf16str  ) 

Definition at line 400 of file llstring.cpp.

Referenced by HFSUniStr255_to_utf8str(), and LLOSInfo::LLOSInfo().

LLWString utf16str_to_wstring ( const llutf16string utf16str  ) 

Definition at line 236 of file llstring.cpp.

References S32, and utf16str_to_wstring().

LLWString utf16str_to_wstring ( const llutf16string utf16str,
S32  len 
)

Definition at line 219 of file llstring.cpp.

Referenced by utf16str_to_utf8str(), and utf16str_to_wstring().

S32 utf8str_compare_insensitive ( const std::string &  lhs,
const std::string &  rhs 
)

Definition at line 626 of file llstring.cpp.

References LLStringBase< T >::compareInsensitive(), and utf8str_to_wstring().

std::string utf8str_makeASCII ( const std::string &  utf8str  ) 

Definition at line 679 of file llstring.cpp.

References LLStringBase< T >::_makeASCII(), utf8str_to_wstring(), and wstring_to_utf8str().

std::string utf8str_removeCRLF ( const std::string &  utf8str  ) 

Definition at line 699 of file llstring.cpp.

References i, and S32.

Referenced by LLXMLNode::getTextContents(), and LLTextEditor::setText().

std::string utf8str_substChar ( const std::string &  utf8str,
const llwchar  target_char,
const llwchar  replace_char 
)

Replace all occurences of target_char with replace_char.

Parameters:
utf8str A utf8 string to process.
target_char The wchar to be replaced
replace_char The wchar which is written on replace

Definition at line 668 of file llstring.cpp.

References LLStringBase< T >::replaceChar(), utf8str_to_wstring(), and wstring_to_utf8str().

llutf16string utf8str_to_utf16str ( const LLString utf8str  ) 

Definition at line 212 of file llstring.cpp.

References utf8str_to_wstring(), and wstring_to_utf16str().

Referenced by LLFile::_fsopen(), LLFile::fopen(), LLFile::mkdir(), LLFile::remove(), LLFile::rename(), LLFile::rmdir(), LLFile::stat(), and utf8str_to_HFSUniStr255().

LLWString utf8str_to_wstring ( const std::string &  utf8str  ) 

Definition at line 372 of file llstring.cpp.

References S32, and utf8str_to_wstring().

LLWString utf8str_to_wstring ( const std::string &  utf8str,
S32  len 
)

Definition at line 284 of file llstring.cpp.

Referenced by LLFontGL::addEmbeddedChar(), LLHUDText::addLine(), LLFixedBuffer::addLine(), LLConsole::addLine(), LLKeywords::addToken(), LLTextEditor::appendText(), cmd_get_key(), LLScrollListCtrl::copy(), LLProgressView::draw(), LLLineEditor::draw(), LLTextEditor::drawCursor(), LLTextEditor::drawSelectionBackground(), LLUIString::format(), LLViewerTextEditor::getEmbeddedItemToolTipAtPos(), LLNotifyBox::getNotifyTipRect(), LLFontGL::getWidth(), LLFontGL::getWidthF32(), LLControlGroup::getWString(), LLScrollListCtrl::handleUnicodeCharHere(), hud_render_utf8text(), LLVOAvatar::idleUpdate(), LLTextEditor::insertText(), LLFloaterAvatarList::onClickGetKey(), LLFloaterWorldMap::onCopySLURL(), LLItemBridge::performAction(), LLLineEditor::postvalidateFloat(), LLFloaterAvatarList::processTrustNetReply(), rawstr_to_utf8(), LLFloaterSellLandUI::refreshUI(), LLFontGL::render(), LLTracker::renderBeacon(), LLViewerObjectList::renderObjectBeacons(), LLFontGL::renderUTF8(), LLManip::renderXYZ(), LLTextEditor::replaceText(), LLTextEditor::selectNext(), LLScrollListCtrl::selectSimpleItemByPrefix(), LLChatBar::sendChatFromViewer(), LLViewerTextEditor::setEmbeddedText(), LLHUDText::setLabel(), LLPrefsIMImpl::setPersonalInfo(), LLHUDText::setStringUTF8(), LLTextEditor::setText(), LLTextBox::setWrappedText(), show_progress(), LLComboBox::updateSelection(), utf8str_compare_insensitive(), utf8str_makeASCII(), utf8str_substChar(), utf8str_to_utf16str(), utf8str_to_wstring(), utf8str_tolower(), utf8str_trim(), and utf8string_to_wstring().

std::string utf8str_tolower ( const std::string &  utf8str  ) 

Definition at line 618 of file llstring.cpp.

References LLStringBase< T >::toLower(), utf8str_to_wstring(), and wstring_to_utf8str().

Referenced by LLGesture::deserialize(), headerCallback(), and LLGesture::LLGesture().

std::string utf8str_trim ( const std::string &  utf8str  ) 

Definition at line 610 of file llstring.cpp.

References LLStringBase< T >::trim(), utf8str_to_wstring(), and wstring_to_utf8str().

Referenced by headerCallback(), LLTextEditor::loadKeywords(), LLChatBar::onCommitGesture(), LLChatBar::sendChat(), and LLChatBar::sendChatFromViewer().

std::string utf8str_truncate ( const std::string &  utf8str,
const S32  max_len 
)

Properly truncate a utf8 string to a maximum byte count.

The returned string may be less than max_len if the truncation happens in the middle of a glyph. If max_len is longer than the string passed in, the return value == utf8str.

Parameters:
utf8str A valid utf8 string to truncate.
max_len The maximum number of bytes in the returne
Returns:
Returns a valid utf8 string with byte count <= max_len.

Definition at line 633 of file llstring.cpp.

References S32.

Referenced by LLViewerGestureList::matchPrefix(), LLChatBar::sendChatFromViewer(), LLFloaterIMPanel::sendMsg(), and LLLineEditor::setText().

S32 wchar_to_utf8chars ( llwchar  in_char,
char *  outchars 
)

Definition at line 99 of file llstring.cpp.

References base, LL_UNKNOWN_CHAR, llendl, and llwarns.

Referenced by utf16chars_to_utf8chars(), and wstring_to_utf8str().

S32 wchar_utf8_length ( const llwchar  wc  ) 

Definition at line 242 of file llstring.cpp.

Referenced by LLLineEditor::addChar(), LLLineEditor::paste(), and wstring_utf8_length().

llutf16string wstring_to_utf16str ( const LLWString utf32str  ) 

Definition at line 206 of file llstring.cpp.

References S32, and wstring_to_utf16str().

llutf16string wstring_to_utf16str ( const LLWString utf32str,
S32  len 
)

Definition at line 184 of file llstring.cpp.

Referenced by show_progress(), utf8str_to_utf16str(), and wstring_to_utf16str().

std::string wstring_to_utf8str ( const LLWString utf32str  ) 

Definition at line 394 of file llstring.cpp.

References S32, and wstring_to_utf8str().

std::string wstring_to_utf8str ( const LLWString utf32str,
S32  len 
)

Definition at line 378 of file llstring.cpp.

Referenced by LLPrefsIMImpl::apply(), LLStringOps::collate(), LLUIString::erase(), LLViewerTextEditor::getEmbeddedText(), LLButton::getLabelSelected(), LLButton::getLabelUnselected(), LLTextEditor::getText(), LLTextSegment::getToolTip(), LLScrollListCtrl::handleKeyHere(), LLViewerTextEditor::handleToolTip(), LLScrollListCtrl::handleUnicodeCharHere(), LLUIString::insert(), LLScriptEdCore::onBtnDynamicHelp(), LLChatBar::onInputEditorKeystroke(), operator<<(), LLLineEditor::prevalidateNonNegativeS32(), LLLineEditor::prevalidatePositiveS32(), rawstr_to_utf8(), LLUIString::replace(), LLChatBar::sendChat(), LLAgent::sendChat(), LLChatBar::sendChatFromViewer(), LLFloaterIMPanel::sendMsg(), LLPrefsIMImpl::setPersonalInfo(), LLTextBox::setWrappedText(), LLChatBar::stripChannelNumber(), LLUIString::truncate(), LLComboBox::updateSelection(), utf16str_to_utf8str(), utf8str_makeASCII(), utf8str_substChar(), utf8str_tolower(), utf8str_trim(), and wstring_to_utf8str().

S32 wstring_utf8_length ( const LLWString wstr  ) 

Definition at line 273 of file llstring.cpp.

References i, S32, and wchar_utf8_length().

Referenced by LLLineEditor::paste().


Generated on Thu Jul 1 06:10:41 2010 for Second Life Viewer by  doxygen 1.4.7