Created
September 6, 2018 13:17
-
-
Save js2854/e1e8006e3d3ab6a4d555766690cf55b8 to your computer and use it in GitHub Desktop.
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
#ifndef __RESULT_CODE__ | |
#define __RESULT_CODE__ | |
#include <string> | |
#include <iostream> | |
using std::string; | |
using std::ostream; | |
namespace Result | |
{ | |
typedef struct T_Result | |
{ | |
int code; | |
string msg; | |
friend ostream& operator<<(ostream& os, const T_Result& res) | |
{ | |
os << res.code << '(' << res.msg << ')'; | |
return os; | |
} | |
} T_Result; | |
static const T_Result OK = {0, "ok"}; | |
static const T_Result INVALID_PARAMS = {-1, "invalid params"}; | |
}; | |
#endif //__RESULT_CODE__ | |
// usage demo: | |
// std::cout << Result::OK << std::endl; | |
// std::cout << Result::INVALID_PARAMS << std::endl; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment