Difference between revisions of "LavishSettings:settingset (Object Type)"
Jump to navigation
Jump to search
(6 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
* [[LavishSettings:settingset (Object Type)|settingset]] '''FindSet['''name''']''': Retrieve a child set by name | * [[LavishSettings:settingset (Object Type)|settingset]] '''FindSet['''name''']''': Retrieve a child set by name | ||
* [[LavishSettings:setting (Object Type)|setting]] '''FindSetting['''name''']''': Retrieve a child setting by name | * [[LavishSettings:setting (Object Type)|setting]] '''FindSetting['''name''']''': Retrieve a child setting by name | ||
+ | * [[LavishSettings:setting (Object Type)|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 | * ... '''Children''': Retrieves the first child node, if any, in this set | ||
+ | * [[LavishSettings:settingattribute (Object Type)|settingattribute]] '''FindAttribute['''Name''']''': Finds an Attribute on this set by name | ||
+ | * [[LavishSettings:settingattribute (Object Type)|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 == | == Methods == | ||
*'''Import['''filename''']''': Imports a given LavishSettings XML file into this set | *'''Import['''filename''']''': Imports a given LavishSettings XML file into this set | ||
− | |||
*'''Export['''filename''']''': Exports this set to a given LavishSettings XML file | *'''Export['''filename''']''': Exports this set to a given LavishSettings XML file | ||
*'''AddSet['''name''']''': Creates a child set (sub-set) with the given name | *'''AddSet['''name''']''': Creates a child set (sub-set) with the given name | ||
Line 20: | Line 22: | ||
*'''Sort''': Sorts the children in this set alphabetically | *'''Sort''': Sorts the children in this set alphabetically | ||
*'''GetIterator['''iterator object''']''': Initializes the given iterator object for iteration of all children of this set | *'''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 | + | *'''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 | + | *'''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 | + | *'''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 == | == Examples == | ||
Line 51: | Line 54: | ||
variable int Count | variable int Count | ||
for (${Count}<${Indent};Count:Inc) | for (${Count}<${Indent};Count:Inc) | ||
− | |||
sIndent:Concat[.] | sIndent:Concat[.] | ||
− | + | ||
echo ${sIndent}${Set.Name} | echo ${sIndent}${Set.Name} | ||
if !${Iterator:First(exists)} | if !${Iterator:First(exists)} | ||
− | |||
return | return | ||
− | + | ||
+ | Indent:Inc | ||
do | do | ||
{ | { | ||
− | call DumpSubsets ${Iterator.Value.GUID} | + | call DumpSubsets ${Iterator.Value.GUID} ${Indent} |
} | } | ||
while ${Iterator:Next(exists)} | while ${Iterator:Next(exists)} | ||
Line 70: | Line 72: | ||
{ | { | ||
variable settingsetref Set=${LavishSettings[Lavish Software].GUID} | variable settingsetref Set=${LavishSettings[Lavish Software].GUID} | ||
− | + | call DumpSubsets ${Set} | |
− | call DumpSubsets ${ | ||
} | } | ||
;Output | ;Output |
Latest revision as of 18:39, 24 February 2009
Description
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
- Joe Thaler
- Employees
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