Merge pull request #82 from michael-loki/using

Update from `typedef` to `using` in .hpp files
pull/90/head
Jeff 6 years ago committed by GitHub
commit e2c0eb2683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,19 +17,19 @@ namespace llarp
const byte_t* const byte_t*
pq_keypair_to_secret(const byte_t* keypair); pq_keypair_to_secret(const byte_t* keypair);
typedef AlignedBuffer< SHAREDKEYSIZE > SharedSecret; using SharedSecret = AlignedBuffer< SHAREDKEYSIZE >;
typedef AlignedBuffer< 32 > KeyExchangeNonce; using KeyExchangeNonce = AlignedBuffer< 32 >;
typedef AlignedBuffer< PUBKEYSIZE > PubKey; using PubKey = AlignedBuffer< PUBKEYSIZE >;
typedef AlignedBuffer< SECKEYSIZE > SecretKey; using SecretKey = AlignedBuffer< SECKEYSIZE >;
typedef AlignedBuffer< SHORTHASHSIZE > ShortHash; using ShortHash = AlignedBuffer< SHORTHASHSIZE >;
typedef AlignedBuffer< SIGSIZE > Signature; using Signature = AlignedBuffer< SIGSIZE >;
typedef AlignedBuffer< TUNNONCESIZE > TunnelNonce; using TunnelNonce = AlignedBuffer< TUNNONCESIZE >;
typedef AlignedBuffer< NONCESIZE > SymmNonce; using SymmNonce = AlignedBuffer< NONCESIZE >;
typedef AlignedBuffer< 32 > SymmKey; using SymmKey = AlignedBuffer< 32 >;
typedef AlignedBuffer< PQ_CIPHERTEXTSIZE + 1 > PQCipherBlock; using PQCipherBlock = AlignedBuffer< PQ_CIPHERTEXTSIZE + 1 >;
typedef AlignedBuffer< PQ_PUBKEYSIZE > PQPubKey; using PQPubKey = AlignedBuffer< PQ_PUBKEYSIZE >;
typedef AlignedBuffer< PQ_KEYPAIRSIZE > PQKeyPair; using PQKeyPair = AlignedBuffer< PQ_KEYPAIRSIZE >;
} // namespace llarp } // namespace llarp

