1<?php 2/** 3 * C/C++ code specific extension of the Indent class 4 * 5 * PHP versions 5 6 * 7 * LICENSE: This source file is subject to version 3.0 of the PHP license 8 * that is available through the world-wide-web at the following URI: 9 * http://www.php.net/license/3_0.txt. If you did not receive a copy of 10 * the PHP License and are unable to obtain it through the web, please 11 * send a note to license@php.net so we can mail you a copy immediately. 12 * 13 * @category Tools and Utilities 14 * @package CodeGen 15 * @author Hartmut Holzgraefe <hartmut@php.net> 16 * @copyright 2005-2008 Hartmut Holzgraefe 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 * @version CVS: $Id: IndentC.php,v 1.3 2006/10/11 10:07:41 hholzgra Exp $ 19 * @link http://pear.php.net/package/CodeGen 20 */ 21 22require_once "CodeGen/Tools/Indent.php"; 23 24/** 25 * C/C++ code specific extension of the Indent class 26 * 27 * So far the only C/C++ specific stuff is that preprocessor commands 28 * require the # to be on the first column 29 * 30 * @category Tools and Utilities 31 * @package CodeGen 32 * @author Hartmut Holzgraefe <hartmut@php.net> 33 * @copyright 2005-2008 Hartmut Holzgraefe 34 * @license http://www.php.net/license/3_0.txt PHP License 3.0 35 * @version Release: @package_version@ 36 * @link http://pear.php.net/package/CodeGen 37 */ 38class CodeGen_Tools_IndentC 39 extends CodeGen_Tools_Indent 40{ 41 /** 42 * re-indent a block of text 43 * 44 * with C/C++ we need to make sure that preporcessor 45 * directives always start on the first column 46 * 47 * @access public 48 * @param int number of leading indent spaces 49 * @param string text to reindent 50 * @return string indented text 51 */ 52 function indent($level, $text) 53 { 54 $result = parent::indent($level, $text); 55 56 return preg_replace('/^\s+#/m', '#', $result); 57 } 58} 59 60/* 61 * Local variables: 62 * tab-width: 4 63 * c-basic-offset: 4 64 * indent-tabs-mode:nil 65 * End: 66 */ 67