Struct write_interface
Defined in File jwt.hpp
Inheritance Relationships
Derived Types
public jwt::jwt_header
(Struct jwt_header)public jwt::jwt_payload
(Struct jwt_payload)
Struct Documentation
-
struct write_interface
A helper class providing the necessary functionalities for: a) converting an object into JSON string. b) writing to a standard output stream in JSON format. c) writing to standard console in JSON format using overloaded ‘<<’ operator.
Note
: The JWT component classes inherits from this class to get the above functionalities.
Subclassed by jwt::jwt_header, jwt::jwt_payload
Friends
-
template<typename T, typename Cond>
friend std::string to_json_str(const T &obj, bool pretty) Converts an object of type
T
to its JSON string format.
For pretty print, pass second parameter as
true
.Note
: Type
T
must have a member function namedcreate_json_obj
. The check is made at compile time. Checkmeta::has_create_json_obj_member
for more details. This check is done inCond
template parameter.
-
template<typename T>
friend std::ostream &write(std::ostream &os, const T &obj, bool pretty) Writes the object of instance
T
in JSON format to standard output stream. The requirements on typeT
is same as that forto_json_str
API.
-
template<typename T, typename Cond>
friend std::ostream &operator<<(std::ostream &os, const T &obj) An overloaded operator for writing to standard ostream in JSON format. The requirements on type
T
is same as that forto_json_str
API.This API is same in functionality as that of
write
API. Only difference is that, there is no option to write the JSON representation in pretty format.
-
template<typename T, typename Cond>