Line data Source code
1 : #pragma once
2 :
3 : #include <prefixdb/api/common_status.hpp>
4 : #include <wfc/json.hpp>
5 : namespace wamba { namespace prefixdb {
6 :
7 : struct common_status_json
8 : {
9 0 : JSON_NAME(OK)
10 0 : JSON_NAME(InvalidFieldValue)
11 0 : JSON_NAME(EmptyFields)
12 0 : JSON_NAME(EmptyPrefix)
13 0 : JSON_NAME(CreatePrefixFail)
14 0 : JSON_NAME(CreateSnapshotFail)
15 0 : JSON_NAME(PrefixNotFound)
16 0 : JSON_NAME(SnapshotNotFound)
17 0 : JSON_NAME(TooManyKeys)
18 0 : JSON_NAME(KeyLengthExceeded)
19 0 : JSON_NAME(ValueLengthExceeded)
20 0 : JSON_NAME(PrefixLengthExceeded)
21 0 : JSON_NAME(RangeLimitExceeded)
22 0 : JSON_NAME(InvalidSeqNumber)
23 0 : JSON_NAME(CompactFail)
24 :
25 : typedef ::wfc::json::enumerator<
26 : common_status,
27 : ::wfc::json::member_list<
28 : ::wfc::json::enum_value<n_OK, common_status, common_status::OK>,
29 : ::wfc::json::enum_value<n_InvalidFieldValue, common_status, common_status::InvalidFieldValue>,
30 : ::wfc::json::enum_value<n_EmptyFields, common_status, common_status::EmptyFields>,
31 : ::wfc::json::enum_value<n_EmptyPrefix, common_status, common_status::EmptyPrefix>,
32 : ::wfc::json::enum_value<n_CreatePrefixFail, common_status, common_status::CreatePrefixFail>,
33 : ::wfc::json::enum_value<n_PrefixNotFound, common_status, common_status::PrefixNotFound>,
34 : ::wfc::json::enum_value<n_CreateSnapshotFail, common_status, common_status::CreateSnapshotFail>,
35 : ::wfc::json::enum_value<n_SnapshotNotFound, common_status, common_status::SnapshotNotFound>,
36 : ::wfc::json::enum_value<n_TooManyKeys, common_status, common_status::TooManyKeys>,
37 : ::wfc::json::enum_value<n_KeyLengthExceeded, common_status, common_status::KeyLengthExceeded>,
38 : ::wfc::json::enum_value<n_ValueLengthExceeded, common_status, common_status::ValueLengthExceeded>,
39 : ::wfc::json::enum_value<n_PrefixLengthExceeded, common_status, common_status::PrefixLengthExceeded>,
40 : ::wfc::json::enum_value<n_RangeLimitExceeded, common_status, common_status::RangeLimitExceeded>,
41 : ::wfc::json::enum_value<n_InvalidSeqNumber, common_status, common_status::InvalidSeqNumber>,
42 : ::wfc::json::enum_value<n_CompactFail, common_status, common_status::CompactFail>
43 : >
44 : > type;
45 :
46 : typedef type::target target;
47 : typedef type::serializer serializer;
48 : typedef type::member_list member_list;
49 : };
50 :
51 : }}
52 :
53 : namespace std{
54 0 : inline std::ostream& operator<< (std::ostream& os, wamba::prefixdb::common_status cs)
55 : {
56 0 : std::string status;
57 0 : wamba::prefixdb::common_status_json::serializer()(cs, std::back_inserter(status) );
58 0 : if (!status.empty() && status[0]=='"')
59 0 : status.erase(status.begin());
60 0 : if (!status.empty() && *status.rbegin()=='"')
61 0 : status.pop_back();
62 :
63 0 : os << status;
64 0 : return os;
65 : }
66 : }
|