Table of Contents

OIL2 Class Standard.ParseParameterFile


class Standard . ParseParameterFile {
        string  currentSectionName;
        assoc   dataBySection;
        any     defaultStorageFile;
        int32   lineCount;
        any     serviceName;
        oid     sleepingThread;
inherits from Object;

DESCRIPTION

The class ParseParameterFile can read/write/query small database files of attribute value pairs. Each file can be broken into sections, providing a two-level hierarchy. A ParseParameterFile can also be registered as a named service, allowing convenient treatment as a globally accessible database.

METHODS


Standard.ParseParameterFile:create

ParseParameterFile:create(any ioObj, string servName)

Method Description

See initialize.


Standard.ParseParameterFile:initialize

ParseParameterFile:initialize(any ioObj, string servName)

Method Description


Standard.ParseParameterFile:getSectionData

ParseParameterFile:getSectionData(string sectionName, string key)

Method Description

If no arguments are present, the entire database contents are returned as an associative array; otherwise, data associated with the section identified by sectionName will be returned. If sectionName is the null string, the default section is used. If the indicated section does not exist, nil will be returned. The second argument, key, is also optional. If not present, all of the data of the indicated section will be returned; otherwise, only the indicated element will be returned.


Standard.ParseParameterFile:addEntry

ParseParameterFile:addEntry(string sectionName, string key, any value)

Method Description

Adds a new attribute/value entry to the section indicated by sectionName. If sectionName is the null string, the default section is used.

Return Value

If fromObject is not nil, then zero is returned.


Standard.ParseParameterFile:addEntries

ParseParameterFile:addEntries(string sectionName, assoc vals)

Method Description

Adds a collection of attribute/value pairs to the section indicated by sectionName. If sectionName is the null string, the default section is used. The attribute names are obtained from the subscripts of the associative array vals; the values are taken from the corresponding entries.

Return Value

If fromObject is not nil, then zero is returned.


Standard.ParseParameterFile:deleteEntry

ParseParameterFile:deleteEntry(string sectionName, string key)

Method Description

Deletes an attribute value pair whose name is specified as key from the section identified by sectionName. If sectionName is the null string, the default section is used.

Return Value

If fromObject is not nil, a value indicating the success of the delete operation is returned. If the section named does not exist, -1 is returned. If the indicated attribute does not exist, 0 is returned. If the element did exist, then 1 is returned.


Standard.ParseParameterFile:deleteSection

ParseParameterFile:deleteSection(string sectionName)

Method Description

Deletes from the database an entire section, whose name is specified by sectionName. If sectionName is the null string, the default section is used.

Return Value

If fromObject is not nil, then zero is returned.


Standard.ParseParameterFile:getSectionNames

ParseParameterFile:getSectionNames()

Method Description

Returns an array of section names that are defined by the database.


Standard.ParseParameterFile:dumpToFile

ParseParameterFile:dumpToFile(any file)

Method Description

Writes the contents of the database to a file or open IOobject. If the file parameter is a string, it is treated as a file name, which will be used as an argument to create an IOobject. The file name can be specified using the "file:" scheme or a just a plain file name. If the file parameter is an object Id, it is used directly.

Return Value

If fromObject is not nil, a count of the number of records written to the file is returned. A value of -1 indicates an error.