206 lines
11 KiB
HTML
206 lines
11 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||
|
<meta name="generator" content="Doxygen 1.8.18"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
<title>AngelScript: string</title>
|
||
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
<script type="text/javascript" src="navtreedata.js"></script>
|
||
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
||
|
<script type="text/javascript" src="search/search.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
$(document).ready(function() { init_search(); });
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||
|
<div id="titlearea">
|
||
|
<table cellspacing="0" cellpadding="0">
|
||
|
<tbody>
|
||
|
<tr style="height: 56px;">
|
||
|
<td id="projectlogo"><img alt="Logo" src="aslogo_small.png"/></td>
|
||
|
<td id="projectalign" style="padding-left: 0.5em;">
|
||
|
<div id="projectname">AngelScript
|
||
|
</div>
|
||
|
</td>
|
||
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
||
|
<span class="left">
|
||
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
alt=""/>
|
||
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
||
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
||
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
||
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
||
|
</span><span class="right">
|
||
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
||
|
</span>
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- end header part -->
|
||
|
<!-- Generated by Doxygen 1.8.18 -->
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
</div><!-- top -->
|
||
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
<div id="nav-tree">
|
||
|
<div id="nav-tree-contents">
|
||
|
<div id="nav-sync" class="sync"></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
class="ui-resizable-handle">
|
||
|
</div>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
$(document).ready(function(){initNavTree('doc_script_stdlib_string.html',''); initResizable(); });
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
<div id="doc-content">
|
||
|
<!-- window showing the filter options -->
|
||
|
<div id="MSearchSelectWindow"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
</div>
|
||
|
|
||
|
<!-- iframe showing the search results (closed by default) -->
|
||
|
<div id="MSearchResultsWindow">
|
||
|
<iframe src="javascript:void(0)" frameborder="0"
|
||
|
name="MSearchResults" id="MSearchResults">
|
||
|
</iframe>
|
||
|
</div>
|
||
|
|
||
|
<div class="PageDoc"><div class="header">
|
||
|
<div class="headertitle">
|
||
|
<div class="title">string </div> </div>
|
||
|
</div><!--header-->
|
||
|
<div class="contents">
|
||
|
<div class="textblock"><dl class="section note"><dt>Note</dt><dd>Strings are only available in the scripts if the application <a class="el" href="doc_addon_std_string.html">registers the support for them</a>. The syntax for using strings may differ for the application you're working with so consult the application's manual for more details.</dd></dl>
|
||
|
<dl class="section see"><dt>See also</dt><dd><a class="el" href="doc_datatypes_strings.html">Strings</a> for information on syntax for string literals</dd></dl>
|
||
|
<h1><a class="anchor" id="doc_datatypes_strings_addon"></a>
|
||
|
Supporting string object and functions</h1>
|
||
|
<p>The string object supports a number of operators, and has several class methods and supporting global functions to facilitate the manipulation of strings.</p>
|
||
|
<h2><a class="anchor" id="doc_datatypes_strings_addon_ops"></a>
|
||
|
Operators</h2>
|
||
|
<p><b>= assignment</b><br />
|
||
|
</p>
|
||
|
<p>The assignment operator copies the content of the right hand string into the left hand string.</p>
|
||
|
<p>Assignment of primitive types is allowed, which will do a default transformation of the primitive to a string.</p>
|
||
|
<p><b>+, += concatenation</b><br />
|
||
|
</p>
|
||
|
<p>The concatenation operator appends the content of the right hand string to the end of the left hand string.</p>
|
||
|
<p>Concatenation of primitives types is allowed, which will do a default transformation of the primitive to a string.</p>
|
||
|
<p><b>==, != equality</b><br />
|
||
|
</p>
|
||
|
<p>Compares the content of the two strings.</p>
|
||
|
<p><b><, >, <=, >= comparison</b><br />
|
||
|
</p>
|
||
|
<p>Compares the content of the two strings. The comparison is done on the byte values in the strings, which may not correspond to alphabetical comparisons for some languages.</p>
|
||
|
<p><b>[] index operator</b><br />
|
||
|
</p>
|
||
|
<p>The index operator gives access to a single byte in the string.</p>
|
||
|
<h2><a class="anchor" id="doc_datatypes_strings_addon_mthd"></a>
|
||
|
Methods</h2>
|
||
|
<p><b>uint length() const</b><br />
|
||
|
</p>
|
||
|
<p>Returns the length of the string.</p>
|
||
|
<p><b>void resize(uint)</b><br />
|
||
|
</p>
|
||
|
<p>Sets the length of the string.</p>
|
||
|
<p><b>bool isEmpty() const</b><br />
|
||
|
</p>
|
||
|
<p>Returns true if the string is empty, i.e. the length is zero.</p>
|
||
|
<p><b>string substr(uint start = 0, int count = -1) const</b><br />
|
||
|
</p>
|
||
|
<p>Returns a string with the content starting at <em>start</em> and the number of bytes given by count. The default arguments will return the whole string as the new string.</p>
|
||
|
<p><b>void insert(uint pos, const string &in other)</b><br />
|
||
|
</p>
|
||
|
<p>Inserts another string <em>other</em> at position <em>pos</em> in the original string.</p>
|
||
|
<p><b>void erase(uint pos, int count = -1)</b><br />
|
||
|
</p>
|
||
|
<p>Erases a range of characters from the string, starting at position <em>pos</em> and counting <em>count</em> characters.</p>
|
||
|
<p><b>int findFirst(const string &in str, uint start = 0) const</b><br />
|
||
|
</p>
|
||
|
<p>Find the first occurrence of the value <em>str</em> in the string, starting at <em>start</em>. If no occurrence is found a negative value will be returned.</p>
|
||
|
<p><b>int findLast(const string &in str, int start = -1) const</b><br />
|
||
|
</p>
|
||
|
<p>Find the last occurrence of the value <em>str</em> in the string. If <em>start</em> is informed the search will begin at that position, i.e. any potential occurrence after that position will not be searched. If no occurrence is found a negative value will be returned.</p>
|
||
|
<p><b>int findFirstOf(const string &in chars, int start = 0) const</b><br />
|
||
|
<b>int findFirstNotOf(const string &in chars, int start = 0) const</b><br />
|
||
|
<b>int findLastOf(const string &in chars, int start = -1) const</b><br />
|
||
|
<b>int findLastNotOf(const string &in chars, int start = -1) const</b><br />
|
||
|
</p>
|
||
|
<p>The first variant finds the first character in the string that matches on of the characters in <em>chars</em>, starting at <em>start</em>. If no occurrence is found a negative value will be returned.</p>
|
||
|
<p>The second variant finds the first character that doesn't match any of those in <em>chars</em>. The third and last variant are the same except they start the search from the end of the string.</p>
|
||
|
<dl class="section note"><dt>Note</dt><dd>These functions work on the individual bytes in the strings. They do not attempt to understand encoded characters, e.g. UTF-8 encoded characters that can take up to 4 bytes.</dd></dl>
|
||
|
<p><b>array<string>@ split(const string &in delimiter) const</b><br />
|
||
|
</p>
|
||
|
<p>Splits the string in smaller strings where the delimiter is found.</p>
|
||
|
<h2><a class="anchor" id="doc_datatypes_strings_addon_funcs"></a>
|
||
|
Functions</h2>
|
||
|
<p><b>string join(const array<string> &in arr, const string &in delimiter)</b><br />
|
||
|
</p>
|
||
|
<p>Concatenates the strings in the array into a large string, separated by the delimiter.</p>
|
||
|
<p><b>int64 parseInt(const string &in str, uint base = 10, uint &out byteCount = 0)</b><br />
|
||
|
<b>uint64 parseUInt(const string &in str, uint base = 10, uint &out byteCount = 0)</b><br />
|
||
|
</p>
|
||
|
<p>Parses the string for an integer value. The <em>base</em> can be 10 or 16 to support decimal numbers or hexadecimal numbers. If <em>byteCount</em> is provided it will be set to the number of bytes that were considered as part of the integer value.</p>
|
||
|
<p><b>double parseFloat(const string &in, uint &out byteCount = 0)</b><br />
|
||
|
</p>
|
||
|
<p>Parses the string for a floating point value. If <em>byteCount</em> is provided it will be set to the number of bytes that were considered as part of the value.</p>
|
||
|
<p><b>string formatInt(int64 val, const string &in options = '', uint width = 0)</b><br />
|
||
|
<b>string formatUInt(uint64 val, const string &in options = '', uint width = 0)</b><br />
|
||
|
<b>string formatFloat(double val, const string &in options = '', uint width = 0, uint precision = 0)</b><br />
|
||
|
</p>
|
||
|
<p>The format functions takes a string that defines how the number should be formatted. The string is a combination of the following characters:</p>
|
||
|
<ul>
|
||
|
<li>l = left justify</li>
|
||
|
<li>0 = pad with zeroes</li>
|
||
|
<li>+ = always include the sign, even if positive</li>
|
||
|
<li>space = add a space in case of positive number</li>
|
||
|
<li>h = hexadecimal integer small letters (not valid for formatFloat)</li>
|
||
|
<li>H = hexadecimal integer capital letters (not valid for formatFloat)</li>
|
||
|
<li>e = exponent character with small e (only valid for formatFloat)</li>
|
||
|
<li>E = exponent character with capital E (only valid for formatFloat)</li>
|
||
|
</ul>
|
||
|
<p>Examples:</p>
|
||
|
<pre>
|
||
|
// Left justify number in string with 10 characters
|
||
|
string justified = formatInt(number, 'l', 10);</pre><pre> // Create hexadecimal representation with capital letters, right justified
|
||
|
string hex = formatInt(number, 'H', 10);</pre><pre> // Right justified, padded with zeroes and two digits after decimal separator
|
||
|
string num = formatFloat(number, '0', 8, 2);
|
||
|
</pre> </div></div><!-- contents -->
|
||
|
</div><!-- PageDoc -->
|
||
|
</div><!-- doc-content -->
|
||
|
<!-- start footer part -->
|
||
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||
|
<ul>
|
||
|
<li class="footer">Generated on Sat Dec 5 2020 23:20:25 for AngelScript by
|
||
|
<a href="http://www.doxygen.org/index.html">
|
||
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.18 </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|