3 karl 1.2 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
11 humberto 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Humberto Rivero (hurivero@us.ibm.com)
31 //
32 humberto 1.1 // Modified By:
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef Pegasus_LanguageElementContainerRep_h
37 #define Pegasus_LanguageElementContainerRep_h
38
39
40 #include <cstdlib>
41 #include <cctype>
42 #include <iostream>
43 #include <Pegasus/Common/Linkage.h>
44 #include <Pegasus/Common/Config.h>
45 #include <Pegasus/Common/String.h>
46 #include <Pegasus/Common/Array.h>
47 #include <Pegasus/Common/LanguageElement.h>
48 #include <Pegasus/Common/LanguageParser.h>
49
50 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
51
52 PEGASUS_NAMESPACE_BEGIN
53 humberto 1.1
54 //////////////////////////////////////////////////////////////
55 //
56 // LanguageElementContainerRep::
57 //
58 //////////////////////////////////////////////////////////////
59
60 /** This class is a container class for AcceptLanguageElement
61 */
62 class PEGASUS_COMMON_LINKAGE LanguageElementContainerRep{
63
64 public:
65
66 /** This member is used to represent an empty LanguageElementContainer. Using this
67 member avoids construction of an empty LanguageElementContainer
68 (e.g., LanguageElementContainer()).
69 */
70 // static const LanguageElementContainer EMPTY;
71
72 /**
73 * Default Constructor
74 humberto 1.1 */
75 LanguageElementContainerRep();
76
77 /**
78 * Constructor
79 * @param container Array<LanguageElement> - contructs the object with the elements in the array
80 */
81 LanguageElementContainerRep(const Array<LanguageElement> &container);
82
83 /** Copy Constructor
84 * @param rhs LanguageElementContainer
85 */
86 LanguageElementContainerRep(const LanguageElementContainerRep &rhs);
87
88 /**
89 * Destructor
90 */
91 virtual ~LanguageElementContainerRep();
92
93 /**
94 * Deep copy
95 humberto 1.1 * @param rhs LanguageElementContainer
96 */
|
99 humberto 1.1
100 /** Gets an AcceptLanguageElement object at position index
101 * @param index int position of AcceptLanguageElement
102 * @return AcceptLanguageElement
103 */
104 LanguageElement getLanguageElement(Uint32 index) const;
105
106 /** Gets all AcceptLanguageElement objects in the container
107 * @return Array<AcceptLanguageElement>
108 */
109 Array<LanguageElement> getAllLanguageElements() const;
110
111 /** Returns the String representation of this container
112 * @return String
113 */
114 virtual String toString() const;
115
116 /**
117 * Returns the length of the LanguageElementContainer object.
118 * @return Length of the container.
119 */
120 humberto 1.1 Uint32 size() const;
121
122 /**
123 * True if the container has element (case INSENSITIVE match of element's language fields
124 * @param LanguageElement element
125 * @return Boolean
126 */
127 Boolean contains(LanguageElement element)const;
128
129 /**
130 * Resets this object's iterator, should be called once before using itrNext()
131 */
132 void itrStart();
133
134 /**
135 * Returns the next element in the container
136 * Callers should call itrStart() ONCE before making calls to this function and
137 * anytime callers want the iterator reset to the beginning of the container.
138 * @return LanguageElement - the next element the container or LanguageElement::EMPTY_REF
139 * if the end of the container has been reached.
140 */
141 humberto 1.1 LanguageElement itrNext();
142
143 /**
144 * Removes the element at index from the container.
145 * @param index Uint32 - position of the element in the container to remove
146 */
147 void remove(Uint32 index);
148
149 /**
150 * Removes the element matching the parameter, returns -1 if not found
151 * @param element LanguageElement - element to remove
152 * @return int -1 if element not found, otherwise returns the position of element before the remove.
153 */
154 Uint32 remove(const LanguageElement &element);
155
156 /**
157 * Clears the container of all elements
158 */
159 void clear();
160
161 void append(LanguageElement element);
162 humberto 1.1
163 /**
164 * Equality based on language fields only
165 */
166 Boolean operator==(const LanguageElementContainerRep &rhs)const;
167
168 /**
169 * Inequality based on language fields only
170 */
171 Boolean operator!=(const LanguageElementContainerRep &rhs)const;
172
173 /**
174 * Finds the element in the container and returns its position.
175 * @param element LanguageElement - element to find
176 * @return int index of element if found, otherwise -1
177 */
178 Sint32 find(LanguageElement element)const;
179
180
181 Array<LanguageElement> container; // holds LanguageElements
182
183 humberto 1.1 private:
184
185 void buildLanguageElements(Array<String> values);
186
187 void updateIterator();
188
189 Uint32 itr_index; // current position for iterator type access
190
191 }; // end LanguageElementContainerRep
192
193 PEGASUS_NAMESPACE_END
194
195 #endif // PEGASUS_USE_EXPERIMENTAL_INTERFACE
196
197 #endif
|