Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Xml\ReadWrite Class Reference
Inheritance diagram for Hoa\Xml\ReadWrite:

Public Member Functions

 __construct (Stream\IStream\In $stream, $initializeNamespace=true, $entityResolver=null, $autoSave=true)
 
 _close (Core\Event\Bucket $bucket)
 
 eof ()
 
 read ($length)
 
 readString ($length)
 
 readCharacter ()
 
 readBoolean ()
 
 readInteger ($length=1)
 
 readFloat ($length=1)
 
 readArray ($argument=null)
 
 readLine ()
 
 readAll ($offset=0)
 
 scanf ($format)
 
 readDOM ()
 
 write ($string, $length)
 
 writeString ($string)
 
 writeCharacter ($char)
 
 writeBoolean ($boolean)
 
 writeInteger ($integer)
 
 writeFloat ($float)
 
 writeArray (Array $array)
 
 writeLine ($line)
 
 writeAll ($string)
 
 truncate ($size)
 
 writeDOM (\DOMNode $dom)
 
 writeAttributes (Array $attributes)
 
 writeAttribute ($name, $value)
 
 isAutoSaveEnabled ()
 
- Public Member Functions inherited from Hoa\Xml\Xml
 __construct ($stream, Stream $innerStream, $initializeNamespace=true, $entityResolver=null)
 
 initializeNamespaces ()
 
 namespaceExists ($namespace)
 
 useNamespace ($namespace)
 
 getPrefix ($namespace)
 
 getNamespaces ()
 
 selectRoot ()
 
 selectAnyElements ()
 
 selectElements ($E=null)
 
 selectDescendantElements ($F=null)
 
 selectChildElements ($F=null)
 
 selectAdjacentSiblingElement ($F)
 
 selectSiblingElements ($F=null)
 
 querySelector ($query)
 
 querySelectorAll ($query)
 
 xpath ($path)
 
 __toString ()
 
 readAttributes ()
 
 readAttribute ($name)
 
 attributeExists ($name)
 
 readAttributesAsList ()
 
 readAttributeAsList ($name)
 
 readAttributesAsString ()
 
 readXML ()
 
 readDOM ()
 
 getName ()
 
 count ()
 
 getIterator ()
 
 __set ($name, $value)
 
 __get ($name)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 hasError ()
 
 getErrors ()
 
- Public Member Functions inherited from Hoa\Stream\Composite
 getInnerStream ()
 

Protected Attributes

 $_autoSave = true
 
- Protected Attributes inherited from Hoa\Xml\Xml
 $_namespaces = null
 
 $_errors = null
 
- Protected Attributes inherited from Hoa\Stream\Composite
 $_stream = null
 
 $_innerStream = null
 

Additional Inherited Members

- Protected Member Functions inherited from Hoa\Xml\Xml
 clearErrors ()
 
- Protected Member Functions inherited from Hoa\Stream\Composite
 setStream ($stream)
 
 getStream ()
 
 setInnerStream (Stream $innerStream)
 

Detailed Description

Class .

Read/write a XML element.

Definition at line 50 of file ReadWrite.php.

Constructor & Destructor Documentation

Hoa\Xml\ReadWrite::__construct ( Stream\IStream\In  $stream,
  $initializeNamespace = true,
  $entityResolver = null,
  $autoSave = true 
)

Start the stream reader/writer as if it is a XML document.

Parameters
\Hoa\Stream\IStream\In$streamStream to read/write.
bool$initializeNamespaceWhether we initialize namespaces.
mixed$entityResolverEntity resolver.
bool$autoSaveWhether we should auto-save.
Returns
void
Exceptions

Definition at line 79 of file ReadWrite.php.

84  {
85  if (true === $autoSave && !($stream instanceof Stream\IStream\Out)) {
86  throw new Exception(
87  'The stream %s (that has opened %s) must implement ' .
88  '\Hoa\Stream\IStream\In and \Hoa\Stream\IStream\Out interfaces.',
89  0,
90  [get_class($stream), $stream->getStreamName()]
91  );
92  }
93 
94  parent::__construct(
95  '\Hoa\Xml\Element\ReadWrite',
96  $stream,
97  $initializeNamespace,
98  $entityResolver
99  );
100 
101  if (true === $autoSave) {
102  event(
103  'hoa://Event/Stream/' . $stream->getStreamName() .
104  ':close-before'
105  )->attach(xcallable($this, '_close'));
106  }
107 
108  $this->_autoSave = $autoSave;
109 
110  return;
111  }

Member Function Documentation

Hoa\Xml\ReadWrite::_close ( Core\Event\Bucket  $bucket)

Do not use this method. It is called from the hoa://Event/Stream/...:close-before event. It transforms the XML tree as a XML string, truncates the stream to zero and writes all this string into the stream.

Parameters
\Hoa\Core\Event\Bucket$bucketEvent's bucket.
Returns
void

Definition at line 122 of file ReadWrite.php.

