Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -61,7 +61,10 @@ json_t const * GetJSONOptionalField(json_t const * root, char const * field)
return json_object_get(root, field);
}
bool JSONIsNull(json_t const * root) { return json_is_null(root); }
bool JSONIsNull(json_t const * root)
{
return json_is_null(root);
}
std::string DumpToString(JSONPtr const & json, size_t flags)
{
@@ -138,5 +141,8 @@ void FromJSON(json_t const * root, UniString & result)
result = MakeUniString(s);
}
base::JSONPtr ToJSON(UniString const & s) { return ToJSON(ToUtf8(s)); }
base::JSONPtr ToJSON(UniString const & s)
{
return ToJSON(ToUtf8(s));
}
} // namespace strings

View File

@@ -26,13 +26,34 @@ struct JSONDecRef
using JSONPtr = std::unique_ptr<json_t, JSONDecRef>;
inline JSONPtr NewJSONObject() { return JSONPtr(json_object()); }
inline JSONPtr NewJSONArray() { return JSONPtr(json_array()); }
inline JSONPtr NewJSONString(std::string const & s) { return JSONPtr(json_string(s.c_str())); }
inline JSONPtr NewJSONInt(json_int_t value) { return JSONPtr(json_integer(value)); }
inline JSONPtr NewJSONReal(double value) { return JSONPtr(json_real(value)); }
inline JSONPtr NewJSONBool(bool value) { return JSONPtr(value ? json_true() : json_false()); }
inline JSONPtr NewJSONNull() { return JSONPtr(json_null()); }
inline JSONPtr NewJSONObject()
{
return JSONPtr(json_object());
}
inline JSONPtr NewJSONArray()
{
return JSONPtr(json_array());
}
inline JSONPtr NewJSONString(std::string const & s)
{
return JSONPtr(json_string(s.c_str()));
}
inline JSONPtr NewJSONInt(json_int_t value)
{
return JSONPtr(json_integer(value));
}
inline JSONPtr NewJSONReal(double value)
{
return JSONPtr(json_real(value));
}
inline JSONPtr NewJSONBool(bool value)
{
return JSONPtr(value ? json_true() : json_false());
}
inline JSONPtr NewJSONNull()
{
return JSONPtr(json_null());
}
class Json
{
@@ -85,8 +106,7 @@ inline json_t const * GetJSONObligatoryFieldByPath(json_t const * root, First &&
}
template <class First, class... Paths>
inline json_t const * GetJSONObligatoryFieldByPath(json_t const * root, First && path,
Paths &&... paths)
inline json_t const * GetJSONObligatoryFieldByPath(json_t const * root, First && path, Paths &&... paths)
{
json_t const * newRoot = GetJSONObligatoryFieldByPath(root, std::forward<First>(path));
return GetJSONObligatoryFieldByPath(newRoot, std::forward<Paths>(paths)...);
@@ -99,8 +119,7 @@ inline json_t * GetJSONObligatoryFieldByPath(json_t * root, First && path)
}
template <class First, class... Paths>
inline json_t * GetJSONObligatoryFieldByPath(json_t * root, First && path,
Paths &&... paths)
inline json_t * GetJSONObligatoryFieldByPath(json_t * root, First && path, Paths &&... paths)
{
json_t * newRoot = GetJSONObligatoryFieldByPath(root, std::forward<First>(path));
return GetJSONObligatoryFieldByPath(newRoot, std::forward<Paths>(paths)...);
@@ -117,8 +136,14 @@ T FromJSON(json_t const * root)
return result;
}
inline void FromJSON(json_t * root, json_t *& value) { value = root; }
inline void FromJSON(json_t const * root, json_t const *& value) { value = root; }
inline void FromJSON(json_t * root, json_t *& value)
{
value = root;
}
inline void FromJSON(json_t const * root, json_t const *& value)
{
value = root;
}
void FromJSON(json_t const * root, double & result);
void FromJSON(json_t const * root, bool & result);
@@ -190,9 +215,18 @@ inline base::JSONPtr ToJSON(T value)
{
return base::NewJSONInt(value);
}
inline base::JSONPtr ToJSON(double value) { return base::NewJSONReal(value); }
inline base::JSONPtr ToJSON(bool value) { return base::NewJSONBool(value); }
inline base::JSONPtr ToJSON(char const * s) { return base::NewJSONString(s); }
inline base::JSONPtr ToJSON(double value)
{
return base::NewJSONReal(value);
}
inline base::JSONPtr ToJSON(bool value)
{
return base::NewJSONBool(value);
}
inline base::JSONPtr ToJSON(char const * s)
{
return base::NewJSONString(s);
}
template <typename T>
void ToJSONArray(json_t & root, T const & value)
@@ -205,7 +239,10 @@ inline void ToJSONArray(json_t & parent, base::JSONPtr & child)
json_array_append_new(&parent, child.release());
}
inline void ToJSONArray(json_t & parent, json_t & child) { json_array_append_new(&parent, &child); }
inline void ToJSONArray(json_t & parent, json_t & child)
{
json_array_append_new(&parent, &child);
}
template <typename T>
void ToJSONObject(json_t & root, char const * field, T const & value)
@@ -331,7 +368,10 @@ struct JSONFreeDeleter
namespace std
{
void FromJSON(json_t const * root, std::string & result);
inline base::JSONPtr ToJSON(std::string const & s) { return base::NewJSONString(s); }
inline base::JSONPtr ToJSON(std::string const & s)
{
return base::NewJSONString(s);
}
} // namespace std
namespace strings

View File

@@ -12,47 +12,26 @@ class JsonHandle
void DecRef();
public:
JsonHandle(json_t * pJson = 0) : m_pJson(pJson)
{
IncRef();
}
JsonHandle(json_t * pJson = 0) : m_pJson(pJson) { IncRef(); }
JsonHandle(JsonHandle const & json) : m_pJson(json.m_pJson)
{
IncRef();
}
JsonHandle(JsonHandle const & json) : m_pJson(json.m_pJson) { IncRef(); }
~JsonHandle()
{
DecRef();
}
~JsonHandle() { DecRef(); }
JsonHandle & operator = (JsonHandle const & json)
JsonHandle & operator=(JsonHandle const & json)
{
JsonHandle tmp(json);
tmp.swap(*this);
return *this;
}
void swap(JsonHandle & json)
{
std::swap(m_pJson, json.m_pJson);
}
void swap(JsonHandle & json) { std::swap(m_pJson, json.m_pJson); }
json_t * get() const
{
return m_pJson;
}
json_t * get() const { return m_pJson; }
json_t * operator -> () const
{
return m_pJson;
}
json_t * operator->() const { return m_pJson; }
operator bool () const
{
return m_pJson != 0;
}
operator bool() const { return m_pJson != 0; }
/// Attach newly created object without incrementing ref count (it's already == 1).
void AttachNew(json_t * pJson)