1 /* 2 * Copyright 2008, Haiku. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Michael Pfeiffer <laplace@users.sourceforge.net> 7 */ 8 9 #ifndef _STATEMENT_H 10 #define _STATEMENT_H 11 12 #include "StatementList.h" 13 #include "Value.h" 14 15 class Statement 16 { 17 public: 18 enum Type { 19 kDefault, 20 kQuery, 21 kValue, 22 kParam, 23 kUnknown 24 }; 25 26 private: 27 Type fType; 28 BString* fKeyword; 29 Value* fOption; 30 Value* fValue; 31 StatementList* fChildren; 32 33 const char* ElementForType(); 34 35 public: 36 Statement(); 37 virtual ~Statement(); 38 39 void SetType(Type type); 40 Type GetType(); 41 42 void SetKeyword(BString* keyword); 43 // mandatory in a valid statement 44 BString* GetKeyword(); 45 46 void SetOption(Value* value); 47 // optional in a valid statement 48 Value* GetOption(); 49 50 void SetValue(Value* value); 51 // optional in a valid statement 52 Value* GetValue(); 53 54 void AddChild(Statement* statement); 55 // optional in a valid statement 56 StatementList* GetChildren(); 57 58 // convenience methods IsDefaultStatement()59 bool IsDefaultStatement() { return fType == kDefault; } IsQueryStatement()60 bool IsQueryStatement() { return fType == kQuery; } IsValueStatement()61 bool IsValueStatement() { return fType == kValue; } IsParamStatement()62 bool IsParamStatement() { return fType == kParam; } IsUnknownStatement()63 bool IsUnknownStatement() { return fType == kUnknown; } 64 65 const char* GetKeywordString(); 66 const char* GetOptionString(); 67 const char* GetTranslationString(); 68 const char* GetValueString(); 69 const char* GetValueTranslationString(); 70 71 void Print(); 72 }; 73 74 #endif 75