Javascript ConfigFile: Difference between revisions

From Yate Documentation
Jump to navigation Jump to search
Created page with "Configuration File handling object. ==Constructor== new ConfigFile(); new ConfigFile(path); new ConfigFile(path,warn); Where: * path - Relative or absolute path to the Confi..."
 
Line 47: Line 47:


* '''getValue(section,key,defValue)'''
* '''getValue(section,key,defValue)'''
Retrieves the value of ''key'' in ''section''. Returns ''defValur'' if the key or section does not exist.
Retrieves the value of ''key'' in ''section''. Returns ''defValue'' if the key or section does not exist.


* '''setValue(section,key,value)'''
* '''setValue(section,key,value)'''

Revision as of 11:55, 1 April 2014

Configuration File handling object.

Constructor

new ConfigFile(); new ConfigFile(path); new ConfigFile(path,warn);

Where:

  • path - Relative or absolute path to the Configuration file like "/path/to/file.conf"
  • warn - True to warn if the file does not exist

Methods

  • name()

Returns the path of the Configuration file.

  • name(path)

Sets a new file path

  • load(warn)

Loads the file content, optionally warns if it doesn't exist.

Returns true on success or false if the file does not exist.

  • save()

Saves the file overwriting any existing content.

Returns true on success or false if the file could not be written.

  • count()

Returns the number of sections in the file.

  • sections()

Returns an associative Array containing ConfigSection objects representing each file section.

  • getSection(name)

Returns a ConfigSection object for the section name.

Returns null if the section does not exist.

  • getSection(name,create)

Returns a ConfigSection object for the section name, creates it if create is true.

Returns null if the section could not be created.

  • getValue(section,key)

Retrieves the value of key in section. Returns undefined if the key or section does not exist.

  • getValue(section,key,defValue)

Retrieves the value of key in section. Returns defValue if the key or section does not exist.

  • setValue(section,key,value)

Sets the value for key in specified file section.

  • clearKey(section,key)

Deletes the key from specified file section.

  • keys(section)

Returns a numbered (non-associative) Array containing all the key names in section.