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_LanguageTag_h
33 #define Pegasus_LanguageTag_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/String.h>
37 #include <Pegasus/Common/Linkage.h>
38
39 PEGASUS_NAMESPACE_BEGIN
40
41 class LanguageTagRep;
42
|
43 kumpf 1.3 /**
|
44 kumpf 1.1 This class specifies a language in a standard form (based on RFC 3066),
45 including the special language range "*". Note: This class may be
46 extended to support RFC 3066bis in the future.
47 */
48 class PEGASUS_COMMON_LINKAGE LanguageTag
49 {
50 public:
51
52 /**
53 Constructs an uninitialized LanguageTag object. A method
54 invocation on an uninitialized LanguageTag object will
55 result in the throwing of an UninitializedObjectException. An
56 uninitialized object may be converted into an initialized object only
57 by using the assignment operator with an initialized object.
58 */
59 LanguageTag();
60
61 /**
62 Constructs a LanguageTag object from a language tag String.
63 The syntax of the language tag String is validated, but the subtags
64 are not verified to be values registered with ISO or IANA.
|
65 kumpf 1.4 @param languageTagString A String containing a language tag (for
66 example, "en-US").
|
67 kumpf 1.1 @exception Exception if the syntax of the language tag String is not
68 valid.
69 */
70 LanguageTag(const String& languageTagString);
71
72 /**
73 Copy constructor.
74 @param languageTag The LanguageTag object to copy.
75 */
76 LanguageTag(const LanguageTag& languageTag);
77
78 /**
79 Destructor.
80 */
81 ~LanguageTag();
82
83 /**
84 Assignment operator.
85 @param languageTag The LanguageTag object to copy.
86 */
87 LanguageTag& operator=(const LanguageTag& languageTag);
88 kumpf 1.1
89 /**
90 Gets the language value, if present.
91 @return A String containing the language value for this LanguageTag
92 object if the primary subtag is two or three characters in length,
93 an empty String otherwise.
94 @exception UninitializedObjectException if the LanguageTag
95 has not been initialized.
96 */
97 String getLanguage() const;
98
99 /**
100 Gets the country code from the second subtag, if present.
101 @return A String containing the country code for this LanguageTag
102 object if the primary subtag is two or three characters in length
103 and the second subtag is two characters in length, an empty String
104 otherwise.
105 @exception UninitializedObjectException if the LanguageTag
106 has not been initialized.
107 */
108 String getCountry() const;
109 kumpf 1.1
110 /**
111 Gets the language variant, if applicable. The language variant
112 includes all the subtags after the country code (if present) or
113 language value (if present).
114 @return A String containing the language variant for this LanguageTag
115 object if the primary subtag is two or three characters in length,
116 an empty String otherwise.
117 @exception UninitializedObjectException if the LanguageTag
118 has not been initialized.
119 */
120 String getVariant() const;
121
122 /**
123 Returns a String representation of the language tag.
124 @return A String representing the LanguageTag object in RFC 3066
125 syntax (for example, "language-country-variant").
126 @exception UninitializedObjectException if the LanguageTag has not
127 been initialized.
128 */
129 String toString() const;
130 kumpf 1.1
131 /**
132 Tests LanguageTag objects for equality. Comparisons are
133 case-insensitive. Distinct but equivalent language tags are not
134 considered equal. Language range matching is not performed.
135 @param languageTag A LanguageTag object to be compared.
136 @return True if the language tags differ only in case, false otherwise.
137 @exception UninitializedObjectException if either of the
138 LanguageTags has not been initialized.
139 */
140 Boolean operator==(const LanguageTag& languageTag) const;
141
142 /**
143 Tests LanguageTag objects for inequality. Comparisons are
144 case-insensitive. Distinct but equivalent language tags are not
145 considered equal. Language range matching is not performed.
146 @param languageTag A LanguageTag object to be compared.
147 @return True if the language tags differ in more than just case,
148 false otherwise.
149 @exception UninitializedObjectException if either of the
150 LanguageTags has not been initialized.
151 kumpf 1.1 */
152 Boolean operator!=(const LanguageTag& languageTag) const;
153
154 private:
155 LanguageTagRep* _rep;
156 };
157
158 PEGASUS_NAMESPACE_END
159
160 #endif
|