123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
-
-
-
-
-
- class Swift_CharacterReader_GenericFixedWidthReader
- implements Swift_CharacterReader
- {
-
-
-
- private $_width;
-
-
-
- public function __construct($width)
- {
- $this->_width = $width;
- }
-
-
-
- public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
- {
- $strlen = strlen($string);
-
- $ignored = $strlen%$this->_width;
- $ignoredChars = substr($string, - $ignored);
- $currentMap = $this->_width;
- return ($strlen - $ignored)/$this->_width;
-
- }
-
-
-
- public function getMapType()
- {
- return self::MAP_TYPE_FIXED_LEN;
- }
-
-
-
- public function validateByteSequence($bytes, $size)
- {
- $needed = $this->_width - $size;
- return ($needed > -1)
- ? $needed
- : -1
- ;
- }
-
-
-
- public function getInitialByteSize()
- {
- return $this->_width;
- }
-
- }
|