1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
<title>wxWidgets: wxStringBufferLength Class Reference</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="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classwx_string_buffer_length-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxStringBufferLength Class Reference<div class="ingroups"><a class="el" href="group__group__class__data.html">Data Structures</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/string.h></code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This tiny class allows you to conveniently access the <a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> internal buffer as a writable pointer without any risk of forgetting to restore the string to the usable state later, and allows the user to set the internal length of the string. </p>
<p>For example, assuming you have a low-level OS function called <code>"int GetMeaningOfLifeAsString(char *)"</code> copying the value in the provided buffer (which must be writable, of course), and returning the actual length of the string, you might call it like this:</p>
<div class="fragment"><div class="line"><a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> theAnswer;</div>
<div class="line"><a class="code" href="classwx_string_buffer_length.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBufferLength</a> theAnswerBuffer(theAnswer, 1024);</div>
<div class="line"><span class="keywordtype">int</span> nLength = GetMeaningOfLifeAsString(theAnswerBuffer);</div>
<div class="line">theAnswerBuffer.SetLength(nLength);</div>
<div class="line"><span class="keywordflow">if</span> ( theAnswer != <span class="stringliteral">"42"</span> )</div>
<div class="line"> <a class="code" href="group__group__funcmacro__log.html#ga0dd3c633f990f794e76065c9a7af4c87" title="The functions to use for error messages, i.e.">wxLogError</a>(<span class="stringliteral">"Something is very wrong!"</span>);</div>
</div><!-- fragment --><p>Note that the exact usage of this depends on whether or not wxUSE_STL is enabled. If wxUSE_STL is enabled, <a class="el" href="classwx_string_buffer.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBuffer</a> creates a separate empty character buffer, and if wxUSE_STL is disabled, it uses GetWriteBuf() from <a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a>, keeping the same buffer <a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> uses intact. In other words, relying on <a class="el" href="classwx_string_buffer.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBuffer</a> containing the old <a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> data is not a good idea if you want to build your program both with and without wxUSE_STL.</p>
<p>Note that wxStringBuffer::SetLength <b>must</b> be called before <a class="el" href="classwx_string_buffer_length.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBufferLength</a> destructs.</p>
<h2></h2>
<div><span class="lib">Library:</span>  <span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxbase">wxBase</a></span></div><div><span class="category">Category:</span>  <span class="category_text"><a class="el" href="group__group__class__data.html">Data Structures</a></span></div> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ab5781d700200c2f7bd5fb3a620d11f75"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_string_buffer_length.html#ab5781d700200c2f7bd5fb3a620d11f75">wxStringBufferLength</a> (const <a class="el" href="classwx_string.html">wxString</a> &str, size_t len)</td></tr>
<tr class="memdesc:ab5781d700200c2f7bd5fb3a620d11f75"><td class="mdescLeft"> </td><td class="mdescRight">Constructs a writable string buffer object associated with the given string and containing enough space for at least <em>len</em> characters. <a href="#ab5781d700200c2f7bd5fb3a620d11f75"></a><br/></td></tr>
<tr class="separator:ab5781d700200c2f7bd5fb3a620d11f75"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adb3669db3097da59589bce0dd9a432d6"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_string_buffer_length.html#adb3669db3097da59589bce0dd9a432d6">~wxStringBufferLength</a> ()</td></tr>
<tr class="memdesc:adb3669db3097da59589bce0dd9a432d6"><td class="mdescLeft"> </td><td class="mdescRight">Restores the string passed to the constructor to the usable state by calling <a class="el" href="classwx_string.html#a3783b441b540bac783a8e5a2cceaae7d" title="Puts the string back into a reasonable state (in which it can be used normally), after GetWriteBuf() ...">wxString::UngetWriteBuf</a> on it. <a href="#adb3669db3097da59589bce0dd9a432d6"></a><br/></td></tr>
<tr class="separator:adb3669db3097da59589bce0dd9a432d6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a99d1d8c26b452528a05723e713e98077"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_string_buffer_length.html#a99d1d8c26b452528a05723e713e98077">SetLength</a> (size_t nLength)</td></tr>
<tr class="memdesc:a99d1d8c26b452528a05723e713e98077"><td class="mdescLeft"> </td><td class="mdescRight">Sets the internal length of the string referred to by <a class="el" href="classwx_string_buffer_length.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBufferLength</a> to <em>nLength</em> characters. <a href="#a99d1d8c26b452528a05723e713e98077"></a><br/></td></tr>
<tr class="separator:a99d1d8c26b452528a05723e713e98077"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aabee47fbe9384792d8e9d876ec9a8f5b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_string_buffer_length.html#aabee47fbe9384792d8e9d876ec9a8f5b">operator wxChar *</a> ()</td></tr>
<tr class="memdesc:aabee47fbe9384792d8e9d876ec9a8f5b"><td class="mdescLeft"> </td><td class="mdescRight">Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor. <a href="#aabee47fbe9384792d8e9d876ec9a8f5b"></a><br/></td></tr>
<tr class="separator:aabee47fbe9384792d8e9d876ec9a8f5b"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="ab5781d700200c2f7bd5fb3a620d11f75"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">wxStringBufferLength::wxStringBufferLength </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_string.html">wxString</a> & </td>
<td class="paramname"><em>str</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>len</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Constructs a writable string buffer object associated with the given string and containing enough space for at least <em>len</em> characters. </p>
<p>Basically, this is equivalent to calling <a class="el" href="classwx_string.html#a0c87e85cee09e65d314457379e5aba19" title="Returns a writable buffer of at least len bytes.">wxString::GetWriteBuf</a> and saving the result. </p>
</div>
</div>
<a class="anchor" id="adb3669db3097da59589bce0dd9a432d6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">wxStringBufferLength::~wxStringBufferLength </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Restores the string passed to the constructor to the usable state by calling <a class="el" href="classwx_string.html#a3783b441b540bac783a8e5a2cceaae7d" title="Puts the string back into a reasonable state (in which it can be used normally), after GetWriteBuf() ...">wxString::UngetWriteBuf</a> on it. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="aabee47fbe9384792d8e9d876ec9a8f5b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a>* wxStringBufferLength::operator <a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> * </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the writable pointer to a buffer of the size at least equal to the length specified in the constructor. </p>
</div>
</div>
<a class="anchor" id="a99d1d8c26b452528a05723e713e98077"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void wxStringBufferLength::SetLength </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>nLength</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets the internal length of the string referred to by <a class="el" href="classwx_string_buffer_length.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBufferLength</a> to <em>nLength</em> characters. </p>
<p>Must be called before <a class="el" href="classwx_string_buffer_length.html" title="This tiny class allows you to conveniently access the wxString internal buffer as a writable pointer ...">wxStringBufferLength</a> destructs. </p>
</div>
</div>
</div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:59 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|