chromium/native_client_sdk/doc_generated/pepper_beta/c/struct_p_p_b___var__1__2.html

{{+bindTo:partials.standard_nacl_api}}
<h1>PPB_Var Struct Reference</h1>
<div id="doxygen-ref">
{{- dummy div to appease doxygen -}}
  <div>
<!-- Generated by Doxygen 1.7.6.1 -->


</div>
<!--header-->
<div class="contents">
<!-- doxytag: class="PPB_Var" --><h2>
Data Fields</h2><table class="memberdecls">

<tr><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a52f49d7d04522a69bbbc2b5161a32c1c">AddRef</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a3ca6fe76b51c14df6cc6a04d77edb807">Release</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a5c7ce303ae72998f54ba5da3357f7641">VarFromUtf8</a> )(const char *data, uint32_t len)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const char *(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a573919f500ea491afe6c8c9dddc0106f">VarToUtf8</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var, uint32_t *len)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a686edc2d60c7d3803a03f8e1c1fb1414">VarToResource</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var__1__2.html#a3b2240a7db38d55b6ea084a7d3cfe340">VarFromResource</a> )(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)</td></tr>
</table>
<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>PPB_Var API. </p>
</div><hr /><h2>Field Documentation</h2>
<a class="anchor" id="a52f49d7d04522a69bbbc2b5161a32c1c"></a><!-- doxytag: member="PPB_Var::AddRef" ref="a52f49d7d04522a69bbbc2b5161a32c1c" args=")(struct PP_Var var)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void(* <a class="el" href="struct_p_p_b___var__1__2.html#a52f49d7d04522a69bbbc2b5161a32c1c">PPB_Var::AddRef</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___var__1__2.html#a52f49d7d04522a69bbbc2b5161a32c1c" title="AddRef() adds a reference to the given var.">AddRef()</a> adds a reference to the given var. </p>
<p>If this is not a refcounted object, this function will do nothing so you can always call it no matter what the type.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">var</td><td>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> that will have a reference added. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a3ca6fe76b51c14df6cc6a04d77edb807"></a><!-- doxytag: member="PPB_Var::Release" ref="a3ca6fe76b51c14df6cc6a04d77edb807" args=")(struct PP_Var var)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void(* <a class="el" href="struct_p_p_b___var__1__2.html#a3ca6fe76b51c14df6cc6a04d77edb807">PPB_Var::Release</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___var__1__2.html#a3ca6fe76b51c14df6cc6a04d77edb807" title="Release() removes a reference to given var, deleting it if the internal reference count becomes 0...">Release()</a> removes a reference to given var, deleting it if the internal reference count becomes 0. </p>
<p>If the <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> is of type <code>PP_VARTYPE_RESOURCE</code>, it will implicitly release a reference count on the <code>PP_Resource</code> (equivalent to <a class="el" href="struct_p_p_b___core__1__0.html#af3163aefc33071af39cd085a0a2d44fe" title="ReleaseResource() removes a reference from a resource.">PPB_Core::ReleaseResource()</a>).</p>
<p>If the given var is not a refcounted object, this function will do nothing so you can always call it no matter what the type.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">var</td><td>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> that will have a reference removed. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a3b2240a7db38d55b6ea084a7d3cfe340"></a><!-- doxytag: member="PPB_Var::VarFromResource" ref="a3b2240a7db38d55b6ea084a7d3cfe340" args=")(PP_Resource resource)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(* <a class="el" href="struct_p_p_b___var__1__2.html#a3b2240a7db38d55b6ea084a7d3cfe340">PPB_Var::VarFromResource</a>)(<a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a> resource)<code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates a new <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> from a given resource. </p>
<p>Implicitly adds a reference count on the <code>PP_Resource</code> (equivalent to PPB_Core::AddRefResource(resource)).</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">resource</td><td>A <code>PP_Resource</code> to be wrapped in a var.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> created for this resource, with type <code>PP_VARTYPE_RESOURCE</code>. The reference count of the var is set to 1 on behalf of the caller. </dd></dl>
</div>
</div>
<a class="anchor" id="a5c7ce303ae72998f54ba5da3357f7641"></a><!-- doxytag: member="PPB_Var::VarFromUtf8" ref="a5c7ce303ae72998f54ba5da3357f7641" args=")(const char *data, uint32_t len)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(* <a class="el" href="struct_p_p_b___var__1__2.html#a5c7ce303ae72998f54ba5da3357f7641">PPB_Var::VarFromUtf8</a>)(const char *data, uint32_t len)<code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___var__1__2.html#a5c7ce303ae72998f54ba5da3357f7641" title="VarFromUtf8() creates a string var from a string.">VarFromUtf8()</a> creates a string var from a string. </p>
<p>The string must be encoded in valid UTF-8 and is NOT NULL-terminated, the length must be specified in <code>len</code>. It is an error if the string is not valid UTF-8.</p>
<p>If the length is 0, the <code>*data</code> pointer will not be dereferenced and may be <code>NULL</code>. Note, however if length is 0, the "NULL-ness" will not be preserved, as <a class="el" href="struct_p_p_b___var__1__2.html#a573919f500ea491afe6c8c9dddc0106f" title="VarToUtf8() converts a string-type var to a char* encoded in UTF-8.">VarToUtf8()</a> will never return <code>NULL</code> on success, even for empty strings.</p>
<p>The resulting object will be a refcounted string object. It will be AddRef'ed for the caller. When the caller is done with it, it should be Released.</p>
<p>On error (basically out of memory to allocate the string, or input that is not valid UTF-8), this function will return a Null var.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>A string </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">len</td><td>The length of the string.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> structure containing a reference counted string object. </dd></dl>
</div>
</div>
<a class="anchor" id="a686edc2d60c7d3803a03f8e1c1fb1414"></a><!-- doxytag: member="PPB_Var::VarToResource" ref="a686edc2d60c7d3803a03f8e1c1fb1414" args=")(struct PP_Var var)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___typedefs.html#gafdc3895ee80f4750d0d95ae1b677e9b7">PP_Resource</a>(* <a class="el" href="struct_p_p_b___var__1__2.html#a686edc2d60c7d3803a03f8e1c1fb1414">PPB_Var::VarToResource</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Converts a resource-type var to a <code>PP_Resource</code>. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">var</td><td>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> struct containing a resource-type var.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A <code>PP_Resource</code> retrieved from the var, or 0 if the var is not a resource. The reference count of the resource is incremented on behalf of the caller. </dd></dl>
</div>
</div>
<a class="anchor" id="a573919f500ea491afe6c8c9dddc0106f"></a><!-- doxytag: member="PPB_Var::VarToUtf8" ref="a573919f500ea491afe6c8c9dddc0106f" args=")(struct PP_Var var, uint32_t *len)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char*(* <a class="el" href="struct_p_p_b___var__1__2.html#a573919f500ea491afe6c8c9dddc0106f">PPB_Var::VarToUtf8</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> var, uint32_t *len)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_p_p_b___var__1__2.html#a573919f500ea491afe6c8c9dddc0106f" title="VarToUtf8() converts a string-type var to a char* encoded in UTF-8.">VarToUtf8()</a> converts a string-type var to a char* encoded in UTF-8. </p>
<p>This string is NOT NULL-terminated. The length will be placed in <code>*len</code>. If the string is valid but empty the return value will be non-NULL, but <code>*len</code> will still be 0.</p>
<p>If the var is not a string, this function will return NULL and <code>*len</code> will be 0.</p>
<p>The returned buffer will be valid as long as the underlying var is alive. If the instance frees its reference, the string will be freed and the pointer will be to arbitrary memory.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">var</td><td>A <a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a> struct containing a string-type var. </td></tr>
<tr><td class="paramdir">[in,out]</td><td class="paramname">len</td><td>A pointer to the length of the string-type var.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A char* encoded in UTF-8. </dd></dl>
</div>
</div>
<hr />The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="ppb__var_8h.html">ppb_var.h</a></li>
</ul>
</div><!-- contents -->
</div>
{{/partials.standard_nacl_api}}