@ -14,7 +14,7 @@ namespace llarp
template < typename Val_t > template < typename Val_t >
struct Bucket struct Bucket
{ {
typedef std::map< Key_t, Val_t, XorMetric > BucketStorage_t; using BucketStorage_t = std::map< Key_t, Val_t, XorMetric >;
Bucket(const Key_t& us) : nodes(XorMetric(us)){}; Bucket(const Key_t& us) : nodes(XorMetric(us)){};

@ -126,11 +126,11 @@ namespace llarp
SendReply() = 0; SendReply() = 0;
}; };
typedef std::function< void(const std::vector< service::IntroSet >&) > using IntroSetLookupHandler =
IntroSetLookupHandler; std::function< void(const std::vector< service::IntroSet >&) >;
typedef std::function< void(const std::vector< RouterContact >&) > using RouterLookupHandler =
RouterLookupHandler; std::function< void(const std::vector< RouterContact >&) >;
struct Context struct Context
{ {

@ -9,8 +9,8 @@
#include "dnsd.hpp" #include "dnsd.hpp"
typedef bool (*map_address_hook_func)(const llarp::service::Address &addr, using map_address_hook_func =
uint32_t ip); std::function< bool(const llarp::service::Address &addr, uint32_t ip) >;
/// dotLokiLookup context/config /// dotLokiLookup context/config
struct dotLokiLookup struct dotLokiLookup

@ -14,8 +14,9 @@
struct dnsd_context; struct dnsd_context;
/// sendto hook functor /// sendto hook functor
typedef ssize_t (*sendto_dns_hook_func)(void *sock, const struct sockaddr *from, using sendto_dns_hook_func =
const void *buffer, size_t length); std::function< ssize_t(void *sock, const struct sockaddr *from,
const void *buffer, size_t length) >;
// FIXME: llarp::Addr // FIXME: llarp::Addr
/// DNS server query request /// DNS server query request
@ -89,9 +90,9 @@ writesend_dnss_revresponse(std::string reverse, const struct sockaddr *from,
// //
/// intercept query hook functor /// intercept query hook functor
typedef dnsd_query_hook_response *(*intercept_query_hook)( using intercept_query_hook = std::function< dnsd_query_hook_response *(
std::string name, const struct sockaddr *from, std::string name, const struct sockaddr *from,
struct dnsd_question_request *request); struct dnsd_question_request *request) >;
// FIXME: llarp::Addr // FIXME: llarp::Addr
/// DNS Server context /// DNS Server context

@ -50,7 +50,7 @@ namespace llarp
template < typename User > template < typename User >
struct AsyncFrameEncrypter struct AsyncFrameEncrypter
{ {
typedef void (*EncryptHandler)(EncryptedFrame*, User*); using EncryptHandler = std::function< void(EncryptedFrame*, User*) >;
static void static void
Encrypt(void* user) Encrypt(void* user)
@ -96,7 +96,7 @@ namespace llarp
template < typename User > template < typename User >
struct AsyncFrameDecrypter struct AsyncFrameDecrypter
{ {
typedef void (*DecryptHandler)(llarp_buffer_t*, User*); using DecryptHandler = std::function< void(llarp_buffer_t*, User*) >;
static void static void
Decrypt(void* user) Decrypt(void* user)

@ -119,10 +119,9 @@ namespace llarp
ObtainIPForAddr(const byte_t* addr); ObtainIPForAddr(const byte_t* addr);
protected: protected:
typedef llarp::util::CoDelQueue< using PacketQueue_t = llarp::util::CoDelQueue<
net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime, net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime,
net::IPv4Packet::CompareOrder, net::IPv4Packet::GetNow > net::IPv4Packet::CompareOrder, net::IPv4Packet::GetNow >;
PacketQueue_t;
/// queue for sending packets over the network from us /// queue for sending packets over the network from us
PacketQueue_t m_UserToNetworkPktQueue; PacketQueue_t m_UserToNetworkPktQueue;
/// queue for sending packets to user from network /// queue for sending packets to user from network

@ -133,8 +133,8 @@ namespace llarp
uint32_t tick_id; uint32_t tick_id;
protected: protected:
typedef util::NullLock Lock; using Lock = util::NullLock;
typedef util::NullMutex Mutex; using Mutex = util::NullMutex;
void void
PutSession(ILinkSession* s); PutSession(ILinkSession* s);

@ -14,7 +14,7 @@ namespace llarp
{ {
struct ILinkSession; struct ILinkSession;
typedef std::queue< ILinkMessage* > SendQueue; using SendQueue = std::queue< ILinkMessage* >;
/// parsed link layer message /// parsed link layer message
struct ILinkMessage : public IBEncodeMessage struct ILinkMessage : public IBEncodeMessage

@ -83,7 +83,8 @@ llarp_nodedb_del_rc(struct llarp_nodedb *n, const llarp::RouterID &pk);
/// struct for async rc verification /// struct for async rc verification
struct llarp_async_verify_rc; struct llarp_async_verify_rc;
typedef void (*llarp_async_verify_rc_hook_func)(struct llarp_async_verify_rc *); using llarp_async_verify_rc_hook_func =
std::function< void(struct llarp_async_verify_rc *) >;
/// verify rc request /// verify rc request
struct llarp_async_verify_rc struct llarp_async_verify_rc
@ -118,7 +119,8 @@ llarp_nodedb_async_verify(struct llarp_async_verify_rc *job);
struct llarp_async_load_rc; struct llarp_async_load_rc;
typedef void (*llarp_async_load_rc_hook_func)(struct llarp_async_load_rc *); using llarp_async_load_rc_hook_func =
std::function< void(struct llarp_async_load_rc *) >;
struct llarp_async_load_rc struct llarp_async_load_rc
{ {

@ -280,19 +280,19 @@ namespace llarp
/// A path we made /// A path we made
struct Path : public IHopHandler, public llarp::routing::IMessageHandler struct Path : public IHopHandler, public llarp::routing::IMessageHandler
{ {
typedef std::function< void(Path*) > BuildResultHookFunc; using BuildResultHookFunc = std::function< void(Path*) >;
typedef std::function< bool(Path*, llarp_time_t) > CheckForDeadFunc; using CheckForDeadFunc = std::function< bool(Path*, llarp_time_t) >;
typedef std::function< bool(Path*, const PathID_t&, uint64_t) > using DropHandlerFunc =
DropHandlerFunc; std::function< bool(Path*, const PathID_t&, uint64_t) >;
typedef std::vector< PathHopConfig > HopList; using HopList = std::vector< PathHopConfig >;
typedef std::function< bool(Path*, const service::ProtocolFrame*) > using DataHandlerFunc =
DataHandlerFunc; std::function< bool(Path*, const service::ProtocolFrame*) >;
typedef std::function< bool(Path*) > ExitUpdatedFunc; using ExitUpdatedFunc = std::function< bool(Path*) >;
typedef std::function< bool(Path*) > ExitClosedFunc; using ExitClosedFunc = std::function< bool(Path*) >;
typedef std::function< bool(Path*, llarp_buffer_t) > using ExitTrafficHandlerFunc =
ExitTrafficHandlerFunc; std::function< bool(Path*, llarp_buffer_t) >;
/// (path, backoff) backoff is 0 on success /// (path, backoff) backoff is 0 on success
typedef std::function< bool(Path*, llarp_time_t) > ObtainedExitHandler; using ObtainedExitHandler = std::function< bool(Path*, llarp_time_t) >;
HopList hops; HopList hops;
@ -612,15 +612,15 @@ namespace llarp
void void
RemovePathSet(PathSet* set); RemovePathSet(PathSet* set);
typedef std::multimap< PathID_t, std::shared_ptr< TransitHop > > using TransitHopsMap_t =
TransitHopsMap_t; std::multimap< PathID_t, std::shared_ptr< TransitHop > >;
typedef std::pair< util::Mutex, TransitHopsMap_t > SyncTransitMap_t; using SyncTransitMap_t = std::pair< util::Mutex, TransitHopsMap_t >;
// maps path id -> pathset owner of path // maps path id -> pathset owner of path
typedef std::map< PathID_t, PathSet* > OwnedPathsMap_t; using OwnedPathsMap_t = std::map< PathID_t, PathSet* >;
typedef std::pair< util::Mutex, OwnedPathsMap_t > SyncOwnedPathsMap_t; using SyncOwnedPathsMap_t = std::pair< util::Mutex, OwnedPathsMap_t >;
llarp_threadpool* llarp_threadpool*
Worker(); Worker();

@ -6,7 +6,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< PATHIDSIZE > PathID_t; using PathID_t = AlignedBuffer< PATHIDSIZE >;
} }
#endif #endif

@ -176,7 +176,7 @@ namespace llarp
size_t m_NumPaths; size_t m_NumPaths;
private: private:
typedef std::pair< RouterID, PathID_t > PathInfo_t; using PathInfo_t = std::pair< RouterID, PathID_t >;
struct PathInfoHash struct PathInfoHash
{ {
@ -187,7 +187,7 @@ namespace llarp
} }
}; };
typedef std::unordered_map< PathInfo_t, Path*, PathInfoHash > PathMap_t; using PathMap_t = std::unordered_map< PathInfo_t, Path*, PathInfoHash >;
PathMap_t m_Paths; PathMap_t m_Paths;
}; };

@ -69,8 +69,8 @@ namespace llarp
MarkPathSuccess(path::Path* p); MarkPathSuccess(path::Path* p);
private: private:
typedef llarp::util::Lock lock_t; using lock_t = llarp::util::Lock;
typedef llarp::util::Mutex mtx_t; using mtx_t = llarp::util::Mutex;
mtx_t m_ProfilesMutex; mtx_t m_ProfilesMutex;
std::map< RouterID, RouterProfile > m_Profiles; std::map< RouterID, RouterProfile > m_Profiles;
}; };

@ -5,7 +5,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< 32 > RouterID; using RouterID = AlignedBuffer< 32 >;
} }
#endif #endif

@ -6,7 +6,7 @@
namespace llarp namespace llarp
{ {
typedef AlignedBuffer< 32 > RoutingEndpoint_t; using RoutingEndpoint_t = AlignedBuffer< 32 >;
/// Interface for end to end crypto between endpoints /// Interface for end to end crypto between endpoints
struct IRoutingEndpoint struct IRoutingEndpoint
@ -15,4 +15,4 @@ namespace llarp
}; };
} // namespace llarp } // namespace llarp
#endif #endif

@ -9,9 +9,9 @@ namespace llarp
{ {
struct Config struct Config
{ {
typedef std::list< std::pair< std::string, std::string > > using section_values_t =
section_values_t; std::list< std::pair< std::string, std::string > >;
typedef std::pair< std::string, section_values_t > section_t; using section_t = std::pair< std::string, section_values_t >;
std::list< section_t > services; std::list< section_t > services;
@ -20,4 +20,4 @@ namespace llarp
}; };
} // namespace service } // namespace service
} // namespace llarp } // namespace llarp
#endif #endif

@ -193,7 +193,7 @@ namespace llarp
bool bool
CheckPathIsDead(path::Path* p, llarp_time_t latency); CheckPathIsDead(path::Path* p, llarp_time_t latency);
typedef std::queue< PendingBuffer > PendingBufferQueue; using PendingBufferQueue = std::queue< PendingBuffer >;
struct SendContext struct SendContext
{ {
@ -331,7 +331,7 @@ namespace llarp
// passed a sendto context when we have a path established otherwise // passed a sendto context when we have a path established otherwise
// nullptr if the path was not made before the timeout // nullptr if the path was not made before the timeout
typedef std::function< void(Address, OutboundContext*) > PathEnsureHook; using PathEnsureHook = std::function< void(Address, OutboundContext*) >;
/// return false if we have already called this function before for this /// return false if we have already called this function before for this
/// address /// address

@ -9,7 +9,7 @@ namespace llarp
{ {
namespace service namespace service
{ {
typedef llarp::AlignedBuffer< 16 > ConvoTag; using ConvoTag = llarp::AlignedBuffer< 16 >;
struct ProtocolMessage; struct ProtocolMessage;
struct IDataHandler struct IDataHandler

@ -17,7 +17,7 @@ namespace llarp
{ {
constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2; constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2;
typedef uint64_t ProtocolType; using ProtocolType = uint64_t;
constexpr ProtocolType eProtocolText = 0UL; constexpr ProtocolType eProtocolText = 0UL;
constexpr ProtocolType eProtocolTraffic = 1UL; constexpr ProtocolType eProtocolTraffic = 1UL;

@ -8,7 +8,7 @@ namespace llarp
{ {
/// hidden service address /// hidden service address
typedef llarp::AlignedBuffer< 16 > VanityNonce; using VanityNonce = llarp::AlignedBuffer< 16 >;
} // namespace service } // namespace service
} // namespace llarp } // namespace llarp
#endif #endif

@ -6,7 +6,7 @@
#include <string> #include <string>
namespace llarp namespace llarp
{ {
typedef std::string_view string_view; using string_view = std::string_view;
static std::string static std::string
string_view_string(const string_view& v) string_view_string(const string_view& v)
{ {
@ -17,7 +17,7 @@ namespace llarp
#include <string> #include <string>
namespace llarp namespace llarp
{ {
typedef std::string string_view; using string_view = std::string;
static std::string static std::string
string_view_string(const string_view& v) string_view_string(const string_view& v)
@ -26,4 +26,4 @@ namespace llarp
}; };
} // namespace llarp } // namespace llarp
#endif #endif
#endif #endif

@ -34,9 +34,9 @@ namespace llarp
} }
}; };
typedef std::mutex mtx_t; using mtx_t = std::mutex;
typedef std::unique_lock< std::mutex > lock_t; using lock_t = std::unique_lock< std::mutex >;
typedef std::condition_variable cond_t; using cond_t = std::condition_variable;
struct Mutex struct Mutex
{ {

@ -5,8 +5,11 @@
#include <llarp/threadpool.h> #include <llarp/threadpool.h>
#include <llarp/time.hpp> #include <llarp/time.hpp>
#include <functional>
/** called with userptr, original timeout, left */ /** called with userptr, original timeout, left */
typedef void (*llarp_timer_handler_func)(void *, uint64_t, uint64_t); using llarp_timer_handler_func =
std::function< void(void *, uint64_t, uint64_t) >;
struct llarp_timeout_job struct llarp_timeout_job
{ {

@ -14,10 +14,10 @@ namespace abyss
{ {
namespace http namespace http
{ {
typedef std::string RPC_Method_t; using RPC_Method_t = std::string;
typedef json::Value RPC_Params; using RPC_Params = json::Value;
typedef json::Document RPC_Response; using RPC_Response = json::Document;
typedef std::unordered_multimap< std::string, std::string > Headers_t; using Headers_t = std::unordered_multimap< std::string, std::string >;
struct ConnImpl; struct ConnImpl;
/// jsonrpc response handler for client /// jsonrpc response handler for client
@ -55,7 +55,7 @@ namespace abyss
/// jsonrpc client /// jsonrpc client
struct JSONRPC struct JSONRPC
{ {
typedef std::function< IRPCClientHandler*(ConnImpl*) > HandlerFactory; using HandlerFactory = std::function< IRPCClientHandler*(ConnImpl*) >;
JSONRPC(); JSONRPC();
~JSONRPC(); ~JSONRPC();
@ -115,4 +115,4 @@ namespace abyss
} // namespace http } // namespace http
} // namespace abyss } // namespace abyss
#endif #endif

@ -11,7 +11,7 @@ namespace abyss
{ {
struct RequestHeader struct RequestHeader
{ {
typedef std::unordered_multimap< std::string, std::string > Headers_t; using Headers_t = std::unordered_multimap< std::string, std::string >;
Headers_t Headers; Headers_t Headers;
std::string Method; std::string Method;
std::string Path; std::string Path;
@ -33,4 +33,4 @@ namespace abyss
} // namespace http } // namespace http
} // namespace abyss } // namespace abyss
#endif #endif

@ -10,7 +10,7 @@ namespace abyss
{ {
namespace json namespace json
{ {
typedef std::unordered_map< std::string, std::any > Object; using Object = std::unordered_map< std::string, std::any >;
} }
} // namespace abyss } // namespace abyss
#else #else
@ -19,17 +19,17 @@ namespace abyss
{ {
namespace json namespace json
{ {
typedef rapidjson::Document Document; using Document = rapidjson::Document;
typedef rapidjson::Value Value; using Value = rapidjson::Value;
} // namespace json } // namespace json
} // namespace abyss } // namespace abyss
#endif #endif
namespace abyss namespace abyss
{ {
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
typedef std::string_view string_view; using string_view = std::string_view;
#else #else
typedef std::string string_view; using string_view = std::string;
#endif #endif
namespace json namespace json
{ {

@ -19,9 +19,9 @@ namespace abyss
struct IRPCHandler struct IRPCHandler
{ {
typedef std::string Method_t; using Method_t = std::string;
typedef json::Value Params; using Params = json::Value;
typedef json::Document Response; using Response = json::Document;
IRPCHandler(ConnImpl* impl); IRPCHandler(ConnImpl* impl);

@ -9,7 +9,7 @@ namespace llarp
{ {
struct Config struct Config
{ {
typedef std::list< std::pair< std::string, std::string > > section_t; using section_t = std::list< std::pair< std::string, std::string > >;
section_t router; section_t router;
section_t network; section_t network;

@ -83,13 +83,13 @@ namespace llarp
}; };
}; };
typedef llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime, using LossyWriteQueue_t =
WriteBuffer::PutTime, WriteBuffer::Compare, llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime,
llarp::util::NullMutex, WriteBuffer::PutTime, WriteBuffer::Compare,
llarp::util::NullLock, 5, 100, 128 > llarp::util::NullMutex, llarp::util::NullLock,
LossyWriteQueue_t; 5, 100, 128 >;
typedef std::deque< WriteBuffer > LosslessWriteQueue_t; using LosslessWriteQueue_t = std::deque< WriteBuffer >;
// on windows, tcp/udp event loops are socket fds // on windows, tcp/udp event loops are socket fds
// and TUN device is a plain old fd // and TUN device is a plain old fd
@ -319,13 +319,13 @@ namespace llarp
}; };
}; };
typedef llarp::util::CoDelQueue< using LossyWriteQueue_t =
WriteBuffer, WriteBuffer::GetTime, WriteBuffer::PutTime, llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime,
WriteBuffer::Compare, WriteBuffer::GetNow, llarp::util::NullMutex, WriteBuffer::PutTime, WriteBuffer::Compare,
llarp::util::NullLock, 5, 100, 1024 > WriteBuffer::GetNow, llarp::util::NullMutex,
LossyWriteQueue_t; llarp::util::NullLock, 5, 100, 1024 >;
typedef std::deque< WriteBuffer > LosslessWriteQueue_t; using LosslessWriteQueue_t = std::deque< WriteBuffer >;
int fd; int fd;
int flags = 0; int flags = 0;

@ -22,8 +22,8 @@ namespace llarp
{ {
namespace util namespace util
{ {
typedef std::function< bool(const fs::path &) > PathVisitor; using PathVisitor = std::function< bool(const fs::path &) >;
typedef std::function< void(const fs::path &, PathVisitor) > PathIter; using PathIter = std::function< void(const fs::path &, PathVisitor) >;
static PathIter IterDir = [](const fs::path &path, PathVisitor visit) { static PathIter IterDir = [](const fs::path &path, PathVisitor visit) {
DIR *d = opendir(path.string().c_str()); DIR *d = opendir(path.string().c_str());

@ -48,9 +48,9 @@ namespace ini
{ {
} }
typedef std::list< std::pair< std::string, std::string > > value_map_t; using value_map_t = std::list< std::pair< std::string, std::string > >;
typedef std::map< std::string, Level > section_map_t; using section_map_t = std::map< std::string, Level >;
typedef std::list< section_map_t::const_iterator > sections_t; using sections_t = std::list< section_map_t::const_iterator >;
value_map_t values; value_map_t values;
section_map_t sections; section_map_t sections;
sections_t ordered_sections; sections_t ordered_sections;

@ -137,7 +137,7 @@ struct llarp_router
llarp::Profiling routerProfiling; llarp::Profiling routerProfiling;
std::string routerProfilesFile = "profiles.dat"; std::string routerProfilesFile = "profiles.dat";
typedef std::queue< std::vector< byte_t > > MessageQueue; using MessageQueue = std::queue< std::vector< byte_t > >;
/// outbound message queue /// outbound message queue
std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash > std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash >

@ -10,8 +10,8 @@ namespace llarp
{ {
namespace thread namespace thread
{ {
typedef util::Mutex mtx_t; using mtx_t = util::Mutex;
typedef util::Lock lock_t; using lock_t = util::Lock;
using Pool = ThreadPool; using Pool = ThreadPool;

Loading…
Cancel
Save