mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
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:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
221
src/Tag.h
221
src/Tag.h
|
@ -10,8 +10,7 @@
|
|||
#include "zeek/IntrusivePtr.h"
|
||||
#include "zeek/util.h"
|
||||
|
||||
namespace zeek
|
||||
{
|
||||
namespace zeek {
|
||||
|
||||
class EnumVal;
|
||||
using EnumValPtr = IntrusivePtr<EnumVal>;
|
||||
|
@ -36,138 +35,130 @@ using EnumTypePtr = IntrusivePtr<EnumType>;
|
|||
* The Tag class supports all operations necessary to act as an index in a
|
||||
* \c std::map.
|
||||
*/
|
||||
class Tag
|
||||
{
|
||||
class Tag {
|
||||
public:
|
||||
/**
|
||||
* Type for the component's main type.
|
||||
*/
|
||||
using type_t = uint32_t;
|
||||
/**
|
||||
* Type for the component's main type.
|
||||
*/
|
||||
using type_t = uint32_t;
|
||||
|
||||
/**
|
||||
* Type for the component's subtype.
|
||||
*/
|
||||
using subtype_t = uint32_t;
|
||||
/**
|
||||
* Type for the component's subtype.
|
||||
*/
|
||||
using subtype_t = uint32_t;
|
||||
|
||||
/**
|
||||
* Returns the tag's main type.
|
||||
*/
|
||||
type_t Type() const { return type; }
|
||||
/**
|
||||
* Returns the tag's main type.
|
||||
*/
|
||||
type_t Type() const { return type; }
|
||||
|
||||
/**
|
||||
* Returns the tag's subtype.
|
||||
*/
|
||||
subtype_t Subtype() const { return subtype; }
|
||||
/**
|
||||
* Returns the tag's subtype.
|
||||
*/
|
||||
subtype_t Subtype() const { return subtype; }
|
||||
|
||||
/**
|
||||
* Default constructor. This initializes the tag with an error value
|
||||
* that will make \c operator \c bool return false.
|
||||
*/
|
||||
Tag();
|
||||
/**
|
||||
* Default constructor. This initializes the tag with an error value
|
||||
* that will make \c operator \c bool return false.
|
||||
*/
|
||||
Tag();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*
|
||||
* @param type The main type. Note that the manager class manages the
|
||||
* the value space internally, so noone else should assign main types.
|
||||
*
|
||||
* @param subtype The sub type, which is left to a component for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
Tag(const EnumTypePtr& etype, type_t type, subtype_t subtype = 0);
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*
|
||||
* @param type The main type. Note that the manager class manages the
|
||||
* the value space internally, so noone else should assign main types.
|
||||
*
|
||||
* @param subtype The sub type, which is left to a component for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
Tag(const EnumTypePtr& etype, type_t type, subtype_t subtype = 0);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param type The main type. Note that the \a component::Manager
|
||||
* manages the value space internally, so noone else should assign
|
||||
* any main types.
|
||||
*
|
||||
* @param subtype The sub type, which is left to an component for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
explicit Tag(type_t type, subtype_t subtype = 0);
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param type The main type. Note that the \a component::Manager
|
||||
* manages the value space internally, so noone else should assign
|
||||
* any main types.
|
||||
*
|
||||
* @param subtype The sub type, which is left to an component for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
explicit Tag(type_t type, subtype_t subtype = 0);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param val An enum value of script type \c Component::Tag.
|
||||
*/
|
||||
explicit Tag(EnumValPtr val);
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param val An enum value of script type \c Component::Tag.
|
||||
*/
|
||||
explicit Tag(EnumValPtr val);
|
||||
|
||||
/*
|
||||
* Copy constructor.
|
||||
*/
|
||||
Tag(const Tag& other);
|
||||
/*
|
||||
* Copy constructor.
|
||||
*/
|
||||
Tag(const Tag& other);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Tag();
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Tag();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
*/
|
||||
Tag& operator=(const Tag& other);
|
||||
/**
|
||||
* Assignment operator.
|
||||
*/
|
||||
Tag& operator=(const Tag& other);
|
||||
|
||||
/**
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Tag& operator=(Tag&& other) noexcept;
|
||||
/**
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Tag& operator=(Tag&& other) noexcept;
|
||||
|
||||
/**
|
||||
* Compares two tags for equality.
|
||||
*/
|
||||
bool operator==(const Tag& other) const
|
||||
{
|
||||
return type == other.type && subtype == other.subtype;
|
||||
}
|
||||
/**
|
||||
* Compares two tags for equality.
|
||||
*/
|
||||
bool operator==(const Tag& other) const { return type == other.type && subtype == other.subtype; }
|
||||
|
||||
/**
|
||||
* Compares two tags for inequality.
|
||||
*/
|
||||
bool operator!=(const Tag& other) const
|
||||
{
|
||||
return type != other.type || subtype != other.subtype;
|
||||
}
|
||||
/**
|
||||
* Compares two tags for inequality.
|
||||
*/
|
||||
bool operator!=(const Tag& other) const { return type != other.type || subtype != other.subtype; }
|
||||
|
||||
/**
|
||||
* Compares two tags for less-than relationship.
|
||||
*/
|
||||
bool operator<(const Tag& other) const
|
||||
{
|
||||
return type != other.type ? type < other.type : (subtype < other.subtype);
|
||||
}
|
||||
/**
|
||||
* Compares two tags for less-than relationship.
|
||||
*/
|
||||
bool operator<(const Tag& other) const {
|
||||
return type != other.type ? type < other.type : (subtype < other.subtype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numerical values for main and subtype inside a string
|
||||
* suitable for printing. This is primarily for debugging.
|
||||
*/
|
||||
std::string AsString() const;
|
||||
/**
|
||||
* Returns the numerical values for main and subtype inside a string
|
||||
* suitable for printing. This is primarily for debugging.
|
||||
*/
|
||||
std::string AsString() const;
|
||||
|
||||
/**
|
||||
* Returns the script-layer enum that corresponds to this tag.
|
||||
* The returned value does not have its ref-count increased.
|
||||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*/
|
||||
const EnumValPtr& AsVal() const { return val; }
|
||||
/**
|
||||
* Returns the script-layer enum that corresponds to this tag.
|
||||
* The returned value does not have its ref-count increased.
|
||||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*/
|
||||
const EnumValPtr& AsVal() const { return val; }
|
||||
|
||||
/**
|
||||
* Returns false if the tag represents an error value rather than a
|
||||
* legal component type.
|
||||
*/
|
||||
explicit operator bool() const { return *this != Error; }
|
||||
/**
|
||||
* Returns false if the tag represents an error value rather than a
|
||||
* legal component type.
|
||||
*/
|
||||
explicit operator bool() const { return *this != Error; }
|
||||
|
||||
static const Tag Error;
|
||||
static const Tag Error;
|
||||
|
||||
private:
|
||||
type_t type = 0; // Main type.
|
||||
subtype_t subtype = 0; // Subtype.
|
||||
EnumValPtr val; // Script-layer value.
|
||||
EnumTypePtr etype;
|
||||
};
|
||||
type_t type = 0; // Main type.
|
||||
subtype_t subtype = 0; // Subtype.
|
||||
EnumValPtr val; // Script-layer value.
|
||||
EnumTypePtr etype;
|
||||
};
|
||||
|
||||
} // namespace zeek
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue