Replace most uses of typedef with using for type aliasing

This commit is contained in:
Tim Wojtulewicz 2021-10-11 14:51:10 -07:00
parent 7101f30646
commit 64748edab1
44 changed files with 100 additions and 101 deletions

View file

@ -37,7 +37,7 @@ enum ip_addr_anonymization_method_t
NUM_ADDR_ANONYMIZATION_METHODS,
};
typedef uint32_t ipaddr32_t;
using ipaddr32_t = uint32_t;
// NOTE: all addresses in parameters of *public* functions are in
// network order.

View file

@ -124,9 +124,9 @@ protected:
ListValPtr AddrListDelta(ListVal* al1, ListVal* al2);
void DumpAddrList(FILE* f, ListVal* al);
typedef std::map<std::string, std::pair<DNS_Mapping*, DNS_Mapping*>> HostMap;
typedef std::map<IPAddr, DNS_Mapping*> AddrMap;
typedef std::map<std::string, DNS_Mapping*> TextMap;
using HostMap = std::map<std::string, std::pair<DNS_Mapping*, DNS_Mapping*>>;
using AddrMap = std::map<IPAddr, DNS_Mapping*>;
using TextMap = std::map<std::string, DNS_Mapping*>;
void LoadCache(FILE* f);
void Save(FILE* f, const AddrMap& m);
void Save(FILE* f, const HostMap& m);
@ -168,7 +168,7 @@ protected:
RecordTypePtr dm_rec;
typedef std::list<LookupCallback*> CallbackList;
using CallbackList = std::list<LookupCallback*>;
struct AsyncRequest
{
@ -217,16 +217,16 @@ protected:
}
};
typedef std::map<IPAddr, AsyncRequest*> AsyncRequestAddrMap;
using AsyncRequestAddrMap = std::map<IPAddr, AsyncRequest*>;
AsyncRequestAddrMap asyncs_addrs;
typedef std::map<std::string, AsyncRequest*> AsyncRequestNameMap;
using AsyncRequestNameMap = std::map<std::string, AsyncRequest*>;
AsyncRequestNameMap asyncs_names;
typedef std::map<std::string, AsyncRequest*> AsyncRequestTextMap;
using AsyncRequestTextMap = std::map<std::string, AsyncRequest*>;
AsyncRequestTextMap asyncs_texts;
typedef std::list<AsyncRequest*> QueuedList;
using QueuedList = std::list<AsyncRequest*>;
QueuedList asyncs_queued;
struct AsyncRequestCompare
@ -234,8 +234,8 @@ protected:
bool operator()(const AsyncRequest* a, const AsyncRequest* b) { return a->time > b->time; }
};
typedef std::priority_queue<AsyncRequest*, std::vector<AsyncRequest*>, AsyncRequestCompare>
TimeoutQueue;
using TimeoutQueue =
std::priority_queue<AsyncRequest*, std::vector<AsyncRequest*>, AsyncRequestCompare>;
TimeoutQueue asyncs_timeouts;
unsigned long num_requests;

View file

@ -59,7 +59,7 @@ bool in_debug = false;
// ### fix this hardwired access to external variables etc.
struct yy_buffer_state;
typedef struct yy_buffer_state* YY_BUFFER_STATE;
using YY_BUFFER_STATE = struct yy_buffer_state*;
YY_BUFFER_STATE bro_scan_string(const char*);
extern YYLTYPE yylloc; // holds start line and column of token

View file

