2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
9 #include "StatementWrapper.h"
11 static const char* kOpenUIStatement
= "OpenUI";
12 static const char* kCloseUIStatement
= "CloseUI";
14 static const char* kOpenGroupStatement
= "OpenGroup";
15 static const char* kCloseGroupStatement
= "CloseGroup";
16 static const char* kOpenSubGroupStatement
= "OpenSubGroup";
17 static const char* kCloseSubGroupStatement
= "CloseSubGroup";
20 static const char* kJCL
= "JCL";
21 static const char* kJCLOpenUIStatement
= "JCLOpenUI";
22 static const char* kJCLCloseUIStatement
= "JCLCloseUI";
25 StatementWrapper::StatementWrapper(Statement
* statement
)
26 : fStatement(statement
)
31 GroupStatement::GroupStatement(Statement
* statement
)
32 : StatementWrapper(statement
)
37 bool GroupStatement::IsUIGroup()
39 return strcmp(GetKeyword(), kOpenUIStatement
) == 0;
42 bool GroupStatement::IsGroup()
44 return strcmp(GetKeyword(), kOpenGroupStatement
) == 0;
47 bool GroupStatement::IsSubGroup()
49 return strcmp(GetKeyword(), kOpenSubGroupStatement
) == 0;
52 bool GroupStatement::IsJCL()
54 return strstr(GetKeyword(), kJCL
) == GetKeyword();
57 bool GroupStatement::IsOpenGroup()
59 const char* keyword
= GetKeyword();
61 return strcmp(keyword
, kOpenUIStatement
) == 0 ||
62 strcmp(keyword
, kOpenGroupStatement
) == 0 ||
63 strcmp(keyword
, kOpenSubGroupStatement
) == 0 ||
64 strcmp(keyword
, kJCLOpenUIStatement
) == 0;
67 bool GroupStatement::IsCloseGroup()
69 const char* keyword
= GetKeyword();
71 return strcmp(keyword
, kCloseUIStatement
) == 0 ||
72 strcmp(keyword
, kCloseGroupStatement
) == 0 ||
73 strcmp(keyword
, kCloseSubGroupStatement
) == 0 ||
74 strcmp(keyword
, kJCLCloseUIStatement
) == 0;
77 Value
* GroupStatement::GetValue()
79 if (strcmp(GetKeyword(), kOpenUIStatement
) == 0 ||
80 strcmp(GetKeyword(), kJCLOpenUIStatement
) == 0) {
81 return GetStatement()->GetOption();
83 return GetStatement()->GetValue();
87 const char* GroupStatement::GetGroupName()
89 Value
* value
= GetValue();
90 if (value
== NULL
) return NULL
;
91 BString
* string
= value
->GetValue();
92 if (string
== NULL
) return NULL
;
93 const char* name
= string
->String();
94 if (name
!= NULL
&& *name
== '*') {
101 const char* GroupStatement::GetGroupTranslation()
103 Value
* value
= GetValue();
104 if (value
== NULL
) return NULL
;
105 BString
* string
= value
->GetTranslation();
106 if (string
== NULL
) return NULL
;
107 return string
->String();
110 GroupStatement::Type
GroupStatement::GetType()
112 const char* type
= GetStatement()->GetValueString();
113 if (type
== NULL
) return kUnknown
;
115 if (strstr(type
, "PickOne") != NULL
) return kPickOne
;
116 if (strstr(type
, "PickMany") != NULL
) return kPickMany
;
117 if (strstr(type
, "Boolean") != NULL
) return kBoolean
;