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

@ -7,8 +7,7 @@
#include <memory>
#include <vector>
namespace zeek::packet_analysis
{
namespace zeek::packet_analysis {
class Analyzer; // Forward declaration for Value
using AnalyzerPtr = std::shared_ptr<zeek::packet_analysis::Analyzer>;
@ -16,52 +15,51 @@ using AnalyzerPtr = std::shared_ptr<zeek::packet_analysis::Analyzer>;
/**
* The Dispatcher class manages identifier-to-analyzer mappings.
*/
class Dispatcher
{
class Dispatcher {
public:
Dispatcher() : table(std::vector<AnalyzerPtr>(1, nullptr)){};
~Dispatcher();
Dispatcher() : table(std::vector<AnalyzerPtr>(1, nullptr)){};
~Dispatcher();
/**
* Register an analyzer for a given identifier.
*
* @param identifier The identifier.
* @param analyzer The analyzer to register.
*/
void Register(uint32_t identifier, AnalyzerPtr analyzer);
/**
* Register an analyzer for a given identifier.
*
* @param identifier The identifier.
* @param analyzer The analyzer to register.
*/
void Register(uint32_t identifier, AnalyzerPtr analyzer);
/**
* Looks up the analyzer for an identifier.
*
* @param identifier The identifier to look up.
* @return The analyzer registered for the given identifier. Returns a
* nullptr if no analyzer is registered.
*/
AnalyzerPtr Lookup(uint32_t identifier) const;
/**
* Looks up the analyzer for an identifier.
*
* @param identifier The identifier to look up.
* @return The analyzer registered for the given identifier. Returns a
* nullptr if no analyzer is registered.
*/
AnalyzerPtr Lookup(uint32_t identifier) const;
/**
* Returns the number of registered analyzers.
* @return Number of registered analyzers.
*/
size_t Count() const;
/**
* Returns the number of registered analyzers.
* @return Number of registered analyzers.
*/
size_t Count() const;
/**
* Removes all mappings from the dispatcher.
*/
void Clear();
/**
* Removes all mappings from the dispatcher.
*/
void Clear();
/**
* Dumps out the data structure to the \c analyzer debug stream.
*/
void DumpDebug() const;
/**
* Dumps out the data structure to the \c analyzer debug stream.
*/
void DumpDebug() const;
private:
uint32_t lowest_identifier = 0;
std::vector<AnalyzerPtr> table;
uint32_t lowest_identifier = 0;
std::vector<AnalyzerPtr> table;
void FreeValues();
void FreeValues();
inline uint32_t GetHighestIdentifier() const { return lowest_identifier + table.size() - 1; }
};
inline uint32_t GetHighestIdentifier() const { return lowest_identifier + table.size() - 1; }
};
}
} // namespace zeek::packet_analysis