Imported Upstream version 0.1
[debian/configureit.git] / string.go
1 // string.go
2 //
3 // String Type
4
5 package configureit
6
7 import (
8         "os"
9 )
10
11 type StringOption struct {      
12         defaultvalue    string
13         isset           bool
14         Value           string
15 }
16
17 func NewStringOption(defaultValue string) ConfigNode {
18         opt := new(StringOption)
19
20         opt.defaultvalue = defaultValue
21         opt.Reset()
22
23         return opt
24 }
25
26 func (opt *StringOption) String() string {
27         return opt.Value
28 }
29
30 func (opt *StringOption) Parse(newValue string) os.Error {
31         opt.Value = newValue
32         opt.isset = true
33
34         return nil
35 }
36
37 func (opt *StringOption) IsDefault() bool {
38         return !opt.isset
39 }
40
41 func (opt *StringOption) Reset() {
42         opt.Value = opt.defaultvalue
43         opt.isset = false
44 }