Molecular Dynamics Simulation  1.0
Functions
OutputFormats.cpp File Reference
#include "OutputFormats.h"
#include "io/logger/Logger.h"
Include dependency graph for OutputFormats.cpp:

Go to the source code of this file.

Functions

const std::map< std::string, OutputFormatget_supported_output_formats ()
 Returns a mappping of supported output formats. More...
 
OutputFormat convertToOutputFormat (const std::string &output_format)
 Converts a string to an OutputFormat. More...
 

Function Documentation

◆ convertToOutputFormat()

OutputFormat convertToOutputFormat ( const std::string &  output_format)

Converts a string to an OutputFormat.

Parameters
output_formatThe string to convert
Returns
OutputFormat The converted OutputFormat

Definition at line 9 of file OutputFormats.cpp.

9  {
10  auto supported = get_supported_output_formats();
11 
12  if (!supported.contains(output_format)) {
13  auto supported_formats = std::string();
14  for (auto& [name, format] : supported) {
15  supported_formats += name + ", ";
16  }
17 
18  Logger::logger->error("Invalid output format given: {}. Supported output formats are: {}", output_format, supported_formats);
19  throw std::runtime_error("Invalid output format given");
20  }
21 
22  return supported[output_format];
23 }
const std::map< std::string, OutputFormat > get_supported_output_formats()
Returns a mappping of supported output formats.
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35

◆ get_supported_output_formats()

const std::map<std::string, OutputFormat> get_supported_output_formats ( )

Returns a mappping of supported output formats.

Returns
std::map<std::string,OutputFormat> Mapping of supported output formats

Definition at line 5 of file OutputFormats.cpp.

5  {
6  return {{"vtu", OutputFormat::VTU}, {"xyz", OutputFormat::XYZ}, {"chkpt", OutputFormat::CHKPT}};
7 }