Reformat Zeek in Spicy style

This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
This commit is contained in:
Benjamin Bannier 2023-10-10 21:13:34 +02:00
parent 7b8e7ed72c
commit f5a76c1aed
786 changed files with 131714 additions and 153609 deletions

View file

@ -12,55 +12,48 @@
#include "zeek/threading/Formatter.h"
namespace zeek::json::detail
{
namespace zeek::json::detail {
class NullDoubleWriter;
}
}
namespace zeek::threading::formatter
{
namespace zeek::threading::formatter {
/**
* A thread-safe class for converting values into a JSON representation
* and vice versa.
*/
class JSON : public Formatter
{
class JSON : public Formatter {
public:
enum TimeFormat
{
TS_EPOCH, // Doubles that represents seconds from the UNIX epoch.
TS_ISO8601, // ISO 8601 defined human readable timestamp format.
TS_MILLIS // Milliseconds from the UNIX epoch. Some consumers need this (e.g.,
// elasticsearch).
};
enum TimeFormat {
TS_EPOCH, // Doubles that represents seconds from the UNIX epoch.
TS_ISO8601, // ISO 8601 defined human readable timestamp format.
TS_MILLIS // Milliseconds from the UNIX epoch. Some consumers need this (e.g.,
// elasticsearch).
};
JSON(MsgThread* t, TimeFormat tf, bool include_unset_fields = false);
~JSON() override = default;
JSON(MsgThread* t, TimeFormat tf, bool include_unset_fields = false);
~JSON() override = default;
bool Describe(ODesc* desc, Value* val, const std::string& name = "") const override;
bool Describe(ODesc* desc, int num_fields, const Field* const* fields,
Value** vals) const override;
Value* ParseValue(const std::string& s, const std::string& name, TypeTag type,
TypeTag subtype = TYPE_ERROR) const override;
bool Describe(ODesc* desc, Value* val, const std::string& name = "") const override;
bool Describe(ODesc* desc, int num_fields, const Field* const* fields, Value** vals) const override;
Value* ParseValue(const std::string& s, const std::string& name, TypeTag type,
TypeTag subtype = TYPE_ERROR) const override;
class NullDoubleWriter : public rapidjson::Writer<rapidjson::StringBuffer>
{
public:
[[deprecated("Remove in v7.1 - This is an implementation detail.")]] NullDoubleWriter(
rapidjson::StringBuffer& stream);
bool Double(double d);
class NullDoubleWriter : public rapidjson::Writer<rapidjson::StringBuffer> {
public:
[[deprecated("Remove in v7.1 - This is an implementation detail.")]] NullDoubleWriter(
rapidjson::StringBuffer& stream);
bool Double(double d);
private:
std::unique_ptr<json::detail::NullDoubleWriter> writer;
};
private:
std::unique_ptr<json::detail::NullDoubleWriter> writer;
};
private:
void BuildJSON(zeek::json::detail::NullDoubleWriter& writer, Value* val,
const std::string& name = "") const;
void BuildJSON(zeek::json::detail::NullDoubleWriter& writer, Value* val, const std::string& name = "") const;
TimeFormat timestamps;
bool include_unset_fields;
};
TimeFormat timestamps;
bool include_unset_fields;
};
} // namespace zeek::threading::formatter
} // namespace zeek::threading::formatter