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