<!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> <title>Parrot - Mapped byte array</title> <link rel="stylesheet" type="text/css" href="../../../resources/parrot.css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="wrapper"> <div id="header"> <a href="http://www.parrot.org"> <img border=0 src="../../../resources/parrot_logo.png" id="logo" alt="parrot"> </a> </div> <!-- "header" --> <div id="divider"></div> <div id="mainbody"> <div id="breadcrumb"> <a href="../../../html/index.html">Home</a> » <a href="../../../html/pmc.html">PMCs</a> » Mapped byte array </div> <h1><a name="NAME" >NAME</a></h1> <p>src/pmc/mappedbytearray.pmc - Mapped byte array</p> <h1><a name="DESCRIPTION" >DESCRIPTION</a></h1> <p>A memory mapped file or shared memory segment accesible as array of bytes.</p> <p>Bare minimal functionality available, only for posix platforms (tested on linux).</p> <h2><a name="Vtable_Functions" >Vtable Functions</a></h2> <dl> <dt><a name="init()" ><b><code>init()</b></code></a></dt> Initialize without doing any mapping. <dt><a name="init_pmc(PMC_*init)" ><b><code>init_pmc(PMC *init)</b></code></a></dt> The argument must be a String PMC with a file name. Maps the whole file.Other options still not available. <dt><a name="destroy()" ><b><code>destroy()</b></code></a></dt> Free all resources used. <dt><a name="get_bool()" ><b><code>get_bool()</b></code></a></dt> Return true if active, false otherwise. <dt><a name="elements()" ><b><code>elements()</b></code></a></dt> Return the size of the mapped area. <dt><a name="get_integer_keyed_int(INTVAL_pos)" ><b><code>get_integer_keyed_int(INTVAL pos)</b></code></a></dt> Get the byte at pos. <dt><a name="set_integer_keyed_int(INTVAL_pos,_INTVAL_value)" ><b><code>set_integer_keyed_int(INTVAL pos, INTVAL value)</b></code></a></dt> Set the byte at pos to value.</dl> <h2><a name="Methods" >Methods</a></h2> <dl> <dt><a name="supported()" ><b><code>supported()</b></code></a></dt> Return 0 if file mapping is not supported, non zero otherwise. <dt><a name="open(STRING_*filename,_STRING_*mode_:optional)" ><b><code>open(STRING *filename, STRING *mode :optional)</b></code></a></dt> Map a file by its name. The mode argument can be "r", "w" or "rw", "r" is assumed if omitted. <dt><a name="close()" ><b><code>close()</b></code></a></dt> Close the mapping. Return 0 if the mapping was opened aand the unmap operation does not fail, non zero otherwise. <dt><a name="get_string(INTVAL_pos,_INTVAL_bytelength,_STRING_*encodingname)" ><b><code>get_string(INTVAL pos, INTVAL bytelength, STRING *encodingname)</b></code></a></dt> Get a string from the buffer content with the specified encoding. <dt><a name="get_chars(INTVAL_pos,_INTVAL_length)" ><b><code>get_chars(INTVAL pos, INTVAL length)</b></code></a></dt> Get a string from the buffer content with the specified encoding and length in codepoints. <dt><a name="get_utf8(INTVAL_pos,_INTVAL_length)" ><b><code>get_utf8(INTVAL pos, INTVAL length)</b></code></a></dt> Get a utf8 string from the buffer content with the specified length in codepoints.</dl> <h2><a name="Helper_functions" >Helper functions</a></h2> <dl> <dt><a name="static_void_unavailable(PARROT_INTERP,_const_char_*msg)" ><b><code>static void unavailable(PARROT_INTERP, const char *msg)</b></code></a></dt> Throws appropiately for functionality not available in the current platform. <dt><a name="static_void_*_mapfromfilehandle(PIOHANDLE_handle,_unsigned_long_size,_int_flag)" ><b><code>static void * mapfromfilehandle(PIOHANDLE handle, unsigned long size, int flag)</b></code></a></dt> Maps a file by its OS handle. <dt><a name="static_void_*_mapfromfilename(PARROT_INTERP,_STRING_*name,_unsigned_long_*size,_int_flag)" ><b><code>static void * mapfromfilename(PARROT_INTERP, STRING *name, unsigned long *size, int flag)</b></code></a></dt> Maps a file by its filename, throw if the file can't be opened. <dt><a name="static_STRING_*_build_string(PARROT_INTERP,_const_unsigned_char_*content,_INTVAL_size,_const_STR_VTABLE_*encoding)" ><b><code>static STRING * build_string(PARROT_INTERP, const unsigned char *content, INTVAL size, const STR_VTABLE *encoding)</b></code></a></dt> Build a string from the buffer content with the encoding specified. <dt><a name="static_STRING_*_get_encoded_chars(PARROT_INTERP,_PMC_*self,_INTVAL_pos,_INTVAL_length,_const_STR_VTABLE_*encoding)" ><b><code>static STRING * get_encoded_chars(PARROT_INTERP, PMC *self, INTVAL pos, INTVAL length, const STR_VTABLE *encoding)</b></code></a></dt> Return the characters starting at pos in the specified encoding.</dl> </div> <!-- "mainbody" --> <div id="divider"></div> <div id="footer"> Copyright © 2002-2011, Parrot Foundation. </div> </div> <!-- "wrapper" --> </body> </html>