Update from `typedef` to `using` in .hpp files

pull/82/head
Michael 6 years ago
parent 067f6c7b26
commit e4c5f4f77a
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

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

@ -14,7 +14,7 @@ namespace llarp
template < typename Val_t >
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)){};

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

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

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

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

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

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

@ -14,7 +14,7 @@ namespace llarp
{
struct ILinkSession;
typedef std::queue< ILinkMessage* > SendQueue;
using SendQueue = std::queue< ILinkMessage* >;
/// parsed link layer message
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 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
struct llarp_async_verify_rc
@ -118,7 +119,8 @@ llarp_nodedb_async_verify(struct llarp_async_verify_rc *job);
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
{

@ -280,19 +280,19 @@ namespace llarp
/// A path we made
struct Path : public IHopHandler, public llarp::routing::IMessageHandler
{
typedef std::function< void(Path*) > BuildResultHookFunc;
typedef std::function< bool(Path*, llarp_time_t) > CheckForDeadFunc;
typedef std::function< bool(Path*, const PathID_t&, uint64_t) >
DropHandlerFunc;
typedef std::vector< PathHopConfig > HopList;
typedef std::function< bool(Path*, const service::ProtocolFrame*) >
DataHandlerFunc;
typedef std::function< bool(Path*) > ExitUpdatedFunc;
typedef std::function< bool(Path*) > ExitClosedFunc;
typedef std::function< bool(Path*, llarp_buffer_t) >
ExitTrafficHandlerFunc;
using BuildResultHookFunc = std::function< void(Path*) >;
using CheckForDeadFunc = std::function< bool(Path*, llarp_time_t) >;
using DropHandlerFunc =
std::function< bool(Path*, const PathID_t&, uint64_t) >;
using HopList = std::vector< PathHopConfig >;
using DataHandlerFunc =
std::function< bool(Path*, const service::ProtocolFrame*) >;
using ExitUpdatedFunc = std::function< bool(Path*) >;
using ExitClosedFunc = std::function< bool(Path*) >;
using ExitTrafficHandlerFunc =
std::function< bool(Path*, llarp_buffer_t) >;
/// (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;
@ -612,15 +612,15 @@ namespace llarp
void
RemovePathSet(PathSet* set);
typedef std::multimap< PathID_t, std::shared_ptr< TransitHop > >
TransitHopsMap_t;
using 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
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*
Worker();

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

@ -176,7 +176,7 @@ namespace llarp
size_t m_NumPaths;
private:
typedef std::pair< RouterID, PathID_t > PathInfo_t;
using PathInfo_t = std::pair< RouterID, PathID_t >;
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;
};

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

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

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

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

@ -193,7 +193,7 @@ namespace llarp
bool
CheckPathIsDead(path::Path* p, llarp_time_t latency);
typedef std::queue< PendingBuffer > PendingBufferQueue;
using PendingBufferQueue = std::queue< PendingBuffer >;
struct SendContext
{
@ -331,7 +331,7 @@ namespace llarp
// passed a sendto context when we have a path established otherwise
// 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
/// address

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

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

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

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

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

@ -5,8 +5,11 @@
#include <llarp/threadpool.h>
#include <llarp/time.hpp>
#include <functional>
/** 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
{

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

@ -11,7 +11,7 @@ namespace abyss
{
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;
std::string Method;
std::string Path;
@ -33,4 +33,4 @@ namespace abyss
} // namespace http
} // namespace abyss
#endif
#endif

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

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

@ -9,7 +9,7 @@ namespace llarp
{
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 network;

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

@ -22,8 +22,8 @@ namespace llarp
{
namespace util
{
typedef std::function< bool(const fs::path &) > PathVisitor;
typedef std::function< void(const fs::path &, PathVisitor) > PathIter;
using PathVisitor = std::function< bool(const fs::path &) >;
using PathIter = std::function< void(const fs::path &, PathVisitor) >;
static PathIter IterDir = [](const fs::path &path, PathVisitor visit) {
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;
typedef std::map< std::string, Level > section_map_t;
typedef std::list< section_map_t::const_iterator > sections_t;
using value_map_t = std::list< std::pair< std::string, std::string > >;
using section_map_t = std::map< std::string, Level >;
using sections_t = std::list< section_map_t::const_iterator >;
value_map_t values;
section_map_t sections;
sections_t ordered_sections;

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

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

Loading…
Cancel
Save