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 PEGASUS_NAMESPACE_BEGIN
41
42 class AcceptLanguageListRep;
43
44 //////////////////////////////////////////////////////////////
45 //
46 // AcceptLanguageList
47 //
48 //////////////////////////////////////////////////////////////
49
|
51 kumpf 1.1 This class represents an list of languages that a reader can understand
52 (as may be specified in an HTTP Accept-Language header value). It is
53 managed as a prioritized list of LanguageTag objects and quality values.
54 */
55 class PEGASUS_COMMON_LINKAGE AcceptLanguageList
56 {
57 public:
58
59 /**
60 Constructs an empty AcceptLanguageList object.
61 */
62 AcceptLanguageList();
63
64 /**
65 Copy constructor.
66 @param acceptLanguages The AcceptLanguageList object to copy.
67 */
68 AcceptLanguageList(const AcceptLanguageList& acceptLanguages);
69
70 /**
71 Destructor.
72 kumpf 1.1 */
73 ~AcceptLanguageList();
74
75 /**
76 Assignment operator.
77 @param acceptLanguages The AcceptLanguageList object to copy.
78 */
79 AcceptLanguageList& operator=(const AcceptLanguageList& acceptLanguages);
80
81 /**
82 Returns the number of LanguagesTags in the AcceptLanguageList object.
83 @return Integer size of the AcceptLanguageList list.
84 */
85 Uint32 size() const;
86
87 /**
88 Accesses an LanguageTag at a specified index.
89 @param index Integer index of the LanguageTag to access.
90 Valid indices range from 0 to size()-1.
91 @return The LanguageTag corresponding to the specified index.
92 @exception IndexOutOfBoundsException If the specified index is out of
93 kumpf 1.1 range.
94 */
95 LanguageTag getLanguageTag(Uint32 index) const;
96
97 /**
98 Accesses a quality value at a specified index (corresponding to a
99 language tag).
100 @param index Integer index of the quality value to access.
101 Valid indices range from 0 to size()-1.
102 @return The quality value corresponding to the specified index.
103 @exception IndexOutOfBoundsException If the specified index is out of
104 range.
105 */
106 Real32 getQualityValue(Uint32 index) const;
107
108 /**
109 Inserts a LanguageTag and quality value into the AcceptLanguageList
110 object. The element is inserted in order of descending quality value
111 and after any other elements with the same quality value.
112 @param languageTag The LanguageTag to insert.
113 @param qualityValue The quality value to insert.
114 kumpf 1.1 */
115 void insert(
116 const LanguageTag& languageTag,
117 Real32 qualityValue);
118
119 /**
120 Removes the specified LanguageTag and quality value from the
121 AcceptLanguageList object.
122 @param index Integer index of the element to remove.
123 @exception IndexOutOfBoundsException If the specified index is out of
124 range.
125 */
126 void remove(Uint32 index);
127
128 /**
129 Finds the first occurrence of the specified LanguageTag in the
130 AcceptLanguageList object and returns its index.
131 @param languageTag The LanguageTag to find.
132 @return Integer index of the element, if found; otherwise
133 PEG_NOT_FOUND.
134 */
135 kumpf 1.1 Uint32 find(const LanguageTag& languageTag) const;
136
137 /**
138 Removes all the LanguageTags and quality values from the
139 AcceptLanguageList object.
140 */
141 void clear();
142
143 /**
144 Tests AcceptLanguageList objects for equality.
145 @param acceptLanguages An AcceptLanguageList object to be compared.
146 @return True if the AcceptLanguageList objects contain the same
147 LanguageTags and quality values in the same order, false otherwise.
148 */
149 Boolean operator==(const AcceptLanguageList& acceptLanguages) const;
150
151 /**
152 Tests AcceptLanguageList objects for inequality.
153 @param acceptLanguages An AcceptLanguageList object to be compared.
154 @return False if the AcceptLanguageList objects contain the same
155 LanguageTags and quality values in the same order, true otherwise.
156 kumpf 1.1 */
157 Boolean operator!=(const AcceptLanguageList& acceptLanguages) const;
158
159 private:
160 AcceptLanguageListRep* _rep;
161 };
162
163 PEGASUS_NAMESPACE_END
164
165 #endif
|