ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions
macro_parser_1_0_0 Class Reference

## Public Member Functions
| is_params_valid (&$Params, &$RegExValidators)
| handle_macro_start ($TmpStartPos, $TmpEndPos, &$StartPos, &$Counter)
| handle_macro_end ($TmpStartPos, $TmpEndPos, &$StartPos, &$Counter, $MacroStartPos)
| handle_macro_start_end (&$StringData, &$TmpStartPos, &$TmpEndPos, &$StartPos, &$Counter, $MacroStartPos)
| find_macro (&$StringData, &$TmpStartPos, &$TmpEndPos, &$StartPos, &$Counter, $MacroStartPos, $ParamStartPos, $RegExValidators)

## Detailed Description

String utilities.

Author
  Dodonov A.A.

Definition at line 26 of file macro_parser.php.

## Member Function Documentation

find_macro | ( | & | $StringData,
|  | & | $TmpStartPos,
|  | & | $TmpEndPos,
|  | & | $StartPos,
|  | & | $Counter,
|  |  | $MacroStartPos,
|  |  | $ParamStartPos,
|  |  | $RegExValidators
| ) |  |

Macro end.

Parameters

  $StringData | - String data.
  $TmpStartPos | - Macro start.
  $TmpEndPos | - Macro end.
  $StartPos | - Macro start.
  $Counter | - Counter.
  $MacroStartPos | - Macro start.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 302 of file macro_parser.php.

{
try
{
do
{
$this->handle_macro_start_end(
$StringData , $TmpStartPos , $TmpEndPos , $StartPos , $Counter , $MacroStartPos
);
if( $Counter == 0 )
{
$Params = substr( $StringData , $ParamStartPos , $TmpEndPos - $ParamStartPos );
if( $this->is_params_valid( $Params , $RegExValidators ) )
{
return( $Params );
}
$TmpStartPos = false;
$StartPos = $MacroStartPos;
}
}
while( $TmpStartPos );
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

handle_macro_end | ( |  | $TmpStartPos,
|  |  | $TmpEndPos,
|  | & | $StartPos,
|  | & | $Counter,
|  |  | $MacroStartPos
| ) |  |

Macro end.

Parameters

  $TmpStartPos | - Macro start.
  $TmpEndPos | - Macro end.
  $StartPos | - Macro start.
  $Counter | - Counter.
  $MacroStartPos | - Macro start.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 177 of file macro_parser.php.

{
try
{
if( $TmpStartPos !== false && $TmpEndPos === false )
{
$Counter++;
$StartPos = $TmpStartPos;
}
if( $TmpStartPos === false && $TmpEndPos !== false )
{
$Counter--;
$StartPos = $TmpEndPos;
}
if( $TmpStartPos === false && $TmpEndPos === false )
{
/* ничего не найдено, поэтому внешний цикл закончен, да и внутренний тоже
$StartPos = strlen( $StringData ); */
$StartPos = $MacroStartPos;
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

handle_macro_start | ( |  | $TmpStartPos,
|  |  | $TmpEndPos,
|  | & | $StartPos,
|  | & | $Counter
| ) |  |

Macro start.

Parameters

  $TmpStartPos | - Macro start.
  $TmpEndPos | - Macro end.
  $StartPos | - Macro start.
  $Counter | - Counter.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 116 of file macro_parser.php.

{
try
{
if( $TmpStartPos !== false && $TmpEndPos !== false )
{
if( $TmpStartPos < $TmpEndPos )
{
$StartPos = $TmpEndPos;
}
if( $TmpEndPos < $TmpStartPos )
{
$Counter--;
if( $Counter )
{
$Counter++;
}
$StartPos = $TmpStartPos;
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

handle_macro_start_end | ( | & | $StringData,
|  | & | $TmpStartPos,
|  | & | $TmpEndPos,
|  | & | $StartPos,
|  | & | $Counter,
|  |  | $MacroStartPos
| ) |  |

Macro end.

Parameters

  $StringData | - String data.
  $TmpStartPos | - Macro start.
  $TmpEndPos | - Macro end.
  $StartPos | - Macro start.
  $Counter | - Counter.
  $MacroStartPos | - Macro start.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 244 of file macro_parser.php.

{
try
{
$TmpStartPos = strpos( $StringData , chr( 123 ) , $StartPos + 1 );
$TmpEndPos = strpos( $StringData , chr( 125 ) , $StartPos + 1 );
$this->handle_macro_start( $TmpStartPos , $TmpEndPos , $StartPos , $Counter );
$this->handle_macro_end(
$TmpStartPos , $TmpEndPos , $StartPos , $Counter , $MacroStartPos
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

is_params_valid | ( | & | $Params,
|  | & | $RegExValidators
| ) |  |

Function validates macro's parameters.

Parameters

  $Params | - Macro's parameters.
  $RegExValidators | - Regular expressions for parameters validation.

Returns
  true/false.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 54 of file macro_parser.php.

{
try
{
$Valid = true;
$Matches = array();
/* проверяем валидность параметров если надо */
if( count( $RegExValidators ) )
{
$ParamsList = explode( ';' , $Params );
foreach( $ParamsList as $key1 => $p )
{
$p = explode( '=' , $p );
foreach( $RegExValidators as $key2 => $rev )
{
if( $key2 == $p[ 0 ] )
{
$Result = preg_match( $rev , $p[ 1 ] , $Matches );
$Valid = count( $Matches ) == 0 ? false : $Valid;
break;
}
}
}
}
return( $Valid );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

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

- packages/string/packages/macro_parser/macro_parser.php