1 //
2 // CDDL HEADER START
3 //
4 // The contents of this file are subject to the terms of the Common Development
5 // and Distribution License Version 1.0 (the "License").
6 //
7 // You can obtain a copy of the license at
8 // http://www.opensource.org/licenses/CDDL-1.0.  See the License for the
9 // specific language governing permissions and limitations under the License.
10 //
11 // When distributing Covered Code, include this CDDL HEADER in each file and
12 // include the License file in a prominent location with the name LICENSE.CDDL.
13 // If applicable, add the following below this CDDL HEADER, with the fields
14 // enclosed by brackets "[]" replaced with your own identifying information:
15 //
16 // Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 //
18 // CDDL HEADER END
19 //
20 
21 //
22 // Copyright (c) 2016--2020, Regents of the University of Minnesota.
23 // All rights reserved.
24 //
25 // Contributors:
26 //    Ryan S. Elliott
27 //
28 
29 //
30 // Release: This file is part of the kim-api-2.2.1 package.
31 //
32 
33 
34 #ifndef KIM_LANGUAGE_NAME_HPP_
35 #define KIM_LANGUAGE_NAME_HPP_
36 
37 #include <string>
38 
39 namespace KIM
40 {
41 /// \brief An \ref extensible_enumeration "Extensible Enumeration" for the
42 /// LanguageName's supported by the %KIM API.
43 ///
44 /// The enumeration constants are contained in the LANGUAGE_NAME namespace.
45 ///
46 /// \sa KIM_LanguageName, kim_language_name_module::kim_language_name_type
47 ///
48 /// \since 2.0
49 class LanguageName
50 {
51  public:
52   /// \brief Integer identifying the specific LanguageName represented.
53   ///
54   /// \note This should not be directly accessed and is only public for
55   /// cross-language reasons.
56   ///
57   /// \sa KIM_LanguageName::languageNameID,
58   /// kim_language_name_module::kim_language_name_type::language_name_id
59   ///
60   /// \since 2.0
61   int languageNameID;
62 
63   /// \brief Create an uninitialized LanguageName object.
64   ///
65   /// \since 2.0
66   LanguageName();
67 
68   /// \brief Create a LanguageName object with the specified id.
69   ///
70   /// \note This should not be used directly.
71   ///
72   /// \since 2.0
73   LanguageName(int const id);
74 
75   /// \brief Create a LanguageName object corresponding to the provided string.
76   /// If the string does not match one of the values defined by the %KIM API,
77   /// then an "unknown" object is generated.
78   ///
79   /// \sa KIM_LanguageName_FromString,
80   /// kim_language_name_module::kim_from_string
81   ///
82   /// \since 2.0
83   LanguageName(std::string const & str);
84 
85   /// \brief Determines if the object is a quantity known to the %KIM API.
86   ///
87   /// LanguageName's known to the %KIM API are found in the LANGUAGE_NAME
88   /// namespace.
89   ///
90   /// \sa KIM_LanguageName_Known, kim_language_name_module::kim_known
91   ///
92   /// \since 2.0
93   bool Known() const;
94 
95   /// \brief Compares LanguageName objects for equality.
96   ///
97   /// \note Not all "unknown" objects are equal.
98   ///
99   /// \sa KIM_LanguageName_Equal, kim_language_name_module::operator(.eq.)
100   ///
101   /// \since 2.0
102   bool operator==(LanguageName const & rhs) const;
103 
104   /// \brief Compares LanguageName objects for inequality.
105   ///
106   /// \note It is possible for two "unknown" objects to be not equal.
107   ///
108   /// \sa KIM_LanguageName_NotEqual, kim_language_name_module::operator(.ne.)
109   ///
110   /// \since 2.0
111   bool operator!=(LanguageName const & rhs) const;
112 
113   /// \brief Converts the object to a string.
114   ///
115   /// \return A string object representing the LanguageName object.
116   ///
117   /// \note If the LanguageName object does not correspond to a value defined
118   /// by the %KIM API, then the string "unknown" is returned.
119   ///
120   /// \sa KIM_LanguageName_ToString, kim_language_name_module::kim_to_string
121   ///
122   /// \since 2.0
123   std::string const & ToString() const;
124 };  // class LanguageName
125 
126 /// \brief Contains the enumeration constants and the discovery routines for
127 /// the LanguageName \ref extensible_enumeration "Extensible Enumeration".
128 namespace LANGUAGE_NAME
129 {
130 /// \brief The standard \c cpp language.
131 ///
132 /// \todo Add more detailed description of the language.
133 ///
134 /// \sa KIM_LANGUAGE_NAME_cpp, kim_language_name_module::kim_language_name_cpp
135 ///
136 /// \since 2.0
137 extern LanguageName const cpp;
138 
139 /// \brief The standard \c c language.
140 ///
141 /// \todo Add more detailed description of the language.
142 ///
143 /// \sa KIM_LANGUAGE_NAME_c, kim_language_name_module::kim_language_name_c
144 ///
145 /// \since 2.0
146 extern LanguageName const c;
147 
148 /// \brief The standard \c fortran language.
149 ///
150 /// \todo Add more detailed description of the language.
151 ///
152 /// \sa KIM_LANGUAGE_NAME_fortran,
153 /// kim_language_name_module::kim_language_name_fortran
154 ///
155 /// \since 2.0
156 extern LanguageName const fortran;
157 
158 
159 /// \brief Get the number of standard LanguageName's defined by the %KIM
160 /// API.
161 ///
162 /// \param[out] numberOfLanguageNames The number of standard LanguageName's
163 ///             defined by the %KIM API.
164 ///
165 /// \sa KIM_LANGUAGE_NAME_GetNumberOfLanguageNames,
166 /// kim_language_name_module::kim_get_number_of_language_names
167 ///
168 /// \since 2.0
169 void GetNumberOfLanguageNames(int * const numberOfLanguageNames);
170 
171 /// \brief Get the identity of each defined standard LanguageName.
172 ///
173 /// \param[in]  index Zero-based index uniquely labeling each defined standard
174 ///             LanguageName.  This index ordering is only guaranteed to be
175 ///             stable during the lifetime of the current process.
176 /// \param[out] languageName The LanguageName object associated with \c index.
177 ///
178 /// \return \c true if `index < 0` or `index >= numberOfLanguageNames`.
179 /// \return \c false otherwise.
180 ///
181 /// \sa KIM_LANGUAGE_NAME_GetLanguageName,
182 /// kim_language_name_module::kim_get_language_name
183 ///
184 /// \since 2.0
185 int GetLanguageName(int const index, LanguageName * const languageName);
186 
187 /// \brief Structure provided for use with std::map.
188 ///
189 /// \since 2.0
190 struct Comparator
191 {
192   /// \brief Provides an (logically unmeaningful) ordering for LanguageName
193   /// objects so that they can be stored in a std::map.
194   ///
195   /// \since 2.0
operator ()KIM::LANGUAGE_NAME::Comparator196   bool operator()(LanguageName const & a, LanguageName const & b) const
197   {
198     return a.languageNameID < b.languageNameID;
199   }
200 };  // struct Comparator
201 }  // namespace LANGUAGE_NAME
202 }  // namespace KIM
203 
204 #endif  // KIM_LANGUAGE_NAME_HPP_
205