Etterna 0.74.4
Loading...
Searching...
No Matches
MsdFile.h
1#ifndef MSDFILE_H
2#define MSDFILE_H
3
4#include <string>
5#include <vector>
6
9class MsdFile
10{
11 public:
16 struct value_t
17 {
19 std::vector<std::string> params;
22 : params()
23 {
24 }
25
31 std::string operator[](unsigned i) const
32 {
33 if (i >= params.size())
34 return std::string();
35 return params[i];
36 }
37 };
38
39 MsdFile()
40 : values()
41 , error("")
42 {
43 }
44
46 virtual ~MsdFile() = default;
47
54 bool ReadFile(const std::string& sFilePath, bool bUnescape);
61 void ReadFromString(const std::string& sString, bool bUnescape);
62
66 std::string GetError() const { return error; }
67
71 unsigned GetNumValues() const { return values.size(); }
77 unsigned GetNumParams(unsigned val) const
78 {
79 if (val >= GetNumValues())
80 return 0;
81 return values[val].params.size();
82 }
88 const value_t& GetValue(unsigned val) const
89 {
90 ASSERT(val < GetNumValues());
91 return values[val];
92 }
99 std::string GetParam(unsigned val, unsigned par) const;
100
101 private:
108 void ReadBuf(const char* buf, int len, bool bUnescape);
114 void AddParam(const char* buf, int len);
118 void AddValue();
119
121 std::vector<value_t> values;
123 std::string error;
124};
125
126#endif
The class that reads the various .SSC, .SM, .SMA, .DWI, and .MSD files.
Definition MsdFile.h:10
unsigned GetNumValues() const
Retrieve the number of values for each tag.
Definition MsdFile.h:71
std::string GetParam(unsigned val, unsigned par) const
Retrieve the specified parameter.
Definition MsdFile.cpp:187
unsigned GetNumParams(unsigned val) const
Get the number of parameters for the current index.
Definition MsdFile.h:77
virtual ~MsdFile()=default
Remove the MSDFile.
std::string GetError() const
Should an error take place, have an easy place to get it.
Definition MsdFile.h:66
void ReadFromString(const std::string &sString, bool bUnescape)
Attempt to read an MSD file.
Definition MsdFile.cpp:181
const value_t & GetValue(unsigned val) const
Get the specified value.
Definition MsdFile.h:88
bool ReadFile(const std::string &sFilePath, bool bUnescape)
Attempt to read an MSD file.
Definition MsdFile.cpp:154
The list of params found in the files.
Definition MsdFile.h:17
std::vector< std::string > params
The list of parameters.
Definition MsdFile.h:19
std::string operator[](unsigned i) const
Access the proper parameter.
Definition MsdFile.h:31
value_t()
Set up the parameters with default values.
Definition MsdFile.h:21