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

  1 chuck 1.1 //%/////////////////////////////////////////////////////////////////////////////
  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 chuck 1.1 //
 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 mday  1.3.2.1 #include <ostream>
 38 chuck 1.1     #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               
 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 chuck 1.1             member avoids construction of an empty LanguageElement 
 60                       (e.g., LanguageElement()).
 61                   */
 62               	static const LanguageElement EMPTY;
 63               	
 64               	/**
 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 chuck 1.1     	 * @param quality Real32 - quality associated with the language, defaults to 1.0
 81               	 */
 82 mday  1.3.2.1 	LanguageElement::LanguageElement(String language, 
 83               									 String country,
 84               									 String variant,
 85               									 Real32 quality = 1);
 86 chuck 1.1     	/** 
 87               	 * Constructor
 88               	 * @param language_tag String language value
 89               	 * @param quality Real32 quality associated with the language value, defaults to 1
 90               	 */
 91               	LanguageElement(String language_tag, Real32 quality = 1);
 92               
 93               	/** Copy Constructor 
 94               	 */
 95               	LanguageElement(const LanguageElement &rhs);
 96               	
 97               	/**
 98               	 * Destructor
 99               	 */
100               	virtual ~LanguageElement();
101               
102               	/**
103               	 * Assignment operator, deep copy
104               	 */
105 mday  1.3.2.2 	LanguageElement operator=(LanguageElement rhs);
106 chuck 1.1     	
107               	/**
108               	 * Builds the language tag representation of this object
109               	 * @return String - language-country-variant 
110               	 */
111 mday  1.3.2.2 	String getLanguageTag() const;
112 chuck 1.1     
113               	/** Gets the language value
114               	 * @return String - language
115               	 */
116               	String getLanguage() const;
117               
118               	/**
119               	 * Gets the country value
120               	 * @return String - country
121               	 */
122               	String getCountry() const;
123               
124               	/**
125               	 * Gets the variant value
126               	 * @return String variant
127               	 */
128               	String getVariant() const;
129               	
130               	/**
131               	 * Builds the language tag representation of this object
132               	 * @return String - language-country-variant 
133 chuck 1.1     	 */
134               	String getTag() const;
135               	
136               	/** String representation of the LanguageElement
137               	 * @return the String
138               	 */
139               	virtual String toString() const;
140               	
141               	/**
142               	 * Equality based on case INSENSITIVE comparison of the language tags
143               	 */
144 mday  1.3.2.2 	Boolean operator==(const LanguageElement rhs)const;
145 chuck 1.1     	
146               	/**
147               	 * Inequality based on case INSENSITIVE comparison of the language tags
148               	 */
149 mday  1.3.2.2 	Boolean operator!=(const LanguageElement rhs)const;
150 chuck 1.1     	
151               	/**
152               	 * Writes the String representation of this object to the stream
153               	 */
154 mday  1.2     	friend PEGASUS_STD(ostream)& operator <<(PEGASUS_STD(ostream) &stream, LanguageElement le);
155 chuck 1.1     
156               	/**
157               	 * AcceptLanguages needs direct access to quality, but ContentLanguages does not.
158               	 */
159               	friend class AcceptLanguages;	
160               
161               protected:
162               	Real32 quality;			// quality value of the languge tag
163               	
164               private:
165               	
166               	String buildLanguageTag() const;
167               	
168               	void splitLanguageTag(String language_tag);
169               	
170               	String language;      // language part of language tag
171               	String country;       // country code part of the language tag
172               	String variant;       // language variant part of the language tag
173               			
174               }; // end LanguageElement
175               
176 chuck 1.1     #ifndef PEGASUS_ARRAY_T
177               #define PEGASUS_ARRAY_T LanguageElement
178               #include <Pegasus/Common/ArrayInter.h>
179               #undef PEGASUS_ARRAY_T
180               #endif
181               
182               PEGASUS_NAMESPACE_END
183               
184               #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2