2 kumpf 1.1 //
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 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 kumpf 1.1 #ifndef Pegasus_AcceptLanguageList_h
35 #define Pegasus_AcceptLanguageList_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/LanguageTag.h>
39
40 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
41
42 PEGASUS_NAMESPACE_BEGIN
43
44 class AcceptLanguageListRep;
45
46 //////////////////////////////////////////////////////////////
47 //
48 // AcceptLanguageList
49 //
50 //////////////////////////////////////////////////////////////
51
52 /** <I><B>Experimental Interface</B></I><BR>
53 This class represents an list of languages that a reader can understand
54 (as may be specified in an HTTP Accept-Language header value). It is
55 kumpf 1.1 managed as a prioritized list of LanguageTag objects and quality values.
56 */
57 class PEGASUS_COMMON_LINKAGE AcceptLanguageList
58 {
59 public:
60
61 /**
62 Constructs an empty AcceptLanguageList object.
63 */
64 AcceptLanguageList();
65
66 /**
67 Copy constructor.
68 @param acceptLanguages The AcceptLanguageList object to copy.
69 */
70 AcceptLanguageList(const AcceptLanguageList& acceptLanguages);
71
72 /**
73 Destructor.
74 */
75 ~AcceptLanguageList();
76 kumpf 1.1
77 /**
78 Assignment operator.
79 @param acceptLanguages The AcceptLanguageList object to copy.
80 */
81 AcceptLanguageList& operator=(const AcceptLanguageList& acceptLanguages);
82
83 /**
84 Returns the number of LanguagesTags in the AcceptLanguageList object.
85 @return Integer size of the AcceptLanguageList list.
86 */
87 Uint32 size() const;
88
89 /**
90 Accesses an LanguageTag at a specified index.
91 @param index Integer index of the LanguageTag to access.
92 Valid indices range from 0 to size()-1.
93 @return The LanguageTag corresponding to the specified index.
94 @exception IndexOutOfBoundsException If the specified index is out of
95 range.
96 */
97 kumpf 1.1 LanguageTag getLanguageTag(Uint32 index) const;
98
99 /**
100 Accesses a quality value at a specified index (corresponding to a
101 language tag).
102 @param index Integer index of the quality value to access.
103 Valid indices range from 0 to size()-1.
104 @return The quality value corresponding to the specified index.
105 @exception IndexOutOfBoundsException If the specified index is out of
106 range.
107 */
108 Real32 getQualityValue(Uint32 index) const;
109
110 /**
111 Inserts a LanguageTag and quality value into the AcceptLanguageList
112 object. The element is inserted in order of descending quality value
113 and after any other elements with the same quality value.
114 @param languageTag The LanguageTag to insert.
115 @param qualityValue The quality value to insert.
116 */
117 void insert(
118 kumpf 1.1 const LanguageTag& languageTag,
119 Real32 qualityValue);
120
121 /**
122 Removes the specified LanguageTag and quality value from the
123 AcceptLanguageList object.
124 @param index Integer index of the element to remove.
125 @exception IndexOutOfBoundsException If the specified index is out of
126 range.
127 */
128 void remove(Uint32 index);
129
130 /**
131 Finds the first occurrence of the specified LanguageTag in the
132 AcceptLanguageList object and returns its index.
133 @param languageTag The LanguageTag to find.
134 @return Integer index of the element, if found; otherwise
135 PEG_NOT_FOUND.
136 */
137 Uint32 find(const LanguageTag& languageTag) const;
138
139 kumpf 1.1 /**
140 Removes all the LanguageTags and quality values from the
141 AcceptLanguageList object.
142 */
143 void clear();
144
145 /**
146 Tests AcceptLanguageList objects for equality.
147 @param acceptLanguages An AcceptLanguageList object to be compared.
148 @return True if the AcceptLanguageList objects contain the same
149 LanguageTags and quality values in the same order, false otherwise.
150 */
151 Boolean operator==(const AcceptLanguageList& acceptLanguages) const;
152
153 /**
154 Tests AcceptLanguageList objects for inequality.
155 @param acceptLanguages An AcceptLanguageList object to be compared.
156 @return False if the AcceptLanguageList objects contain the same
157 LanguageTags and quality values in the same order, true otherwise.
158 */
159 Boolean operator!=(const AcceptLanguageList& acceptLanguages) const;
160 kumpf 1.1
161 private:
162 AcceptLanguageListRep* _rep;
163 };
164
165 PEGASUS_NAMESPACE_END
166
167 #endif // PEGASUS_USE_EXPERIMENTAL_INTERFACES
168
169 #endif
|