llstring.h File Reference

String utility functions and LLString class. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  LLStringFn

Classes

class  LLStringOps
class  LLStringBase< T >
class  LLStringExplicit
struct  LLDictionaryLess

Typedefs

typedef LLStringBase< char > LLString
typedef LLStringBase< llwcharLLWString
typedef std::basic_string<
U16
llutf16string

Functions

std::string chop_tail_copy (const std::string &in, std::string::size_type count)
 chop off the trailing characters in a string.
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::string rawstr_to_utf8 (const std::string &raw)
LLWString utf16str_to_wstring (const llutf16string &utf16str, S32 len)
LLWString utf16str_to_wstring (const llutf16string &utf16str)
llutf16string wstring_to_utf16str (const LLWString &utf32str, S32 len)
llutf16string wstring_to_utf16str (const LLWString &utf32str)
llutf16string utf8str_to_utf16str (const LLString &utf8str, S32 len)
llutf16string utf8str_to_utf16str (const LLString &utf8str)
LLWString utf8str_to_wstring (const std::string &utf8str, S32 len)
LLWString utf8str_to_wstring (const std::string &utf8str)
LLWString utf8string_to_wstring (const std::string &utf8_string)
S32 utf16chars_to_utf8chars (const U16 *inchars, char *outchars, S32 *nchars8=0)
S32 utf16chars_to_wchar (const U16 *inchars, llwchar *outchar)
S32 wchar_to_utf8chars (llwchar inchar, char *outchars)
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, S32 len)
std::string utf16str_to_utf8str (const llutf16string &utf16str)
S32 wstring_utf8_length (const LLWString &wstr)
S32 wchar_utf8_length (const llwchar wc)
std::string utf8str_tolower (const std::string &utf8str)
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_trim (const std::string &utf8str)
S32 utf8str_compare_insensitive (const std::string &lhs, const std::string &rhs)
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 &str)
std::string utf8str_removeCRLF (const std::string &utf8str)
template<class T>
std::ostream & operator<< (std::ostream &s, const LLStringBase< T > &str)
std::ostream & operator<< (std::ostream &s, const LLWString &wstr)
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.

Variables

const char LL_UNKNOWN_CHAR = '?'


Detailed Description

String utility functions and 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.h.


Typedef Documentation

typedef LLStringBase<char> LLString

Definition at line 321 of file llstring.h.

typedef std::basic_string<U16> llutf16string

Definition at line 400 of file llstring.h.

typedef LLStringBase<llwchar> LLWString

Definition at line 322 of file llstring.h.


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().

std::string chop_tail_copy ( const std::string &  in,
std::string::size_type  count 
) [inline]

chop off the trailing characters in a string.

This function works on bytes rather than glyphs, so this will incorrectly truncate non-single byte strings. Use utf8str_truncate() for utf8 strings

Returns:
a copy of in string minus the trailing count characters.

Definition at line 358 of file llstring.h.

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 &  str  ) 

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.

References wstring_to_utf8str().

template<class T>
std::ostream& operator<< ( std::ostream &  s,
const LLStringBase< T > &  str 
)

Definition at line 475 of file llstring.h.

References s.

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 nchars8 = 0 
)

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  ) 

Definition at line 400 of file llstring.cpp.

References utf16str_to_wstring(), and wstring_to_utf8str().

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

Definition at line 405 of file llstring.cpp.

References utf16str_to_wstring(), and wstring_to_utf8str().

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.

References i, S32, and utf16chars_to_wchar().

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().

llutf16string utf8str_to_utf16str ( const LLString utf8str,
S32  len 
)

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.

References end, i, LL_UNKNOWN_CHAR, and S32.

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().

LLWString utf8string_to_wstring ( const std::string &  utf8_string  )  [inline]

Definition at line 414 of file llstring.h.

References utf8str_to_wstring().

Referenced by LLView::escapeXML().

S32 wchar_to_utf8chars ( llwchar  inchar,
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.

References i, and S32.

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.

References i, n, S32, and wchar_to_utf8chars().

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().


Variable Documentation

const char LL_UNKNOWN_CHAR = '?'

Definition at line 40 of file llstring.h.

Referenced by LLStringBase< T >::_makeASCII(), LLEmbeddedItems::getEmbeddedCharFromIndex(), LLViewerTextEditor::getEmbeddedText(), mbcsstring_makeASCII(), LLTextEditor::paste(), LLViewerTextEditor::pasteEmbeddedItem(), LLParcel::setMediaURL(), LLParcel::setMusicURL(), LLParcel::setName(), utf8str_to_wstring(), and wchar_to_utf8chars().


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