File Module

This module provides file I/O operations for various formats.

File Handler

class File

File Format Enum

enum class sbody::FileFormat

Values:

enumerator NUMPY
enumerator CSV

NumPy Handler

class NumPy : public sbody::Writer

Public Functions

NumPy(std::filesystem::path file_path, std::vector<std::size_t> dimension)

Construct a new NumPy object.

Parameters:
  • file_path –

  • dimension –

virtual void save(const double data[], uint length)

Save the data.

Parameters:
  • data – Data to be saved

  • length – Length of the data

virtual void save(double datum)

Save the data.

Parameters:

datum – Data to be saved

CSV Handler

class CSV : public sbody::Writer

Public Functions

CSV(std::filesystem::path file_path, char separator = ',')

Construct a new CSV object.

Parameters:
  • file_path –

  • separator – Separator of the file. If ‘separator == ’\t’`, the file would be a Tab-Separated Values (TSV).

virtual void save(const double data[], uint length) override

Save the data.

Parameters:
  • data – Data to be saved

  • length – Length of the data

virtual void save(const double datum) override

Save the data.

Parameters:

datum – Data to be saved

Writer Base Class

class Writer

Subclassed by sbody::CSV, sbody::NumPy

Public Functions

virtual ~Writer()

Destroy the file object.

virtual void save(const double data[], uint length) = 0

Save the data.

Parameters:
  • data – Data to be saved

  • length – Length of the data

virtual void save(const double datum) = 0

Save the data.

Parameters:

datum – Data to be saved