@ -267,7 +267,7 @@ size_t ODesc::StartsWithEscapeSequence(const char* start, const char* end)
std::pair<const char*, size_t> ODesc::FirstEscapeLoc(const char* bytes, size_t n)
{
typedef std::pair<const char*, size_t> escape_pos;
using escape_pos = std::pair<const char*, size_t>;
if ( IsBinary() )
return escape_pos(0, 0);

View file

@ -9,7 +9,7 @@
#include "zeek/Hash.h"
// Type for function to be called when deleting elements.
typedef void (*dict_delete_func)(void*);
using dict_delete_func = void (*)(void*);
namespace zeek
{

View file

@ -50,10 +50,10 @@ extern zeek::detail::BifReturnVal md5_hmac_bif(zeek::detail::Frame* frame, const
namespace zeek::detail
{
typedef uint64_t hash_t;
typedef uint64_t hash64_t;
typedef uint64_t hash128_t[2];
typedef uint64_t hash256_t[4];
using hash_t = uint64_t;
using hash64_t = uint64_t;
using hash128_t = uint64_t[2];
using hash256_t = uint64_t[4];
class KeyedHash
{
@ -219,12 +219,12 @@ private:
friend BifReturnVal BifFunc::md5_hmac_bif(zeek::detail::Frame* frame, const Args*);
};
typedef enum
{
enum HashKeyTag
{
HASH_KEY_INT,
HASH_KEY_DOUBLE,
HASH_KEY_STRING
} HashKeyTag;
};
constexpr int NUM_HASH_KEYS = HASH_KEY_STRING + 1;

View file

@ -87,7 +87,7 @@ private:
// Will be called from the object itself.
void Modified(Modifiable* m);
typedef std::unordered_multimap<Modifiable*, Receiver*> ModifiableMap;
using ModifiableMap = std::unordered_multimap<Modifiable*, Receiver*>;
ModifiableMap registrations;
};

View file

@ -36,7 +36,7 @@ public:
};
#define YYLTYPE zeek::detail::yyltype
typedef Location yyltype;
using yyltype = Location;
YYLTYPE GetCurrentLocation();
// Used to mean "no location associated with this object".

View file

@ -35,7 +35,7 @@ struct PolicyFile
vector<const char*> lines;
};
typedef map<string, PolicyFile*> PolicyFileMap;
using PolicyFileMap = map<string, PolicyFile*>;
static PolicyFileMap policy_files;
namespace zeek::detail

View file

@ -304,7 +304,7 @@ void Specific_RE_Matcher::Dump(FILE* f)
inline void RE_Match_State::AddMatches(const AcceptingSet& as, MatchPos position)
{
typedef std::pair<AcceptIdx, MatchPos> am_idx;
using am_idx = std::pair<AcceptIdx, MatchPos>;
for ( AcceptingSet::const_iterator it = as.begin(); it != as.end(); ++it )
accepted_matches.insert(am_idx(*it, position));

View file

@ -12,7 +12,7 @@
#include "zeek/EquivClass.h"
#include "zeek/List.h"
typedef int (*cce_func)(int);
using cce_func = int (*)(int);
// This method is automatically generated by flex and shouldn't be namespaced
extern int re_lex(void);

View file

@ -42,12 +42,12 @@ public:
/**
* Type for the analyzer's main type.
*/
typedef uint32_t type_t;
using type_t = uint32_t;
/**
* Type for the analyzer's subtype.
*/
typedef uint32_t subtype_t;
using subtype_t = uint32_t;
/**
* Returns the tag's main type.

View file

@ -1689,8 +1689,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
// Create temporary, reverse name map so that enums can be documented
// in ascending order of their actual integral value instead of by name.
typedef map<bro_int_t, std::string> RevNameMap;
using RevNameMap = std::map<bro_int_t, std::string>;
RevNameMap rev;
for ( NameMap::const_iterator it = names.begin(); it != names.end(); ++it )

View file

@ -743,7 +743,7 @@ protected:
class EnumType final : public Type
{
public:
typedef std::list<std::pair<std::string, bro_int_t>> enum_name_list;
using enum_name_list = std::list<std::pair<std::string, bro_int_t>>;
explicit EnumType(const EnumType* e);
explicit EnumType(const std::string& arg_name);
@ -792,7 +792,7 @@ protected:
bool is_export, detail::Expr* deprecation = nullptr,
bool from_redef = false);
typedef std::map<std::string, bro_int_t> NameMap;
using NameMap = std::map<std::string, bro_int_t>;
NameMap names;
// Whether any of the elements of the enum were added via redef's.

View file

@ -17,7 +17,7 @@ namespace zeek
//
class VectorVal;
typedef u_char* byte_vec;
using byte_vec = u_char*;
/**
* A container type for holding blocks of byte data. This can be used for
@ -28,18 +28,18 @@ typedef u_char* byte_vec;
class String
{
public:
typedef std::vector<String*> Vec;
typedef Vec::iterator VecIt;
typedef Vec::const_iterator VecCIt;
using Vec = std::vector<String*>;
using VecIt = Vec::iterator;
using VecCIt = Vec::const_iterator;
typedef std::vector<const String*> CVec;
typedef Vec::iterator CVecIt;
typedef Vec::const_iterator CVecCIt;
using CVec = std::vector<const String*>;
using CVecIt = Vec::iterator;
using CVecCIt = Vec::const_iterator;
// IdxVecs are vectors of indices of characters in a string.
typedef std::vector<int> IdxVec;
typedef IdxVec::iterator IdxVecIt;
typedef IdxVec::const_iterator IdxVecCIt;
using IdxVec = std::vector<int>;
using IdxVecIt = IdxVec::iterator;
using IdxVecCIt = IdxVec::const_iterator;
// Constructors creating internal copies of the data passed in.
String(const u_char* str, int arg_n, bool add_NUL);

View file

@ -57,8 +57,8 @@ class OutputHandler;
// to the children list, it can invalidate iterators in the outer call,
// causing a crash.
using analyzer_list = std::list<Analyzer*>;
typedef uint32_t ID;
typedef void (Analyzer::*analyzer_timer_func)(double t);
using ID = uint32_t;
using analyzer_timer_func = void (Analyzer::*)(double_t);
/**
* Class to receive processed output from an anlyzer.

View file

@ -28,7 +28,7 @@ class Analyzer;
class Component : public plugin::Component, public plugin::TaggedComponent<analyzer::Tag>
{
public:
typedef Analyzer* (*factory_callback)(Connection* conn);
using factory_callback = Analyzer* (*)(Connection* conn);
/**
* Constructor.

View file

@ -215,23 +215,23 @@ public:
~Contents_RPC() override;
protected:
typedef enum
{
enum state_t
{
WAIT_FOR_MESSAGE,
WAIT_FOR_MARKER,
WAIT_FOR_DATA,
WAIT_FOR_LAST_DATA,
} state_t;
};
typedef enum
{
enum resync_state_t
{
NEED_RESYNC,
RESYNC_WAIT_FOR_MSG_START,
RESYNC_WAIT_FOR_FULL_MSG,
RESYNC_HAD_FULL_MSG,
INSYNC,
RESYNC_INIT,
} resync_state_t;
};
void Init() override;
virtual bool CheckResync(int& len, const u_char*& data, bool orig);

View file

@ -424,8 +424,8 @@ protected:
static bool IsDisabled(const analyzer::Tag& tag);
private:
typedef std::set<Tag> TagSet;
typedef std::map<std::string, TagSet*> MIMEMap;
using TagSet = std::set<Tag>;
using MIMEMap = std::map<std::string, TagSet*>;
TagSet* LookupMIMEType(const std::string& mtype, bool add_if_not_found);

View file

@ -18,7 +18,7 @@ class ReaderBackend;
class Component : public plugin::Component, public plugin::TaggedComponent<Tag>
{
public:
typedef ReaderBackend* (*factory_callback)(ReaderFrontend* frontend);
using factory_callback = ReaderBackend* (*)(ReaderFrontend* frontend);
/**
* Constructor.

View file

@ -76,7 +76,7 @@ public:
struct ReaderInfo
{
// Structure takes ownership of the strings.
typedef std::map<const char*, const char*, util::CompareString> config_map;
using config_map = std::map<const char*, const char*, util::CompareString>;
/**
* A string left to the interpretation of the reader

View file

@ -20,7 +20,7 @@ class PktDumper;
class Component : public plugin::Component
{
public:
typedef IOSource* (*factory_callback)();
using factory_callback = IOSource* (*)();
/**
* Constructor.
@ -63,7 +63,7 @@ public:
BOTH ///< Live input as well as offline.
};
typedef PktSrc* (*factory_callback)(const std::string& path, bool is_live);
using factory_callback = PktSrc* (*)(const std::string& path, bool is_live);
/**
* Constructor.
@ -134,7 +134,7 @@ private:
class PktDumperComponent : public plugin::Component
{
public:
typedef PktDumper* (*factory_callback)(const std::string& path, bool append);
using factory_callback = PktDumper* (*)(const std::string& path, bool append);
/**
* XXX

View file

@ -8,9 +8,9 @@
#if defined(__OpenBSD__)
#include <net/bpf.h>
typedef struct bpf_timeval pkt_timeval;
using pkt_timeval = bpf_timeval;
#else
typedef struct timeval pkt_timeval;
using pkt_timeval = struct timeval;
#endif
#include <pcap.h> // For DLT_ constants

View file

@ -18,7 +18,7 @@ class WriterBackend;
class Component : public plugin::Component, public plugin::TaggedComponent<logging::Tag>
{
public:
typedef WriterBackend* (*factory_callback)(WriterFrontend* frontend);
using factory_callback = WriterBackend* (*)(WriterFrontend* frontend);
/**
* Constructor.

View file

@ -85,9 +85,8 @@ struct Manager::Stream
Func* policy;
list<Filter*> filters;
typedef pair<int, string> WriterPathPair;
typedef map<WriterPathPair, WriterInfo*> WriterMap;
using WriterPathPair = pair<int, string>;
using WriterMap = map<WriterPathPair, WriterInfo*>;
WriterMap writers; // Writers indexed by id/path pair.

View file

@ -53,7 +53,7 @@ public:
struct WriterInfo
{
// Structure takes ownership of these strings.
typedef std::map<const char*, const char*, util::CompareString> config_map;
using config_map = std::map<const char*, const char*, util::CompareString>;
/**
* A string left to the interpretation of the writer

View file

@ -15,11 +15,11 @@ enum TransportProto
extern const char* transport_proto_string(TransportProto proto);
typedef enum
{
enum IPFamily
{
IPv4,
IPv6
} IPFamily;
};
#include <sys/types.h>
#include <arpa/inet.h>

View file

@ -53,7 +53,7 @@ namespace plugin
class Manager
{
public:
typedef void (*bif_init_func)(Plugin*);
using bif_init_func = void (*)(Plugin*);
using plugin_list = std::list<Plugin*>;
using component_list = Plugin::component_list;
using inactive_plugin_list = std::list<std::pair<std::string, std::string>>;

View file

@ -574,9 +574,9 @@ using HookArgumentList = std::list<HookArgument>;
class Plugin
{
public:
typedef std::list<Component*> component_list;
typedef std::list<BifItem> bif_item_list;
typedef std::list<std::pair<HookType, int>> hook_list;
using component_list = std::list<Component*>;
using bif_item_list = std::list<BifItem>;
using hook_list = std::list<std::pair<HookType, int>>;
/**
* The different types of @loads supported by HookLoadFile.

View file

@ -21,9 +21,9 @@ namespace zeek::probabilistic::detail
class BitVector
{
public:
typedef uint64_t block_type;
typedef size_t size_type;
typedef bool const_reference;
using block_type = uint64_t;
using size_type = size_t;
using const_reference = bool;
static size_type npos;
static block_type bits_per_block;

View file

@ -25,8 +25,8 @@ class BitVector;
class CounterVector
{
public:
typedef size_t size_type;
typedef uint64_t count_type;
using size_type = size_t;
using count_type = uint64_t;
/**
* Constructs a counter vector having cells of a given width.

View file

@ -29,8 +29,8 @@ enum HasherType
class Hasher
{
public:
typedef zeek::detail::hash_t digest;
typedef std::vector<digest> digest_vector;
using digest = zeek::detail::hash_t;
using digest_vector = std::vector<digest>;
struct seed_t
{
// actually HH_U64, which has the same type

View file

@ -17,7 +17,7 @@ namespace detail
// An initialization hook for a collection of compiled-to-C++ functions
// (the result of a single invocation of the compiler on a set of scripts).
typedef void (*CPP_init_func)();
using CPP_init_func = void (*)();
// Tracks the initialization hooks for different compilation runs.
extern std::vector<CPP_init_func> CPP_init_funcs;

View file

@ -18,7 +18,7 @@ namespace zeek::detail
// across function calls).
class UseDefSet;
typedef std::shared_ptr<UseDefSet> UDs;
using UDs = std::shared_ptr<UseDefSet>;
class UseDefSet
{

View file

@ -29,7 +29,7 @@ class Timer;
}
class Session;
typedef void (Session::*timer_func)(double t);
using timer_func = void (Session::*)(double t);
class Session : public Obj
{

View file

@ -65,7 +65,7 @@ public:
*/
bool Terminating() const { return terminating; }
typedef std::list<std::pair<std::string, MsgThread::Stats>> msg_stats_list;
using msg_stats_list = std::list<std::pair<std::string, MsgThread::Stats>>;
/**
* Returns statistics from all current MsgThread instances.
@ -143,10 +143,10 @@ protected:
void StartHeartbeatTimer();
private:
typedef std::list<BasicThread*> all_thread_list;
using all_thread_list = std::list<BasicThread*>;
all_thread_list all_threads;
typedef std::list<MsgThread*> msg_thread_list;
using msg_thread_list = std::list<MsgThread*>;
msg_thread_list msg_threads;
bool did_process; // True if the last Process() found some work to do.

View file

@ -120,7 +120,7 @@ struct Value
bro_int_t size;
Value** vals;
};
typedef set_t vec_t;
using vec_t = set_t;
struct port_t
{
bro_uint_t port;

View file

@ -284,7 +284,7 @@ double calc_next_rotate(double current, double rotate_interval, double base);
template <class T> void delete_each(T* t)
{
typedef typename T::iterator iterator;
using iterator = typename T::iterator;
for ( iterator it = t->begin(); it != t->end(); ++it )
delete *it;
}

View file

@ -3087,14 +3087,14 @@ function decode_base64_conn%(cid: conn_id, s: string, a: string &default=""%): s
%}
%%{
typedef struct {
struct bro_uuid_t {
uint32_t time_low;
uint16_t time_mid;
uint16_t time_hi_and_version;
uint8_t clock_seq_hi_and_reserved;
uint8_t clock_seq_low;
uint8_t node[6];
} bro_uuid_t;
};
%%}
## Converts a bytes representation of a UUID into its string form. For example,

View file

@ -187,8 +187,8 @@ private:
bool from_redef;
};
typedef std::list<Redefinition*> redef_list;
typedef std::map<std::string, RecordField*> record_field_map;
using redef_list = std::list<Redefinition*>;
using record_field_map = std::map<std::string, RecordField*>;
std::vector<std::string> comments;
zeek::detail::IDPtr id;

View file

@ -32,7 +32,7 @@ class ScriptInfo;
*/
template <class T> struct InfoMap
{
typedef std::map<std::string, T*> map_type;
using map_type = std::map<std::string, T*>;
/**
* @param name Name of an info object to retrieve.
@ -216,8 +216,8 @@ public:
bool IsUpToDate(const std::string& target_file, const std::vector<T*>& dependencies) const;
private:
typedef std::vector<std::string> comment_buffer_t;
typedef std::map<std::string, comment_buffer_t> comment_buffer_map_t;
using comment_buffer_t = std::vector<std::string>;
using comment_buffer_map_t = std::map<std::string, comment_buffer_t>;
IdentifierInfo* CreateIdentifierInfo(zeek::detail::IDPtr id, ScriptInfo* script,
bool from_redef = false);

View file

@ -107,7 +107,7 @@ static string make_redef_summary(const string& heading, char underline, char bor
d.SetQuotes(true);
id->DescribeReSTShort(&d);
typedef list<IdentifierInfo::Redefinition> redef_list;
using redef_list = std::list<IdentifierInfo::Redefinition>;
redef_list redefs = (*it)->GetRedefs(from_script);
for ( redef_list::const_iterator iit = redefs.begin(); iit != redefs.end(); ++iit )

View file

@ -85,8 +85,8 @@ public:
std::vector<std::string> GetComments() const;
private:
typedef std::map<std::string, IdentifierInfo*> id_info_map;
typedef std::set<std::string> string_set;
using id_info_map = std::map<std::string, IdentifierInfo*>;
using string_set = std::set<std::string>;
time_t DoGetModificationTime() const override;

View file

@ -149,8 +149,8 @@ public:
}
private:
typedef Target* (*TargetFactoryFn)(const std::string& name, const std::string& pattern);
typedef std::map<std::string, TargetFactoryFn> target_creator_map;
using TargetFactoryFn = Target* (*)(const std::string& name, const std::string& pattern);
using target_creator_map = std::map<std::string, TargetFactoryFn>;
target_creator_map target_creators;
};
@ -167,7 +167,7 @@ public:
void CreateAnalyzerDoc(FILE* f) const { return DoCreateAnalyzerDoc(f); }
protected:
typedef void (*doc_creator_fn)(FILE*);
using doc_creator_fn = void (*)(FILE*);
AnalyzerTarget(const std::string& name, const std::string& pattern) : Target(name, pattern) { }
@ -262,7 +262,8 @@ private:
std::vector<PackageInfo*> pkg_deps;
std::vector<ScriptInfo*> script_deps;
typedef std::map<PackageInfo*, std::vector<ScriptInfo*>> manifest_t;
using manifest_t = std::map<PackageInfo*, std::vector<ScriptInfo*>>;
manifest_t pkg_manifest;
};