2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
9 #include "StatementList.h"
10 #include "Statement.h"
14 StatementList::StatementList(bool ownsStatements
)
15 : fOwnsStatements(ownsStatements
)
19 StatementList::~StatementList()
21 if (fOwnsStatements
) {
22 for (int32 i
= 0; i
< Size(); i
++) {
23 Statement
* statement
= StatementAt(i
);
30 void StatementList::Add(Statement
* statement
)
32 fList
.AddItem(statement
);
35 void StatementList::Remove(Statement
* statement
)
37 fList
.RemoveItem(statement
);
40 int32
StatementList::Size()
42 return fList
.CountItems();
45 Statement
* StatementList::StatementAt(int32 index
)
47 return (Statement
*)fList
.ItemAt(index
);
50 Statement
* StatementList::GetStatement(const char* keyword
)
52 for (int32 i
= 0; i
< fList
.CountItems(); i
++) {
53 if (strcmp(keyword
, StatementAt(i
)->GetKeywordString()) == 0) {
54 return StatementAt(i
);
60 const char* StatementList::GetValue(const char* keyword
)
62 Statement
* statement
= GetStatement(keyword
);
63 if (statement
!= NULL
) {
64 return statement
->GetValueString();
69 void StatementList::Print()
71 for (int32 i
= 0; i
< Size(); i
++) {
72 StatementAt(i
)->Print();