FileIO.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Created by wrede on 19.04.16.
  3. //
  4. #ifndef GBMOT_FILEIO_H
  5. #define GBMOT_FILEIO_H
  6. #include "../core/Definitions.h"
  7. #include <string>
  8. #include <fstream>
  9. namespace util
  10. {
  11. /**
  12. * Utility class for file in- and output.
  13. */
  14. class FileIO
  15. {
  16. public:
  17. /**
  18. * Reads a CSV file and stores the values in a 3D array.
  19. * The first dimension is the first value of each row, used as a
  20. * index to bundle multiple rows with the same first value into a
  21. * single vector.
  22. * The second dimension is the row in the row bundle.
  23. * The third dimension is the value in that row.
  24. * @param filename The filename to read from
  25. * @param delimiter The delimiter used to separate the values in the file
  26. * @param values The 3D array of values to store the read values in
  27. */
  28. static void ReadCSV(
  29. const std::string &filename,
  30. const char &delimiter,
  31. core::Vector3d &values);
  32. /**
  33. * Reads a CSV file and stores the values in a 2D array.
  34. * The first dimension is the row and the second the value in that row.
  35. * @param filename The filename to read from
  36. * @param delimiter The delimiter used to separate the values in the file
  37. * @param values The 2D array of values to store the read values in
  38. */
  39. static void ReadCSV(
  40. const std::string &filename,
  41. const char &delimiter,
  42. core::Vector2d &values);
  43. };
  44. }
  45. #endif //GBMOT_FILEIO_H