Class: Buffer
- Package: saf.Parser
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 0.8, 2003-01-20, $Id: Buffer.php,v 1.3 2007/10/06 00:06:30 lux Exp $
- Access: public
Buffer implements string, array, and tree structure buffering for
classes extending saf.Parser. This makes management of cumulative data
easier during the analysis of a big ugly pile of tokens.
One might call the combination of this and saf.Parser something of a
Finite State Machine (FSM), but not quite. Callbacks (like transitions)
are handled by saf.Parser, which would use Buffer to store data in a
Push-Down Automata (PDA) like manner. The current state can be stored
in a private property of the saf.Parser object.
Usage Example
<?php
$buff = new Buffer;
// sets $output to 'Foo bar'
$buff->set ('Foo bar');
// adds ' asdf qwerty to $output
$buff->append (' asdf qwerty');
// returns $output
echo $buff->get ();
?>
Return to Top
Properties
$output = ''
The string buffer.
$buffers = array ()
The array buffer.
Return to Top
Methods
set ($name, $data = false)
- Access: public
- Return: mixed
Sets a buffer value. If only one parameter is passed,
it will assume that you want it to go into the $output property.
If two are passed, it will put it into $buffers. If the first
value is false, it will append it to $buffers without specifying
the key. Returns true for named buffers and data sent to $output,
and returns the number of the buffered data in the absense of a
key.
append ($name, $data = false)
- Access: public
- Return: mixed
Appends to a buffer value. Same rules as set() apply
as to how the parameters are interpreted (this applies to all
methods here), and what is returned. Note: On unnamed arrays,
append() appends the value to the end of the array, and not
to the end of the last element in the array.
prepend ($name, $data = false)
- Access: public
- Return: mixed
Preppends to a buffer value. Note: On unnamed arrays,
append() appends the value to the end of the array, and not
to the start of an element in the array.
clear ($name = false)
Clears a buffer value.
get ($name = false)
- Access: public
- Return: mixed
Retrieves the specified value from the buffers.
getAll ()
- Access: public
- Return: array
Returns the entire $buffers array.
Return to Top