123  {
124  if (false === $this->isAutoSaveEnabled()) {
125  return;
126  }
127 
128  $handle = $this->getStream()->selectRoot()->asXML();
129 
130  if (true === $this->getInnerStream()->truncate(0)) {
131  $this->getInnerStream()->writeAll($handle);
132  }
133 
134  return;
135  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::eof ( )

Test for end-of-file.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 142 of file ReadWrite.php.

143  {
144  return $this->getStream()->eof();
145  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::isAutoSaveEnabled ( )

Check if we should auto-save the document.

Returns
string

Definition at line 416 of file ReadWrite.php.

417  {
418  return $this->_autoSave;
419  }

Here is the caller graph for this function:

Hoa\Xml\ReadWrite::read (   $length)

Read n characters.

Parameters
int$lengthLength.
Returns
string
Exceptions

Implements Hoa\Stream\IStream\In.

Definition at line 154 of file ReadWrite.php.

155  {
156  return $this->getStream()->read($length);
157  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readAll (   $offset = 0)

Read all, i.e. read as much as possible.

Parameters
int$offsetOffset.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 239 of file ReadWrite.php.

240  {
241  return $this->getStream()->readAll($offset);
242  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readArray (   $argument = null)

Read the XML tree as an array.

Parameters
string$argumentNot use here.
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 218 of file ReadWrite.php.

219  {
220  return $this->getStream()->readArray($argument);
221  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readBoolean ( )

Read a boolean.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 185 of file ReadWrite.php.

186  {
187  return $this->getStream()->readBoolean();
188  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readCharacter ( )

Read a character.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 175 of file ReadWrite.php.

176  {
177  return $this->getStream()->readCharacter();
178  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readDOM ( )

Read content as a DOM tree.

Returns

Definition at line 260 of file ReadWrite.php.

261  {
262  return $this->getStream()->readDOM();
263  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readFloat (   $length = 1)

Read a float.

Parameters
int$lengthLength.
Returns
float

Implements Hoa\Stream\IStream\In.

Definition at line 207 of file ReadWrite.php.

208  {
209  return $this->getStream()->readFloat($length);
210  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readInteger (   $length = 1)

Read an integer.

Parameters
int$lengthLength.
Returns
int

Implements Hoa\Stream\IStream\In.

Definition at line 196 of file ReadWrite.php.

197  {
198  return $this->getStream()->readInteger($length);
199  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readLine ( )

Read a line.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 228 of file ReadWrite.php.

229  {
230  return $this->getStream()->readLine();
231  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::readString (   $length)

Alias of $this->read().

Parameters
int$lengthLength.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 165 of file ReadWrite.php.

166  {
167  return $this->getStream()->readString($length);
168  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::scanf (   $format)

Parse input from a stream according to a format.

Parameters
string$formatFormat (see printf's formats).
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 250 of file ReadWrite.php.

251  {
252  return $this->getStream()->scanf($format);
253  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::truncate (   $size)

Truncate to a given length.

Parameters
int$sizeSize.
Returns
bool

Implements Hoa\Stream\IStream\Out.

Definition at line 372 of file ReadWrite.php.

373  {
374  return $this->getStream()->truncate($size);
375  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xml\ReadWrite::write (   $string,
  $length 
)

Write n characters.

Parameters
string$stringString.
int$lengthLength.
Returns
mixed
Exceptions

Implements Hoa\Stream\IStream\Out.

Definition at line 273 of file ReadWrite.php.

274  {
275  return $this->getStream()->write($string, $length);
276  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeAll (   $string)

Write all, i.e. as much as possible.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 361 of file ReadWrite.php.

362  {
363  return $this->getStream()->writeAll($string);
364  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeArray ( Array  $array)

Write an array.

Parameters
array$arrayArray.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 339 of file ReadWrite.php.

340  {
341  return $this->getStream()->writeArray($array);
342  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeAttribute (   $name,
  $value 
)

Write an attribute.

Parameters
string$nameName.
string$valueValue.
Returns
void

Definition at line 406 of file ReadWrite.php.

407  {
408  return $this->getStream()->writeAttribute($name, $value);
409  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeAttributes ( Array  $attributes)

Write attributes.

Parameters
array$attributesAttributes.
Returns
void

Definition at line 394 of file ReadWrite.php.

395  {
396  return $this->getStream()->writeAttributes($attributes);
397  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeBoolean (   $boolean)

Write a boolean.

Parameters
bool$booleanBoolean.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 306 of file ReadWrite.php.

307  {
308  return $this->getStream()->writeBoolean($boolean);
309  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeCharacter (   $char)

Write a character.

Parameters
string$charCharacter.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 295 of file ReadWrite.php.

296  {
297  return $this->getStream()->writeCharacter($char);
298  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeDOM ( \DOMNode  $dom)

Write a DOM tree.

Parameters
\DOMNode$domDOM tree.
Returns
mixed

Definition at line 383 of file ReadWrite.php.

384  {
385  return $this->getStream()->writeDOM($dom);
386  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeFloat (   $float)

Write a float.

Parameters
float$floatFloat.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 328 of file ReadWrite.php.

329  {
330  return $this->getStream()->writeFloat($float);
331  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeInteger (   $integer)

Write an integer.

Parameters
int$integerInteger.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 317 of file ReadWrite.php.

318  {
319  return $this->getStream()->writeInteger($integer);
320  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeLine (   $line)

Write a line.

Parameters
string$lineLine.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 350 of file ReadWrite.php.

351  {
352  return $this->getStream()->writeLine($line);
353  }

Here is the call graph for this function:

Hoa\Xml\ReadWrite::writeString (   $string)

Write a string.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 284 of file ReadWrite.php.

285  {
286  return $this->getStream()->writeString($string);
287  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Xml\ReadWrite::$_autoSave = true
protected

Definition at line 60 of file ReadWrite.php.


The documentation for this class was generated from the following file: