OpenMPCD
ImplementationDetails/Configuration/Configuration.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Implements functionality of the `OpenMPCD::Configuration` class.
4  */
5 
6 #ifndef OPENMPCD_IMPLEMENTATIONDETAILS_CONFIGURATION_CONFIGURATION_HPP
7 #define OPENMPCD_IMPLEMENTATIONDETAILS_CONFIGURATION_CONFIGURATION_HPP
8 
10 
11 
12 namespace OpenMPCD
13 {
14 
15 inline OpenMPCD::Configuration::Configuration(const std::string& filename)
16  : config()
17 {
18  try
19  {
20  config.readFile(filename.c_str());
21  }
22  catch(const std::exception& e)
23  {
24  if(std::string(e.what()) == "FileIOException")
25  {
26  std::string message = "Failed to open configuration file: ";
27  message += filename;
28 
30  }
31 
32  if(std::string(e.what()) == "ParseException")
33  {
34  std::string message = "Failed to parse configuration file: ";
35  message += filename;
36 
38  }
39 
40  throw;
41  }
42 }
43 
44 } //namespace OpenMPCD
45 
46 #endif //OPENMPCD_IMPLEMENTATIONDETAILS_CONFIGURATION_CONFIGURATION_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::IOException
Error on IO.
Definition: Exceptions.hpp:160
OpenMPCD::MalformedFileException
Represents an exception that signals a malformed file.
Definition: Exceptions.hpp:224
Configuration.hpp
OpenMPCD::Configuration::Configuration
Configuration()
The constructor.
Definition: Configuration.hpp:479