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

  1 mday  1.3.2.4 //%/////////////////////////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4               // The Open Group, Tivoli Systems
  5               //
  6               // Permission is hereby granted, free of charge, to any person obtaining a copy
  7               // of this software and associated documentation files (the "Software"), to
  8               // deal in the Software without restriction, including without limitation the
  9               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10               // sell copies of the Software, and to permit persons to whom the Software is
 11               // furnished to do so, subject to the following conditions:
 12               // 
 13               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16               // LIMITED TO THEa
 17               // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 18               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 19               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 20               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 21               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 22 mday  1.3.2.4 //
 23               //==============================================================================
 24               //
 25               // Author: Humberto Rivero (hurivero@us.ibm.com)
 26               //
 27               // Modified By:
 28               //
 29               //%/////////////////////////////////////////////////////////////////////////////
 30               
 31               #ifndef Pegasus_LanguageElement_h
 32               #define Pegasus_LanguageElement_h
 33               
 34               #include <cstdlib>
 35               #include <cctype>
 36               #include <iostream>
 37               //#include <ostream>
 38               #include <Pegasus/Common/Linkage.h>
 39               #include <Pegasus/Common/Config.h>
 40               #include <Pegasus/Common/String.h>
 41               #include <Pegasus/Common/Array.h>
 42               
 43 mday  1.3.2.4 
 44               PEGASUS_NAMESPACE_BEGIN
 45               
 46               //////////////////////////////////////////////////////////////
 47               //
 48               // LanguageElement::
 49               //
 50               //////////////////////////////////////////////////////////////
 51                   
 52               /** This is a base class for derived LanguageElements
 53                */ 
 54               class PEGASUS_COMMON_LINKAGE LanguageElement{
 55               	     
 56               public:
 57               
 58               	/**	This member is used to represent an empty LanguageElement. Using this 
 59                       member avoids construction of an empty LanguageElement 
 60                       (e.g., LanguageElement()).
 61                   */
 62               	static const LanguageElement EMPTY;
 63               	
 64 mday  1.3.2.4 	/**
 65               	 * This member is used to notify callers of (Accept/Content)Languages::itrNext() that the end of the container
 66               	 * has been reached and subsequent calls to (Accept/Content)Languages::itrNext() will fail.
 67               	 */
 68               	static LanguageElement EMPTY_REF;
 69               
 70               	/** Constructor
 71               	 */
 72               	LanguageElement();
 73               	
 74               	
 75               	/**
 76               	 * Constructor
 77               	 * @param language String - language ex: en
 78               	 * @param country String - country code ex: US
 79               	 * @param variant String - variant ex: rab-oof
 80               	 * @param quality Real32 - quality associated with the language, defaults to 1.0
 81               	 */
 82               	LanguageElement(String language, 
 83               				 String country,
 84               				 String variant,
 85 mday  1.3.2.4 				 Real32 quality = 1);
 86               
 87               	/** 
 88               	 * Constructor
 89               	 * @param language_tag String language value
 90               	 * @param quality Real32 quality associated with the language value, defaults to 1
 91               	 */
 92               	LanguageElement(String language_tag, Real32 quality = 1);
 93               
 94               	/** Copy Constructor 
 95               	 */
 96               	LanguageElement(const LanguageElement &rhs);
 97               	
 98               	/**
 99               	 * Destructor
100               	 */
101               	virtual ~LanguageElement();
102               
103               	/**
104               	 * Assignment operator, deep copy
105               	 */
106 mday  1.3.2.4 	LanguageElement operator=(LanguageElement rhs);
107               	
108               	/**
109               	 * Builds the language tag representation of this object
110               	 * @return String - language-country-variant 
111               	 */
112               	String getLanguageTag() const;
113               
114               	/** Gets the language value
115               	 * @return String - language
116               	 */
117               	String getLanguage() const;
118               
119               	/**
120               	 * Gets the country value
121               	 * @return String - country
122               	 */
123               	String getCountry() const;
124               
125               	/**
126               	 * Gets the variant value
127 mday  1.3.2.4 	 * @return String variant
128               	 */
129               	String getVariant() const;
130               	
131               	/**
132               	 * Builds the language tag representation of this object
133               	 * @return String - language-country-variant 
134               	 */
135               	String getTag() const;
136               	
137               	/** String representation of the LanguageElement
138               	 * @return the String
139               	 */
140               	virtual String toString() const;
141               	
142               	/**
143               	 * Equality based on case INSENSITIVE comparison of the language tags
144               	 */
145               	Boolean operator==(const LanguageElement rhs)const;
146               	
147               	/**
148 mday  1.3.2.4 	 * Inequality based on case INSENSITIVE comparison of the language tags
149               	 */
150               	Boolean operator!=(const LanguageElement rhs)const;
151               	
152               	/**
153               	 * Writes the String representation of this object to the stream
154               	 */
155               	PEGASUS_COMMON_LINKAGE friend PEGASUS_STD(ostream)& operator <<(PEGASUS_STD(ostream) &stream, LanguageElement le);
156               
157               	/**
158               	 * AcceptLanguages needs direct access to quality, but ContentLanguages does not.
159               	 */
160               	friend class AcceptLanguages;	
161               
162               protected:
163               	Real32 quality;			// quality value of the languge tag
164               	
165               private:
166               	
167               	String buildLanguageTag() const;
168               	
169 mday  1.3.2.4 	void splitLanguageTag(String language_tag);
170               	
171               	String language;      // language part of language tag
172               	String country;       // country code part of the language tag
173               	String variant;       // language variant part of the language tag
174               			
175               }; // end LanguageElement
176               
177               #ifndef PEGASUS_ARRAY_T
178               #define PEGASUS_ARRAY_T LanguageElement
179               #include <Pegasus/Common/ArrayInter.h>
180               #undef PEGASUS_ARRAY_T
181               #endif
182               
183               PEGASUS_NAMESPACE_END
184               
185               #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2