Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
CsvFile.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/Utility/string_utils.h>
4
5#include <cstddef>
6#include <vector>
7#include <string>
8
9namespace ph
10{
11
12class Path;
13
14class CsvFileRow final
15{
16public:
17 std::size_t numValues() const;
18 const std::string& getValue(std::size_t index) const;
19 std::string& getValue(std::size_t index);
20 CsvFileRow& addValue(std::string value);
21
22 template<typename NumberType>
23 NumberType getValue(std::size_t index) const;
24
25private:
26 std::vector<std::string> m_values;
27};
28
33class CsvFile final
34{
35public:
36 CsvFile() = default;
37
40 explicit CsvFile(const Path& csvFile);
41
42 CsvFile& load(const Path& csvFile);
43 const CsvFile& save(const Path& csvFile) const;
44 std::size_t numRows() const;
45 const CsvFileRow& getRow(std::size_t index) const;
46 CsvFileRow& getRow(std::size_t index);
48
49private:
50 std::vector<CsvFileRow> m_rows;
51};
52
53template<typename NumberType>
54inline NumberType CsvFileRow::getValue(const std::size_t index) const
55{
56 return string_utils::parse_number<NumberType>(getValue(index));
57}
58
59}// end namespace ph
Definition CsvFile.h:34
const CsvFileRow & getRow(std::size_t index) const
Definition CsvFile.cpp:115
const CsvFile & save(const Path &csvFile) const
Definition CsvFile.cpp:87
CsvFile & load(const Path &csvFile)
Definition CsvFile.cpp:43
CsvFile()=default
std::size_t numRows() const
Definition CsvFile.cpp:110
CsvFile & addRow(CsvFileRow row)
Definition CsvFile.cpp:127
Definition CsvFile.h:15
std::size_t numValues() const
Definition CsvFile.cpp:14
CsvFileRow & addValue(std::string value)
Definition CsvFile.cpp:31
const std::string & getValue(std::size_t index) const
Definition CsvFile.cpp:19
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
The root for all renderer implementations.
Definition EEngineProject.h:6