BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/util/Bs_IniHandler.class.php
BlueShoes Application Framework - util

Bs_IniHandler

Bs_Object
   |
  +-- Bs_IniHandler

**********************************************************************

 

public class Bs_IniHandler extends Bs_Object

**********************************************************************
This class provides methods to work with ini-style files.E.g.# Comment[Some test data]one = hallotwo = "hallo"food = "Tom's Pizza = 'good stuff'"more food = Sam's Pizza's = 'best stuff'empty = ""noVal =[more test data]one = hitwo = 'hi'food = 'Pizza = "good"'empty = ''noValno dependencies here.

Authors,
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_IniHandler([ string $fileFullPath ])

Constructor.
bool

loadFile(string $fileFullPath)

Loads the given file (read in and parse).
bool

loadString(string $str)

loads the ini stuff from the given string instead of a file (read in and parse).
void

setQuoteHandling([ string $mode ])

sets the quote handling.
bool

saveFile(string $fileFullPath)

saves the ini settings to the file specified.
void

reset()

resets this object so we can re-use it for something else.
mixed

get([ string $section, string $key ])

returns [all parameters|parameter] [for the given section].
bool

has(string $section, [ string $key ])

tells if the section or key specified is set.
mixed

getLastError()

returns the text message of the last error that occured.

Private Method Summary

void

_parseFromArray(array $arr)

gets called from loadFile() and loadString() to parse the data.
void

toString()

Warning: documentation is missing.

Public Field Summary

array

$commentChars

specifies which chars at the start of a line define a comment line.
string

$unQuote

should quoted values be unquoted?

Private Field Summary

array

$_sections

vector with the sections as strings.
array

$_params

2-dim hash where the first dim is a hash with the section names, the 2nd
unknown

$comments

string

$_fileFullPath

the fullpath to the currently used file.
string

$_lastError

the last error message of the error that occured. not set = no error.

Private Constant Summary

BS_INIHANDLER_VERSION >>4.0.$x$<< Warning: documentation is missing.
BS_INIHANDLER_UNQUOTE_NONE >>0<< Warning: documentation is missing.
BS_INIHANDLER_UNQUOTE_DOUBLE >>1<< Warning: documentation is missing.
BS_INIHANDLER_UNQUOTE_SINGLE >>2<< Warning: documentation is missing.
BS_INIHANDLER_UNQUOTE_ALL >>3<< Warning: documentation is missing.

Public Method Details

Bs_IniHandler

public void Bs_IniHandler( [ string $fileFullPath ] )

  Constructor.
WARNING: please do not use the param $fileFullPath here, better call loadFile() yourselfbecause otherwise you won't know if it worked or not.

Parameter
string $fileFullPath = >>''<<
Returns void


loadFile

public bool loadFile( string $fileFullPath )

  Loads the given file (read in and parse).

Parameter
string $fileFullPath
(a fullpath to the desired file.)
Returns bool

(see getLastError())


loadString

public bool loadString( string $str )

  loads the ini stuff from the given string instead of a file (read in and parse).

Parameter
string $str
Returns bool

(see getLastError())


setQuoteHandling

public void setQuoteHandling( [ string $mode ] )

  sets the quote handling.

Parameter
string $mode = >>BS_INIHANDLER_UNQUOTE_ALL<<
(see constants)
Returns void


saveFile

public bool saveFile( string $fileFullPath )

  saves the ini settings to the file specified.

Parameter
string $fileFullPath
(see above)
Returns bool

(see getLastError())


reset

public void reset( )

  resets this object so we can re-use it for something else.
some setting vars are not reset.resets:_sections_params_fileFullPath_lastErrorkeeps:commentCharsunQuote

Returns void


get

public mixed get( [ string $section, string $key ] )

  returns [all parameters|parameter] [for the given section].
examples:get() => returns all sections with all params as 2-D hash.array of [<section>][<key>] => <string>get('section') => returns all params for the section specified as 1-D hash.array of [<key>] => <string>get('section', 'key') => returns the param specified of the section specified as string.note: if a param is defined in the 'global scope', use an empty string for the$section name. example: get('', 'key')

Parameter
string $section = >>NULL,<<
if not given returns all sections
string $key = >>NULL<<
if not given returns all keys
Returns mixed

(see above)

Throws null (if the given section or key does not exist)

has

public bool has( string $section, [ string $key ] )

  tells if the section or key specified is set.
examples:has('mySection') => tells if 'mySection' is sethas('mySection', 'myKey' => tells if myKey in mySection is set.note: case matters!

Parameter
string $section
string $key = >>NULL<<
(default is NULL)
Returns bool


getLastError

public mixed getLastError( )

  returns the text message of the last error that occured.
call this function if something failed, for example after gettingbool FALSE back from loadFile().

Returns mixed

(string last error, or NULL if no error occured.)


Private Method Details

_parseFromArray

private void _parseFromArray( array $arr )

  gets called from loadFile() and loadString() to parse the data.

Parameter
array $arr
(vector filled with strings (lines))
Returns void


toString

private void toString( )

 

Warning: documentation is missing.

Returns void


Public Field Details

$commentChars

public array $commentChars

>>array('#', '/', ';')<<

specifies which chars at the start of a line define a comment line.
the line is left-trimmed before the comparison is made.default: '#', '/', ';'note: you can only specify chars, not strings. so if you want '//' ascomment char, you need to define '/'. (which is done by default)


$unQuote

public string $unQuote

>>BS_INIHANDLER_UNQUOTE_ALL<<

should quoted values be unquoted?
0 = noBS_INIHANDLER_UNQUOTE_SINGLE = only single-quotes 'like this'BS_INIHANDLER_UNQUOTE_DOUBLE = only double-quotes "like this"BS_INIHANDLER_UNQUOTE_ALL = single and double quotes (default)


Private Field Details

$_sections

private array $_sections

>><<

vector with the sections as strings.
note: since this var is not really needed, and all information is available in$this->_params, this internal var may disappear in the future.


$_params

private array $_params

>><<

2-dim hash where the first dim is a hash with the section names, the 2nd
is the key/value pair hash.


$comments

private unknown $comments

>><<



$_fileFullPath

private string $_fileFullPath

>><<

the fullpath to the currently used file.


$_lastError

private string $_lastError

>><<

the last error message of the error that occured. not set = no error.


Private Constant Details

BS_INIHANDLER_VERSION

define( BS_INIHANDLER_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



BS_INIHANDLER_UNQUOTE_NONE

define( BS_INIHANDLER_UNQUOTE_NONE, >>0<< )
Case: default: case sensitive



BS_INIHANDLER_UNQUOTE_DOUBLE

define( BS_INIHANDLER_UNQUOTE_DOUBLE, >>1<< )
Case: default: case sensitive



BS_INIHANDLER_UNQUOTE_SINGLE

define( BS_INIHANDLER_UNQUOTE_SINGLE, >>2<< )
Case: default: case sensitive



BS_INIHANDLER_UNQUOTE_ALL

define( BS_INIHANDLER_UNQUOTE_ALL, >>3<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta