-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
143 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
#include "json/json.h" | ||
|
||
struct IsDone { | ||
bool is_done; | ||
int operator()() { return is_done; } | ||
}; | ||
|
||
struct HasError { | ||
bool has_error; | ||
int operator()() { return has_error; } | ||
}; | ||
|
||
struct IsStream { | ||
bool is_stream; | ||
int operator()() { return is_stream; } | ||
}; | ||
|
||
struct StatusCode { | ||
int status_code; | ||
int operator()() { return status_code; } | ||
}; | ||
|
||
struct ResStatus { | ||
private: | ||
IsDone is_done; | ||
HasError has_error; | ||
IsStream is_stream; | ||
StatusCode status_code; | ||
|
||
public: | ||
ResStatus(IsDone is_done, HasError has_error, IsStream is_stream, | ||
StatusCode status_code) | ||
: is_done(is_done), | ||
has_error(has_error), | ||
is_stream(is_stream), | ||
status_code(status_code) {} | ||
|
||
Json::Value ToJson() { | ||
Json::Value status; | ||
status["is_done"] = is_done(); | ||
status["has_error"] = has_error(); | ||
status["is_stream"] = is_stream(); | ||
status["status_code"] = status_code(); | ||
return status; | ||
}; | ||
}; | ||
|
||
struct ResStreamData { | ||
private: | ||
std::string s; | ||
|
||
public: | ||
ResStreamData(std::string s) : s(std::move(s)) {} | ||
Json::Value ToJson() { | ||
Json::Value d; | ||
d["data"] = s; | ||
return d; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.