LavishSettings:settingset (Object Type)

From Lavish Software Wiki
Jump to navigation Jump to search

Description

Object Type Vitals
settingset
Defined By LavishSettings
Inherits settingnode
Reduces To the name of the set
Variable Object Type settingsetref
Uses Sub-Types no
C/C++ Type internal

Members

  • string Name: Name of this set
  • uint GUID: Unique ID of this set
  • settingset FindSet[name]: Retrieve a child set by name
  • setting FindSetting[name]: Retrieve a child setting by name
  • setting FindSetting[name,default value]: Retrieve a child setting by name, creating it first with the default value if it does not already exist
  • ... Children: Retrieves the first child node, if any, in this set
  • settingattribute FindAttribute[Name]: Finds an Attribute on this set by name
  • settingattribute FindAttribute[Name,auto-create with default value]: Finds an Attribute on this set by name, creating it first with the given value if it does not exist

Methods

  • Import[filename]: Imports a given LavishSettings XML file into this set
  • Export[filename]: Exports this set to a given LavishSettings XML file
  • AddSet[name]: Creates a child set (sub-set) with the given name
  • AddComment[text]: Creates a child comment with the given text
  • AddSetting[name,value]: Creates a child setting with the given name and value
  • Rename[name]: Renames this set with the given name
  • Clear: Clears (destroys) all children from this set
  • Sort: Sorts the children in this set alphabetically
  • GetIterator[iterator object]: Initializes the given iterator object for iteration of all children of this set
  • GetSetIterator[iterator object]: Initializes the given iterator object for iteration of all child sets of this set (Key=string, Value=settingset)
  • GetSettingIterator[iterator object]: Initializes the given iterator object for iteration of all child settings of this set (Key=string, Value=setting)
  • GetCommentIterator[iterator object]: Initializes the given iterator object for iteration of all child comments of this set (Key=NULL, Value=settingcomment)
  • AddAttribute[name,value]: Adds an attribute to this setting, with the given name and value

Examples

Given the following data

  • Lavish Software
    • Employees
      • Joe Thaler
        • Address=123 Elm St
        • Phone Number=1-800-123-4567
        • Username=Lax
      • Dan Thaler
        • Address=456 Elm St
        • Phone Number=1-800-765-4321
        • Username=NinePointOh

Example 1

Using settingsetref to optimize multiple accesses to a set
variable settingsetref Set=${LavishSettings[Lavish Software].FindSet[Employees].FindSet[Joe Thaler].GUID}
echo ${Set.FindSetting[Address]} ${Set.FindSetting[Phone]} ${Set.FindSetting[Username]}

Example 2

Iterating sub-sets
function DumpSubsets(settingsetref Set, uint Indent=1)
{
  variable iterator Iterator
  Set:GetSetIterator[Iterator]

  variable string sIndent
  variable int Count
  for (${Count}<${Indent};Count:Inc)
    sIndent:Concat[.]

  echo ${sIndent}${Set.Name}

  if !${Iterator:First(exists)}
     return

  Indent:Inc
  do
  {
     call DumpSubsets ${Iterator.Value.GUID} ${Indent}
  }
  while ${Iterator:Next(exists)}
}

function main()
{
  variable settingsetref Set=${LavishSettings[Lavish Software].GUID}
  call DumpSubsets ${Set}
} 
Output
.Lavish Software
..Employees
...Joe Thaler
...Dan Thaler

See Also