1/*---------------------------------------------------------------------------*
2 *  ArrayList.c  *
3 *                                                                           *
4 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5 *                                                                           *
6 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7 *  you may not use this file except in compliance with the License.         *
8 *                                                                           *
9 *  You may obtain a copy of the License at                                  *
10 *      http://www.apache.org/licenses/LICENSE-2.0                           *
11 *                                                                           *
12 *  Unless required by applicable law or agreed to in writing, software      *
13 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 *  See the License for the specific language governing permissions and      *
16 *  limitations under the License.                                           *
17 *                                                                           *
18 *---------------------------------------------------------------------------*/
19
20
21
22#include "ArrayList.h"
23#include "plog.h"
24#include "pmemory.h"
25
26
27ESR_ReturnCode ArrayListAdd(ArrayList* self, void* element)
28{
29  if (self == NULL)
30  {
31    PLogError(L("ESR_INVALID_ARGUMENT"));
32    return ESR_INVALID_ARGUMENT;
33  }
34  return self->add(self, element);
35}
36
37ESR_ReturnCode ArrayListInsertAt(ArrayList* self, size_t index, void* element)
38{
39  if (self == NULL)
40  {
41    PLogError(L("ESR_INVALID_ARGUMENT"));
42    return ESR_INVALID_ARGUMENT;
43  }
44  return self->insertAt(self, index, element);
45}
46
47ESR_ReturnCode ArrayListRemove(ArrayList* self, void* element)
48{
49  if (self == NULL)
50  {
51    PLogError(L("ESR_INVALID_ARGUMENT"));
52    return ESR_INVALID_ARGUMENT;
53  }
54  return self->remove(self, element);
55}
56
57ESR_ReturnCode ArrayListRemoveAtIndex(ArrayList* self, size_t index)
58{
59  if (self == NULL)
60  {
61    PLogError(L("ESR_INVALID_ARGUMENT"));
62    return ESR_INVALID_ARGUMENT;
63  }
64  return self->removeAtIndex(self, index);
65}
66
67ESR_ReturnCode ArrayListRemoveAll(ArrayList* self)
68{
69  if (self == NULL)
70  {
71    PLogError(L("ESR_INVALID_ARGUMENT"));
72    return ESR_INVALID_ARGUMENT;
73  }
74  return self->removeAll(self);
75}
76
77ESR_ReturnCode ArrayListContains(ArrayList* self, void* element, ESR_BOOL* exists)
78{
79  if (self == NULL)
80  {
81    PLogError(L("ESR_INVALID_ARGUMENT"));
82    return ESR_INVALID_ARGUMENT;
83  }
84  return self->contains(self, element, exists);
85}
86
87ESR_ReturnCode ArrayListGetSize(ArrayList* self, size_t* size)
88{
89  if (self == NULL)
90  {
91    PLogError(L("ESR_INVALID_ARGUMENT"));
92    return ESR_INVALID_ARGUMENT;
93  }
94  return self->getSize(self, size);
95}
96
97ESR_ReturnCode ArrayListGet(ArrayList* self, size_t index, void** element)
98{
99  if (self == NULL)
100  {
101    PLogError(L("ESR_INVALID_ARGUMENT"));
102    return ESR_INVALID_ARGUMENT;
103  }
104  return self->get(self, index, element);
105}
106
107ESR_ReturnCode ArrayListSet(ArrayList* self, size_t index, void* element)
108{
109  if (self == NULL)
110  {
111    PLogError(L("ESR_INVALID_ARGUMENT"));
112    return ESR_INVALID_ARGUMENT;
113  }
114  return self->set(self, index, element);
115}
116
117ESR_ReturnCode ArrayListClone(ArrayList* self, ArrayList* clone)
118{
119  if (self == NULL)
120  {
121    PLogError(L("ESR_INVALID_ARGUMENT"));
122    return ESR_INVALID_ARGUMENT;
123  }
124  return self->clone(self, clone);
125}
126
127ESR_ReturnCode ArrayListDestroy(ArrayList* self)
128{
129  if (self == NULL)
130    return ESR_INVALID_ARGUMENT;
131  return self->destroy(self);
132}
133