mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 00:27:27 -04:00
Improve debugabbility of JSON API
JSON API server uses standardized error handling based on std::error_condition for a few method, this improve debugabbility both from library size and from API client side JSON API auth token are now more flexible, now the only proibition is using colon character ':' in user name Implemented TO_JSON operation for std::error_condition Avoid unkown serial job handling code duplication via fatalUnknownSerialJob Usability improvement in t_RsLogger Disable compilation of now unused is_alphanumeric
This commit is contained in:
parent
9c65836503
commit
5dbbe1ffd7
9 changed files with 311 additions and 99 deletions
|
@ -41,12 +41,14 @@ struct t_RsLogger
|
|||
{
|
||||
inline t_RsLogger() = default;
|
||||
|
||||
typedef t_RsLogger stream_type;
|
||||
|
||||
template<typename T>
|
||||
inline t_RsLogger& operator<<(const T& val)
|
||||
inline stream_type& operator<<(const T& val)
|
||||
{ ostr << val; return *this; }
|
||||
|
||||
/// needed for manipulators and things like std::endl
|
||||
t_RsLogger& operator<<(std::ostream& (*pf)(std::ostream&))
|
||||
stream_type& operator<<(std::ostream& (*pf)(std::ostream&))
|
||||
{
|
||||
if(pf == static_cast<std::ostream& (*)(std::ostream&)>(
|
||||
&std::endl< char, std::char_traits<char> > ))
|
||||
|
@ -84,8 +86,10 @@ struct t_RsLogger
|
|||
{
|
||||
inline t_RsLogger() = default;
|
||||
|
||||
typedef decltype(std::cerr) stream_type;
|
||||
|
||||
template<typename T>
|
||||
inline std::ostream& operator<<(const T& val)
|
||||
inline stream_type& operator<<(const T& val)
|
||||
{
|
||||
return std::cerr << static_cast<char>(CATEGORY) << " " << time(nullptr)
|
||||
<< " " << val;
|
||||
|
|
|
@ -205,6 +205,7 @@ bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool is_alphanumeric(char c)
|
||||
{
|
||||
return (c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z');
|
||||
|
@ -216,6 +217,7 @@ bool is_alphanumeric(const std::string& s)
|
|||
if(!is_alphanumeric(s[i])) return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
} } // librs::util
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ namespace librs {
|
|||
|
||||
bool ConvertUtf8ToUtf16(const std::string& source, std::wstring& dest);
|
||||
bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest);
|
||||
|
||||
#if 0
|
||||
bool is_alphanumeric(char c) ;
|
||||
bool is_alphanumeric(const std::string& s);
|
||||
|
||||
#endif
|
||||
} } // librs::util
|
||||
|
||||
#ifdef WIN32
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue