<h1>xercesc::MemBufInputSource Class Reference</h1><!-- doxytag: class="xercesc::MemBufInputSource" --><!-- doxytag: inherits="xercesc::InputSource" -->This class is a derivative of the standard <aclass="el"href="classxercesc_1_1InputSource.html">InputSource</a> class.
Inheritance diagram for xercesc::MemBufInputSource:<p><center><imgsrc="classxercesc_1_1MemBufInputSource__inherit__graph.png"border="0"usemap="#xercesc_1_1MemBufInputSource__inherit__map"alt="Inheritance graph"></center>
<center><fontsize="2">[<ahref="graph_legend.html">legend</a>]</font></center><ahref="classxercesc_1_1MemBufInputSource-members.html">List of all members.</a><tableborder="0"cellpadding="0"cellspacing="0">
<tr><td></td></tr>
<tr><tdcolspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">This method will return a binary input stream derivative that will parse from the memory buffer. <ahref="#12e9b809f29882afb3d472a9e7d2fd65"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">By default, for safety's sake, each newly created stream from this input source will make its own copy of the buffer to stream from. <ahref="#9efbedc3d265c066bc6fa65530ab7e75"></a><br></td></tr>
<tr><tdclass="memItemLeft"nowrapalign="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="classxercesc_1_1MemBufInputSource.html#29770f293ebf71a35d76bbd52411e874">resetMemBufInputSource</a> (const XMLByte *const srcDocBytes, const unsigned int byteCount)</td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">This methods allows the <aclass="el"href="classxercesc_1_1MemBufInputSource.html">MemBufInputSource</a> to be used for more than one input source, instead of destructing/constructing another <aclass="el"href="classxercesc_1_1MemBufInputSource.html">MemBufInputSource</a>. <ahref="#29770f293ebf71a35d76bbd52411e874"></a><br></td></tr>
This class is a derivative of the standard <aclass="el"href="classxercesc_1_1InputSource.html">InputSource</a> class.
<p>
It provides for the parser access to data stored in a memory buffer. The type of buffer and its host specific attributes are of little concern here. The only real requirement is that the memory be readable by the current process.<p>
Note that the memory buffer size is expressed in <b>bytes</b>, not in characters. If you pass it text data, you must account for the bytes per character when indicating the buffer size.<p>
As with all <aclass="el"href="classxercesc_1_1InputSource.html">InputSource</a> derivatives. The primary objective of an input source is to create an input stream via which the parser can spool in data from the referenced source. In this case, there are two options available.<p>
The passed buffer can be adopted or merely referenced. If it is adopted, then it must be dynamically allocated and will be destroyed when the input source is destroyed (no reference counting!.) If not adopted, the caller must insure that it remains valid until the input source object is destroyed.<p>
The other option indicates whether each stream created for this input source should get its own copy of the data, or whether it should just stream the data directly from this object's copy of the data. The same rules apply here, in that the buffer must either be copied by the stream or it must remain valid until the stream is destroyed.
<p>
<hr><h2>Constructor & Destructor Documentation</h2>
A memory buffer input source is constructed from a buffer of byte data, and the count of bytes in that buffer.
<p>
The parser will parse from this memory buffer until it has eaten the indicated number of bytes.<p>
Note that the system id provided serves two purposes. Firstly it is going to be displayed in error messages as the source of the error. And secondly, any entities which are refered to from this entity via relative paths/URLs will be relative to this fake system id.<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>srcDocBytes</em> </td><td>The actual data buffer to be parsed from. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>byteCount</em> </td><td>The count of bytes (not characters, bytes!) in the buffer. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>bufId</em> </td><td>A fake system id for the buffer. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>adoptBuffer</em> </td><td>Indicates whether this object should adopt the buffer (i.e. become responsible for deletion) or just use it in place. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>manager</em> </td><td>Pointer to the memory manager to be used to allocate objects. </td></tr>
The parser will parse from this memory buffer until it has eaten the indicated number of bytes.<p>
Note that the system id provided serves two purposes. Firstly it is going to be displayed in error messages as the source of the error. And secondly, any entities which are refered to from this entity via relative paths/URLs will be relative to this fake system id.<p>
<tr><tdvalign="top"></td><tdvalign="top"><em>bufId</em> </td><td>A fake system id for the buffer. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>adoptBuffer</em> </td><td>Indicates whether this object should adopt the buffer (i.e. become responsible for deletion) or just use it in place. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>manager</em> </td><td>Pointer to the memory manager to be used to allocate objects. </td></tr>
This method will return a binary input stream derivative that will parse from the memory buffer.
<p>
If <aclass="el"href="classxercesc_1_1MemBufInputSource.html#9efbedc3d265c066bc6fa65530ab7e75">setCopyBufToStream()</a> has been set, then the stream will make its own copy. Otherwise, it will use the buffer as is (in which case it must remain valid until the stream is no longer in use, i.e. the parse completes.)<p>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>A dynamically allocated binary input stream derivative that can parse from the memory buffer. </dd></dl>
By default, for safety's sake, each newly created stream from this input source will make its own copy of the buffer to stream from.
<p>
This avoids having to deal with aliasing of the buffer for simple work. But, for higher performance applications or for large buffers, this is obviously not optimal.<p>
In such cases, you can call this method to turn off that default action. Once turned off, the streams will just get a pointer to the buffer and parse directly from that. In this case, you must insure that the buffer remains valid for as long as any parse events are still using it.<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>newState</em> </td><td>The new boolean flag state to set. </td></tr>
This methods allows the <aclass="el"href="classxercesc_1_1MemBufInputSource.html">MemBufInputSource</a> to be used for more than one input source, instead of destructing/constructing another <aclass="el"href="classxercesc_1_1MemBufInputSource.html">MemBufInputSource</a>.
<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>srcDocBytes</em> </td><td>The actual data buffer to be parsed from. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>byteCount</em> </td><td>The count of bytes (not characters, bytes!) in the buffer. </td></tr>