00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Varien 00022 * @package Varien_Filter 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Template constructions tokenizer 00029 * 00030 * @category Varien 00031 * @package Varien_Filter 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 00035 abstract class Varien_Filter_Template_Tokenizer_Abstract 00036 { 00037 /** 00038 * Current index in string 00039 * @var int 00040 */ 00041 protected $_currentIndex; 00042 00043 /** 00044 * String for tokenize 00045 */ 00046 protected $_string; 00047 00048 /** 00049 * Move current index to next char. 00050 * 00051 * If index out of bounds returns false 00052 * 00053 * @return boolean 00054 */ 00055 public function next() 00056 { 00057 if($this->_currentIndex + 1 >= strlen($this->_string)) { 00058 return false; 00059 } 00060 00061 $this->_currentIndex++; 00062 return true; 00063 } 00064 00065 /** 00066 * Move current index to previus char. 00067 * 00068 * If index out of bounds returns false 00069 * 00070 * @return boolean 00071 */ 00072 public function prev() 00073 { 00074 if($this->_currentIndex - 1 < 0) { 00075 return false; 00076 } 00077 00078 $this->_currentIndex--; 00079 return true; 00080 } 00081 00082 /** 00083 * Return current char 00084 * 00085 * @return string 00086 */ 00087 public function char() 00088 { 00089 return $this->_string{$this->_currentIndex}; 00090 } 00091 00092 00093 /** 00094 * Set string for tokenize 00095 */ 00096 public function setString($value) 00097 { 00098 $this->_string = $value; 00099 $this->reset(); 00100 } 00101 00102 /** 00103 * Move char index to begin of string 00104 */ 00105 public function reset() 00106 { 00107 $this->_currentIndex = 0; 00108 } 00109 00110 /** 00111 * Return true if current char is white-space 00112 * 00113 * @return boolean 00114 */ 00115 public function isWhiteSpace() { 00116 return trim($this->char()) != $this->char(); 00117 } 00118 00119 abstract public function tokenize(); 00120 00121 }