You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
//
|
|
// Created by zwsd
|
|
//
|
|
|
|
#pragma once
|
|
#include <functional>
|
|
|
|
#include "config_index.hpp"
|
|
#include "errorcode.hpp"
|
|
#include "packet_interface.hpp"
|
|
namespace iflytop {
|
|
using namespace zcr;
|
|
|
|
class ICmdParserACK {
|
|
public:
|
|
typedef enum {
|
|
kAckType_none,
|
|
kAckType_int32,
|
|
kAckType_buf,
|
|
} ICmdParserACKType_t;
|
|
|
|
public:
|
|
int32_t ecode;
|
|
ICmdParserACKType_t acktype;
|
|
uint8_t rawdata[512];
|
|
int32_t rawlen;
|
|
|
|
int32_t *getAck(int index) {
|
|
if (index < 0 || index >= rawlen / sizeof(int32_t)) {
|
|
return nullptr;
|
|
}
|
|
return (int32_t *)rawdata + index;
|
|
}
|
|
|
|
int32_t getAckInt32Val(int index) {
|
|
if (index < 0 || index >= rawlen / sizeof(int32_t)) {
|
|
return 0;
|
|
}
|
|
return *((int32_t *)rawdata + index);
|
|
}
|
|
|
|
int32_t getAckInt32Num() {
|
|
if (rawlen != sizeof(int32_t)) {
|
|
return 0;
|
|
}
|
|
return *((int32_t *)rawdata);
|
|
}
|
|
};
|
|
|
|
typedef function<void(int32_t paramN, const char **paraV, ICmdParserACK *ack)> ICmdFunction_t;
|
|
|
|
class ICmdParser {
|
|
public:
|
|
virtual void regCMD(const char *cmdname, const char *helpinfo, int paraNum, ICmdFunction_t cmdimpl) = 0;
|
|
};
|
|
|
|
} // namespace iflytop
|