vfs: check userland buffers before reading them.
[haiku.git] / src / tests / add-ons / print / ppd / model / Statement.h
blobf8af47e38519e0a516cb33d0821b605b6807be46
1 /*
2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 */
9 #ifndef _STATEMENT_H
10 #define _STATEMENT_H
12 #include "StatementList.h"
13 #include "Value.h"
15 class Statement
17 public:
18 enum Type {
19 kDefault,
20 kQuery,
21 kValue,
22 kParam,
23 kUnknown
26 private:
27 Type fType;
28 BString* fKeyword;
29 Value* fOption;
30 Value* fValue;
31 StatementList* fChildren;
33 const char* ElementForType();
35 public:
36 Statement();
37 virtual ~Statement();
39 void SetType(Type type);
40 Type GetType();
42 void SetKeyword(BString* keyword);
43 // mandatory in a valid statement
44 BString* GetKeyword();
46 void SetOption(Value* value);
47 // optional in a valid statement
48 Value* GetOption();
50 void SetValue(Value* value);
51 // optional in a valid statement
52 Value* GetValue();
54 void AddChild(Statement* statement);
55 // optional in a valid statement
56 StatementList* GetChildren();
58 // convenience methods
59 bool IsDefaultStatement() { return fType == kDefault; }
60 bool IsQueryStatement() { return fType == kQuery; }
61 bool IsValueStatement() { return fType == kValue; }
62 bool IsParamStatement() { return fType == kParam; }
63 bool IsUnknownStatement() { return fType == kUnknown; }
65 const char* GetKeywordString();
66 const char* GetOptionString();
67 const char* GetTranslationString();
68 const char* GetValueString();
69 const char* GetValueTranslationString();
71 void Print();
74 #endif