-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
65 lines (57 loc) · 1.79 KB
/
Copy pathparser.h
File metadata and controls
65 lines (57 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// parser.h
#ifndef PARSER_H
#define PARSER_H
#include <string>
#include <vector>
#include "json/json.h"
//结构体定义:表示一个时间点
struct Beat {
double time; //时间点由double表示
};
// 结构体定义:表示一个音符
struct Note {
Beat beat; //音符的时间点
int column; //音符所在的列
int iflong = 0; //是否为长音符,0表示不是,1表示是 如果当前note有endbeat才为1
int ifdrag = 0; //是否为drag,0表示不是,1表示是 endbeat处理结果。
Beat endbeat; //可选字段,ifdrag为1时才赋值。
};
class ChartParser {
public:
ChartParser(const std::string& filename);
bool parse();
void printInfo() const;
//获取解析后的数据的方法
std::string getSongTitle() const { return songTitle; }
std::string getSongArtist() const { return songArtist; }
std::string getSound() const { return sound; }
int getOffset() const { return offset; }
int getDivide() const { return divide; }
double getBPM() const { return bpm; }
double getSecondsPerBeat() const { return secondsPerBeat; }
double getSecondsPerMeasure() const { return secondsPerMeasure; }
const std::vector<Note>& getNotes() const { return notes; }
private:
std::string filename;
Json::Value root;
std::string songTitle;
std::string songArtist;
std::string sound;
int offset;
int divide;
double bpm;
double secondsPerBeat;
double secondsPerMeasure;
std::vector<Note> notes;
double drag_endbeat0;
double drag_endbeat1;
double drag_endbeat2;
double drag_endbeat3;
double current_drag_endbeat0;
double current_drag_endbeat1;
double current_drag_endbeat2;
double current_drag_endbeat3;
void parseMeta();
void parseNotes();
};
#endif // PARSER_H