(file) Return to AcceptLanguageList.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2