2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
14 Statement::Statement()
23 Statement::~Statement()
31 void Statement::SetType(Type type
)
36 Statement::Type
Statement::GetType()
41 void Statement::SetKeyword(BString
* keyword
)
46 BString
* Statement::GetKeyword()
51 void Statement::SetOption(Value
* option
)
56 Value
* Statement::GetOption()
62 void Statement::SetValue(Value
* value
)
67 Value
* Statement::GetValue()
72 StatementList
* Statement::GetChildren()
77 void Statement::AddChild(Statement
* statement
)
79 if (fChildren
== NULL
) {
80 fChildren
= new StatementList(true);
82 fChildren
->Add(statement
);
85 const char* Statement::GetKeywordString()
87 if (fKeyword
!= NULL
) {
88 return fKeyword
->String();
93 const char* Statement::GetOptionString()
95 Value
* option
= GetOption();
97 return option
->GetValueString();
102 const char* Statement::GetTranslationString()
104 Value
* option
= GetOption();
105 if (option
!= NULL
) {
106 return option
->GetTranslationString();
111 const char* Statement::GetValueString()
113 Value
* value
= GetValue();
115 return value
->GetValueString();
120 const char* Statement::GetValueTranslationString()
122 Value
* value
= GetValue();
124 return value
->GetTranslationString();
130 const char* Statement::ElementForType() {
132 case kDefault
: return "Default";
134 case kParam
: return "Param";
136 case kQuery
: return "Query";
138 case kValue
: return "Value";
140 case kUnknown
: return "Unknown";
146 void Statement::Print()
148 bool hasValue
= fValue
!= NULL
;
149 bool hasOption
= fOption
!= NULL
;
151 printf("<%s", ElementForType());
153 if (fKeyword
!= NULL
) {
154 printf(" keyword=\"%s\"", fKeyword
->String());
157 if (hasValue
|| hasOption
) {
165 printf("\t<option>\n");
167 printf("\t</option>\n");
172 printf("\t<value>\n");
174 printf("\t</value>\n");
177 if (GetChildren() != NULL
) {
178 printf("\t<children>\n");
179 GetChildren()->Print();
180 printf("\t</children>\n");
183 if (hasValue
|| hasOption
) {
184 printf("</%s>\n\n", ElementForType());