12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #ifndef __PLAYERCONTROL_H_
- #define __PLAYERCONTROL_H_
- #include <iostream>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- #include <vector>
- class PlayerCommand
- {
- public:
- std::string device;
- std::string ctype;
- std::string param;
- public:
- PlayerCommand() {}
- ~PlayerCommand() {}
- void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
- writer.StartObject();
- writer.Key("device");
- writer.String(device.c_str());
- writer.Key("ctype");
- writer.String(ctype.c_str());
- writer.Key("param");
- writer.String(param.c_str());
- writer.EndObject();
- }
- };
- class PlayerControl
- {
- public:
- std::string URL = "/qxsbr360xs.do";
- public:
- std::string cid;
- std::string cname;
- std::string dtype;
- std::string did;
- vector<PlayerCommand> command;
- public:
- PlayerControl() {}
- ~PlayerControl() {}
- void setURL(std::string url){
- this->URL = url;
- }
- std::string getUrl(){
- return this->URL;
- }
- void objectToJson(std::string& str){
- rapidjson::StringBuffer strBuf;
- rapidjson::Writer<rapidjson::StringBuffer> writer(strBuf);
- this->objectToJson(writer);
- str = strBuf.GetString();
- }
- void objectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
- writer.StartObject();
- writer.Key("cid");
- writer.String(cid.c_str());
- writer.Key("cname");
- writer.String(cname.c_str());
- writer.Key("dtype");
- writer.String(dtype.c_str());
- writer.Key("did");
- writer.String(did.c_str());
- writer.Key("command");
- writer.StartArray();
- for(auto iter = command.begin(); iter != command.end(); iter++){
- iter->objectToJson(writer);
- }
- writer.EndArray();
- writer.EndObject();
- }
- };
- #endif
|