mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -8,40 +8,48 @@
|
|||
|
||||
#include "zeek/threading/Formatter.h"
|
||||
|
||||
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 {
|
||||
* A thread-safe class for converting values into a JSON representation
|
||||
* and vice versa.
|
||||
*/
|
||||
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);
|
||||
~JSON() override;
|
||||
|
||||
bool Describe(ODesc* desc, Value* val, const std::string& name = "") const override;
|
||||
bool Describe(ODesc* desc, int num_fields, const Field* const * fields,
|
||||
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> {
|
||||
class NullDoubleWriter : public rapidjson::Writer<rapidjson::StringBuffer>
|
||||
{
|
||||
public:
|
||||
NullDoubleWriter(rapidjson::StringBuffer& stream) : rapidjson::Writer<rapidjson::StringBuffer>(stream) {}
|
||||
NullDoubleWriter(rapidjson::StringBuffer& stream)
|
||||
: rapidjson::Writer<rapidjson::StringBuffer>(stream)
|
||||
{
|
||||
}
|
||||
bool Double(double d);
|
||||
};
|
||||
};
|
||||
|
||||
private:
|
||||
void BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& name = "") const;
|
||||
|
||||
TimeFormat timestamps;
|
||||
bool surrounding_braces;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace zeek::threading::formatter
|
||||
} // namespace zeek::threading::formatter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue