OpenMPCD
getSettingTypeString.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the
4  * `OpenMPCD::ImplementationDetails::Configuration::getSettingTypeString`
5  * function.
6  */
7 
8 #ifndef OPENMPCD_IMPLEMENTATIONDETAILS_CONFIGURATION_GETSETTINGTYPESTRING_HPP
9 #define OPENMPCD_IMPLEMENTATIONDETAILS_CONFIGURATION_GETSETTINGTYPESTRING_HPP
10 
11 #include <OpenMPCD/Exceptions.hpp>
12 
13 #include <libconfig.h++>
14 #include <string>
15 
16 namespace OpenMPCD
17 {
18 namespace ImplementationDetails
19 {
20 namespace Configuration
21 {
22 
23 /**
24  * Returns a string corresponding to the name of the given type.
25  * @param[in] type The type whose name to return.
26  * @throw Exception Throws if the type is unknown.
27  */
28 inline const std::string getSettingTypeString(const libconfig::Setting::Type type)
29 {
30  switch(type)
31  {
32  case libconfig::Setting::TypeNone:
33  return "TypeNone";
34 
35  case libconfig::Setting::TypeInt:
36  return "TypeInt";
37 
38  case libconfig::Setting::TypeInt64:
39  return "TypeInt64";
40 
41  case libconfig::Setting::TypeFloat:
42  return "TypeFloat";
43 
44  case libconfig::Setting::TypeString:
45  return "TypeString";
46 
47  case libconfig::Setting::TypeBoolean:
48  return "TypeBoolean";
49 
50  case libconfig::Setting::TypeGroup:
51  return "TypeGroup";
52 
53  case libconfig::Setting::TypeArray:
54  return "TypeArray";
55 
56  case libconfig::Setting::TypeList:
57  return "TypeList";
58 
59  default:
60  OPENMPCD_THROW(Exception, "Unknown setting type.");
61  }
62 }
63 
64 } //namespace Configuration
65 } //namespace ImplementationDetails
66 } //namespace OpenMPCD
67 
68 #endif
Exceptions.hpp
OPENMPCD_THROW
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
Definition: Exceptions.hpp:22
OpenMPCD::ImplementationDetails::Configuration::getSettingTypeString
const std::string getSettingTypeString(const libconfig::Setting::Type type)
Returns a string corresponding to the name of the given type.
Definition: getSettingTypeString.hpp:28
OpenMPCD::Exception
The base exception class for OpenMPCD.
Definition: Exceptions.hpp:37