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 utf16str_wstring_length (const llutf16string &utf16str, const S32 utf16_len)
S32 wstring_utf16_length (const LLWString &wstr, const S32 woffset, const S32 wlen)
S32 wstring_wstring_length_from_utf16_length (const LLWString &wstr, const S32 woffset, const S32 utf16_length, BOOL *unaligned)
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-2008, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 68 of file llstring.cpp.

References llendl, llifstream, and llinfos.

Referenced by DisplayReleaseNotes(), LLAppViewerMacOSX::initParseCommandLine(), and LLMessageSystem::loadTemplateFile().

Here is the caller graph for this function:

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 50 of file llstring.cpp.

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

Here is the caller graph for this function:

std::string ll_safe_string ( const char *  in  ) 

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

Definition at line 44 of file llstring.cpp.

Referenced by build_transfer_message_to_destination(), build_transfer_message_to_source(), LLViewerJoystick::getDescription(), LLHost::getHostName(), inventory_offer_handler(), and LLPrefsIM::setPersonalInfo().

Here is the caller graph for this function:

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

Definition at line 771 of file llstring.cpp.

References i, LL_UNKNOWN_CHAR, and S32.

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

Definition at line 93 of file llstring.cpp.

References wstring_to_utf8str().

Here is the call graph for this function:

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

Unicode support

Definition at line 100 of file llstring.cpp.

References utf8str_to_wstring(), and wstring_to_utf8str().

Referenced by LLParcel::setDesc(), LLParcel::setMediaDesc(), and LLParcel::setMediaType().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 177 of file llstring.cpp.

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

Here is the call graph for this function:

S32 utf16chars_to_wchar ( const U16 inchars,
llwchar outchar 
)

Definition at line 157 of file llstring.cpp.

Referenced by utf16chars_to_utf8chars(), and utf16str_to_wstring().

Here is the caller graph for this function:

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

Definition at line 490 of file llstring.cpp.

References utf16str_to_wstring(), and wstring_to_utf8str().

Here is the call graph for this function:

std::string utf16str_to_utf8str ( const llutf16string utf16str  ) 

Definition at line 485 of file llstring.cpp.

References utf16str_to_wstring(), and wstring_to_utf8str().

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

Here is the call graph for this function:

Here is the caller graph for this function:

LLWString utf16str_to_wstring ( const llutf16string utf16str  ) 

Definition at line 243 of file llstring.cpp.

References S32, and utf16str_to_wstring().

Here is the call graph for this function:

LLWString utf16str_to_wstring ( const llutf16string utf16str,
S32  len 
)

Definition at line 226 of file llstring.cpp.

References i, S32, and utf16chars_to_wchar().

Referenced by utf16str_to_utf8str(), and utf16str_to_wstring().

Here is the call graph for this function:

Here is the caller graph for this function:

S32 utf16str_wstring_length ( const llutf16string utf16str,
const S32  utf16_len 
)

Definition at line 250 of file llstring.cpp.

References d, i, and S32.

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

Definition at line 711 of file llstring.cpp.

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

Here is the call graph for this function:

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

Definition at line 764 of file llstring.cpp.

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

Here is the call graph for this function:

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

Definition at line 784 of file llstring.cpp.

References i, and S32.

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

Here is the caller graph for this function:

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 753 of file llstring.cpp.

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

Here is the call graph for this function:

llutf16string utf8str_to_utf16str ( const LLString utf8str  ) 

Definition at line 219 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().

Here is the call graph for this function:

Here is the caller graph for this function:

LLWString utf8str_to_wstring ( const std::string &  utf8str  ) 

Definition at line 457 of file llstring.cpp.

References S32, and utf8str_to_wstring().

Here is the call graph for this function:

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

Definition at line 369 of file llstring.cpp.

References i, LL_UNKNOWN_CHAR, and S32.

Referenced by LLFontGL::addEmbeddedChar(), LLHUDText::addLine(), LLConsole::addLine(), LLFixedBuffer::addLine(), LLKeywords::addToken(), LLTextEditor::appendText(), 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(), LLFloaterWorldMap::onCopySLURL(), LLItemBridge::performAction(), LLLineEditor::postvalidateFloat(), rawstr_to_utf8(), LLFloaterSellLandUI::refreshUI(), LLFontGL::render(), LLTracker::renderBeacon(), LLViewerObjectList::renderObjectBeacons(), LLFontGL::renderUTF8(), LLManip::renderXYZ(), LLTextEditor::replaceText(), LLScrollListCtrl::selectItemByPrefix(), LLTextEditor::selectNext(), LLChatBar::sendChatFromViewer(), LLViewerTextEditor::setEmbeddedText(), LLHUDText::setLabel(), LLPrefsIMImpl::setPersonalInfo(), LLHUDText::setStringUTF8(), LLTextEditor::setText(), LLTextBox::setWrappedText(), show_progress(), LLTextEditor::truncate(), 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 703 of file llstring.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 695 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 return value.
Returns:
Returns a valid utf8 string with byte count <= max_len.

Definition at line 718 of file llstring.cpp.

References S32.

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

Here is the caller graph for this function:

S32 wchar_to_utf8chars ( llwchar  in_char,
char *  outchars 
)

Definition at line 106 of file llstring.cpp.

References LL_UNKNOWN_CHAR, llendl, and llwarns.

Referenced by utf16chars_to_utf8chars(), and wstring_to_utf8str().

Here is the caller graph for this function:

S32 wchar_utf8_length ( const llwchar  wc  ) 

Definition at line 327 of file llstring.cpp.

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

Here is the caller graph for this function:

llutf16string wstring_to_utf16str ( const LLWString utf32str  ) 

Definition at line 213 of file llstring.cpp.

References S32, and wstring_to_utf16str().

Here is the call graph for this function:

llutf16string wstring_to_utf16str ( const LLWString utf32str,
S32  len 
)

Definition at line 191 of file llstring.cpp.

References i, and S32.

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

Here is the caller graph for this function:

std::string wstring_to_utf8str ( const LLWString utf32str  ) 

Definition at line 479 of file llstring.cpp.

References S32, and wstring_to_utf8str().

Here is the call graph for this function:

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

S32 wstring_utf16_length ( const LLWString wstr,
const S32  woffset,
const S32  wlen 
)

Definition at line 277 of file llstring.cpp.

References i, llmin(), and S32.

Here is the call graph for this function:

S32 wstring_utf8_length ( const LLWString wstr  ) 

Definition at line 358 of file llstring.cpp.

References i, S32, and wchar_utf8_length().

Referenced by LLTextEditor::addChar(), LLLineEditor::paste(), and LLTextEditor::truncate().

Here is the call graph for this function:

Here is the caller graph for this function:

S32 wstring_wstring_length_from_utf16_length ( const LLWString wstr,
const S32  woffset,
const S32  utf16_length,
BOOL unaligned 
)

Definition at line 301 of file llstring.cpp.

References FALSE, i, n, and S32.


Generated on Fri May 16 08:34:50 2008 for SecondLife by  doxygen 1.5.5