diff --git a/src/uvw/dns.cpp b/src/uvw/dns.cpp index 1f22caf6..2a6b5536 100644 --- a/src/uvw/dns.cpp +++ b/src/uvw/dns.cpp @@ -49,32 +49,32 @@ UVW_INLINE auto GetAddrInfoReq::nodeAddrInfoSync(const char *node, const char *s } -UVW_INLINE void GetAddrInfoReq::nodeAddrInfo(std::string node, addrinfo *hints) { +UVW_INLINE void GetAddrInfoReq::nodeAddrInfo(const std::string &node, addrinfo *hints) { nodeAddrInfo(node.data(), nullptr, hints); } -UVW_INLINE std::pair> GetAddrInfoReq::nodeAddrInfoSync(std::string node, addrinfo *hints) { +UVW_INLINE std::pair> GetAddrInfoReq::nodeAddrInfoSync(const std::string &node, addrinfo *hints) { return nodeAddrInfoSync(node.data(), nullptr, hints); } -UVW_INLINE void GetAddrInfoReq::serviceAddrInfo(std::string service, addrinfo *hints) { +UVW_INLINE void GetAddrInfoReq::serviceAddrInfo(const std::string &service, addrinfo *hints) { nodeAddrInfo(nullptr, service.data(), hints); } -UVW_INLINE std::pair> GetAddrInfoReq::serviceAddrInfoSync(std::string service, addrinfo *hints) { +UVW_INLINE std::pair> GetAddrInfoReq::serviceAddrInfoSync(const std::string &service, addrinfo *hints) { return nodeAddrInfoSync(nullptr, service.data(), hints); } -UVW_INLINE void GetAddrInfoReq::addrInfo(std::string node, std::string service, addrinfo *hints) { +UVW_INLINE void GetAddrInfoReq::addrInfo(const std::string &node, const std::string &service, addrinfo *hints) { nodeAddrInfo(node.data(), service.data(), hints); } -UVW_INLINE std::pair> GetAddrInfoReq::addrInfoSync(std::string node, std::string service, addrinfo *hints) { +UVW_INLINE std::pair> GetAddrInfoReq::addrInfoSync(const std::string &node, const std::string &service, addrinfo *hints) { return nodeAddrInfoSync(node.data(), service.data(), hints); } @@ -96,7 +96,7 @@ UVW_INLINE void GetNameInfoReq::nameInfo(const sockaddr &addr, int flags) { template -UVW_INLINE void GetNameInfoReq::nameInfo(std::string ip, unsigned int port, int flags) { +UVW_INLINE void GetNameInfoReq::nameInfo(const std::string &ip, unsigned int port, int flags) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); nameInfo(reinterpret_cast(addr), flags); @@ -115,7 +115,7 @@ UVW_INLINE std::pair> GetNameInfoReq template -UVW_INLINE std::pair> GetNameInfoReq::nameInfoSync(std::string ip, unsigned int port, int flags) { +UVW_INLINE std::pair> GetNameInfoReq::nameInfoSync(const std::string &ip, unsigned int port, int flags) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); return nameInfoSync(reinterpret_cast(addr), flags); @@ -130,17 +130,18 @@ UVW_INLINE std::pair> GetNameInfoReq // explicit instantiations #ifdef UVW_AS_LIB -template void GetNameInfoReq::nameInfo(std::string ip, unsigned int port, int flags); -template void GetNameInfoReq::nameInfo(std::string ip, unsigned int port, int flags); +template void GetNameInfoReq::nameInfo(const std::string &, unsigned int, int); +template void GetNameInfoReq::nameInfo(const std::string &, unsigned int, int); -template void GetNameInfoReq::nameInfo(Addr addr, int flags); -template void GetNameInfoReq::nameInfo(Addr addr, int flags); +template void GetNameInfoReq::nameInfo(Addr, int); +template void GetNameInfoReq::nameInfo(Addr, int); -template std::pair> GetNameInfoReq::nameInfoSync(std::string ip, unsigned int port, int flags); -template std::pair> GetNameInfoReq::nameInfoSync(std::string ip, unsigned int port, int flags); +template std::pair> GetNameInfoReq::nameInfoSync(const std::string &, unsigned int, int); +template std::pair> GetNameInfoReq::nameInfoSync(const std::string &, unsigned int, int); -template std::pair> GetNameInfoReq::nameInfoSync(Addr addr, int flags); -template std::pair> GetNameInfoReq::nameInfoSync(Addr addr, int flags); +template std::pair> GetNameInfoReq::nameInfoSync(Addr, int); +template std::pair> GetNameInfoReq::nameInfoSync(Addr, int); #endif // UVW_AS_LIB + } diff --git a/src/uvw/dns.h b/src/uvw/dns.h index 1800f898..ef5f05fa 100644 --- a/src/uvw/dns.h +++ b/src/uvw/dns.h @@ -84,7 +84,7 @@ public: * @param hints Optional `addrinfo` data structure with additional address * type constraints. */ - void nodeAddrInfo(std::string node, addrinfo *hints = nullptr); + void nodeAddrInfo(const std::string &node, addrinfo *hints = nullptr); /** * @brief Sync [getaddrinfo](http://linux.die.net/man/3/getaddrinfo). @@ -97,7 +97,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * A `std::unique_ptr` containing the data requested. */ - std::pair> nodeAddrInfoSync(std::string node, addrinfo *hints = nullptr); + std::pair> nodeAddrInfoSync(const std::string &node, addrinfo *hints = nullptr); /** * @brief Async [getaddrinfo](http://linux.die.net/man/3/getaddrinfo). @@ -105,7 +105,7 @@ public: * @param hints Optional `addrinfo` data structure with additional address * type constraints. */ - void serviceAddrInfo(std::string service, addrinfo *hints = nullptr); + void serviceAddrInfo(const std::string &service, addrinfo *hints = nullptr); /** * @brief Sync [getaddrinfo](http://linux.die.net/man/3/getaddrinfo). @@ -118,7 +118,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * A `std::unique_ptr` containing the data requested. */ - std::pair> serviceAddrInfoSync(std::string service, addrinfo *hints = nullptr); + std::pair> serviceAddrInfoSync(const std::string &service, addrinfo *hints = nullptr); /** * @brief Async [getaddrinfo](http://linux.die.net/man/3/getaddrinfo). @@ -127,7 +127,7 @@ public: * @param hints Optional `addrinfo` data structure with additional address * type constraints. */ - void addrInfo(std::string node, std::string service, addrinfo *hints = nullptr); + void addrInfo(const std::string &node, const std::string &service, addrinfo *hints = nullptr); /** * @brief Sync [getaddrinfo](http://linux.die.net/man/3/getaddrinfo). @@ -141,7 +141,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * A `std::unique_ptr` containing the data requested. */ - std::pair> addrInfoSync(std::string node, std::string service, addrinfo *hints = nullptr); + std::pair> addrInfoSync(const std::string &node, const std::string &service, addrinfo *hints = nullptr); }; @@ -173,7 +173,7 @@ public: * @param flags Optional flags that modify the behavior of `getnameinfo`. */ template - void nameInfo(std::string ip, unsigned int port, int flags = 0); + void nameInfo(const std::string &ip, unsigned int port, int flags = 0); /** * @brief Async [getnameinfo](http://linux.die.net/man/3/getnameinfo). @@ -211,7 +211,7 @@ public: * * A `const char *` containing a valid service name. */ template - std::pair> nameInfoSync(std::string ip, unsigned int port, int flags = 0); + std::pair> nameInfoSync(const std::string &ip, unsigned int port, int flags = 0); /** * @brief Sync [getnameinfo](http://linux.die.net/man/3/getnameinfo). @@ -238,19 +238,20 @@ public: // (extern) explicit instantiations #ifdef UVW_AS_LIB -extern template void GetNameInfoReq::nameInfo(std::string ip, unsigned int port, int flags); -extern template void GetNameInfoReq::nameInfo(std::string ip, unsigned int port, int flags); +extern template void GetNameInfoReq::nameInfo(const std::string &, unsigned int, int); +extern template void GetNameInfoReq::nameInfo(const std::string &, unsigned int, int); -extern template void GetNameInfoReq::nameInfo(Addr addr, int flags); -extern template void GetNameInfoReq::nameInfo(Addr addr, int flags); +extern template void GetNameInfoReq::nameInfo(Addr, int); +extern template void GetNameInfoReq::nameInfo(Addr, int); -extern template std::pair> GetNameInfoReq::nameInfoSync(std::string ip, unsigned int port, int flags); -extern template std::pair> GetNameInfoReq::nameInfoSync(std::string ip, unsigned int port, int flags); +extern template std::pair> GetNameInfoReq::nameInfoSync(const std::string &, unsigned int, int); +extern template std::pair> GetNameInfoReq::nameInfoSync(const std::string &, unsigned int, int); -extern template std::pair> GetNameInfoReq::nameInfoSync(Addr addr, int flags); -extern template std::pair> GetNameInfoReq::nameInfoSync(Addr addr, int flags); +extern template std::pair> GetNameInfoReq::nameInfoSync(Addr, int); +extern template std::pair> GetNameInfoReq::nameInfoSync(Addr, int); #endif // UVW_AS_LIB + /** * Internal details not to be documented. * @endcond @@ -264,4 +265,5 @@ extern template std::pair> GetNameIn #include "dns.cpp" #endif + #endif // UVW_DNS_INCLUDE_H diff --git a/src/uvw/fs.cpp b/src/uvw/fs.cpp index 5eae12b6..4a4c5ac8 100644 --- a/src/uvw/fs.cpp +++ b/src/uvw/fs.cpp @@ -66,12 +66,12 @@ UVW_INLINE bool FileReq::closeSync() { } -UVW_INLINE void FileReq::open(std::string path, Flags flags, int mode) { +UVW_INLINE void FileReq::open(const std::string &path, Flags flags, int mode) { cleanupAndInvoke(&uv_fs_open, parent(), get(), path.data(), flags, mode, &fsOpenCallback); } -UVW_INLINE bool FileReq::openSync(std::string path, Flags flags, int mode) { +UVW_INLINE bool FileReq::openSync(const std::string &path, Flags flags, int mode) { auto req = get(); cleanupAndInvokeSync(&uv_fs_open, parent(), req, path.data(), flags, mode); @@ -256,48 +256,48 @@ UVW_INLINE FsReq::~FsReq() noexcept { } -UVW_INLINE void FsReq::unlink(std::string path) { +UVW_INLINE void FsReq::unlink(const std::string &path) { cleanupAndInvoke(&uv_fs_unlink, parent(), get(), path.data(), &fsGenericCallback); } -UVW_INLINE bool FsReq::unlinkSync(std::string path) { +UVW_INLINE bool FsReq::unlinkSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_unlink, parent(), req, path.data()); return !(req->result < 0); } -UVW_INLINE void FsReq::mkdir(std::string path, int mode) { +UVW_INLINE void FsReq::mkdir(const std::string &path, int mode) { cleanupAndInvoke(&uv_fs_mkdir, parent(), get(), path.data(), mode, &fsGenericCallback); } -UVW_INLINE bool FsReq::mkdirSync(std::string path, int mode) { +UVW_INLINE bool FsReq::mkdirSync(const std::string &path, int mode) { auto req = get(); cleanupAndInvokeSync(&uv_fs_mkdir, parent(), req, path.data(), mode); return !(req->result < 0); } -UVW_INLINE void FsReq::mkdtemp(std::string tpl) { +UVW_INLINE void FsReq::mkdtemp(const std::string &tpl) { cleanupAndInvoke(&uv_fs_mkdtemp, parent(), get(), tpl.data(), &fsGenericCallback); } -UVW_INLINE std::pair FsReq::mkdtempSync(std::string tpl) { +UVW_INLINE std::pair FsReq::mkdtempSync(const std::string &tpl) { auto req = get(); cleanupAndInvokeSync(&uv_fs_mkdtemp, parent(), req, tpl.data()); return std::make_pair(!(req->result < 0), req->path); } -UVW_INLINE void FsReq::mkstemp(std::string tpl) { +UVW_INLINE void FsReq::mkstemp(const std::string &tpl) { cleanupAndInvoke(&uv_fs_mkstemp, parent(), get(), tpl.data(), &fsResultCallback); } -UVW_INLINE std::pair> FsReq::mkstempSync(std::string tpl) { +UVW_INLINE std::pair> FsReq::mkstempSync(const std::string &tpl) { std::pair> ret{false, {}}; auto req = get(); cleanupAndInvokeSync(&uv_fs_mkdtemp, parent(), req, tpl.data()); @@ -312,36 +312,36 @@ UVW_INLINE std::pair> FsReq::mkstempSy } -UVW_INLINE void FsReq::lutime(std::string path, Time atime, Time mtime) { +UVW_INLINE void FsReq::lutime(const std::string &path, Time atime, Time mtime) { cleanupAndInvoke(&uv_fs_lutime, parent(), get(), path.data(), atime.count(), mtime.count(), &fsGenericCallback); } -UVW_INLINE bool FsReq::lutimeSync(std::string path, Time atime, Time mtime) { +UVW_INLINE bool FsReq::lutimeSync(const std::string &path, Time atime, Time mtime) { auto req = get(); cleanupAndInvokeSync(&uv_fs_lutime, parent(), req, path.data(), atime.count(), mtime.count()); return !(req->result < 0); } -UVW_INLINE void FsReq::rmdir(std::string path) { +UVW_INLINE void FsReq::rmdir(const std::string &path) { cleanupAndInvoke(&uv_fs_rmdir, parent(), get(), path.data(), &fsGenericCallback); } -UVW_INLINE bool FsReq::rmdirSync(std::string path) { +UVW_INLINE bool FsReq::rmdirSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_rmdir, parent(), req, path.data()); return !(req->result < 0); } -UVW_INLINE void FsReq::scandir(std::string path, int flags) { +UVW_INLINE void FsReq::scandir(const std::string &path, int flags) { cleanupAndInvoke(&uv_fs_scandir, parent(), get(), path.data(), flags, &fsResultCallback); } -UVW_INLINE std::pair FsReq::scandirSync(std::string path, int flags) { +UVW_INLINE std::pair FsReq::scandirSync(const std::string &path, int flags) { auto req = get(); cleanupAndInvokeSync(&uv_fs_scandir, parent(), req, path.data(), flags); bool err = req->result < 0; @@ -366,132 +366,132 @@ UVW_INLINE std::pair> FsReq::sca } -UVW_INLINE void FsReq::stat(std::string path) { +UVW_INLINE void FsReq::stat(const std::string &path) { cleanupAndInvoke(&uv_fs_stat, parent(), get(), path.data(), &fsStatCallback); } -UVW_INLINE std::pair FsReq::statSync(std::string path) { +UVW_INLINE std::pair FsReq::statSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_stat, parent(), req, path.data()); return std::make_pair(!(req->result < 0), req->statbuf); } -UVW_INLINE void FsReq::lstat(std::string path) { +UVW_INLINE void FsReq::lstat(const std::string &path) { cleanupAndInvoke(&uv_fs_lstat, parent(), get(), path.data(), &fsStatCallback); } -UVW_INLINE std::pair FsReq::lstatSync(std::string path) { +UVW_INLINE std::pair FsReq::lstatSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_lstat, parent(), req, path.data()); return std::make_pair(!(req->result < 0), req->statbuf); } -UVW_INLINE void FsReq::statfs(std::string path) { +UVW_INLINE void FsReq::statfs(const std::string &path) { cleanupAndInvoke(&uv_fs_statfs, parent(), get(), path.data(), &fsStatfsCallback); } -UVW_INLINE std::pair FsReq::statfsSync(std::string path) { +UVW_INLINE std::pair FsReq::statfsSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_statfs, parent(), req, path.data()); return std::make_pair(!(req->result < 0), *static_cast(req->ptr)); } -UVW_INLINE void FsReq::rename(std::string old, std::string path) { +UVW_INLINE void FsReq::rename(const std::string &old, const std::string &path) { cleanupAndInvoke(&uv_fs_rename, parent(), get(), old.data(), path.data(), &fsGenericCallback); } -UVW_INLINE bool FsReq::renameSync(std::string old, std::string path) { +UVW_INLINE bool FsReq::renameSync(const std::string &old, const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_rename, parent(), req, old.data(), path.data()); return !(req->result < 0); } -UVW_INLINE void FsReq::copyfile(std::string old, std::string path, Flags flags) { +UVW_INLINE void FsReq::copyfile(const std::string &old, const std::string &path, Flags flags) { cleanupAndInvoke(&uv_fs_copyfile, parent(), get(), old.data(), path.data(), flags, &fsGenericCallback); } -UVW_INLINE bool FsReq::copyfileSync(std::string old, std::string path, Flags flags) { +UVW_INLINE bool FsReq::copyfileSync(const std::string &old, const std::string &path, Flags flags) { auto req = get(); cleanupAndInvokeSync(&uv_fs_copyfile, parent(), get(), old.data(), path.data(), flags); return !(req->result < 0); } -UVW_INLINE void FsReq::access(std::string path, int mode) { +UVW_INLINE void FsReq::access(const std::string &path, int mode) { cleanupAndInvoke(&uv_fs_access, parent(), get(), path.data(), mode, &fsGenericCallback); } -UVW_INLINE bool FsReq::accessSync(std::string path, int mode) { +UVW_INLINE bool FsReq::accessSync(const std::string &path, int mode) { auto req = get(); cleanupAndInvokeSync(&uv_fs_access, parent(), req, path.data(), mode); return !(req->result < 0); } -UVW_INLINE void FsReq::chmod(std::string path, int mode) { +UVW_INLINE void FsReq::chmod(const std::string &path, int mode) { cleanupAndInvoke(&uv_fs_chmod, parent(), get(), path.data(), mode, &fsGenericCallback); } -UVW_INLINE bool FsReq::chmodSync(std::string path, int mode) { +UVW_INLINE bool FsReq::chmodSync(const std::string &path, int mode) { auto req = get(); cleanupAndInvokeSync(&uv_fs_chmod, parent(), req, path.data(), mode); return !(req->result < 0); } -UVW_INLINE void FsReq::utime(std::string path, FsRequest::Time atime, FsRequest::Time mtime) { +UVW_INLINE void FsReq::utime(const std::string &path, FsRequest::Time atime, FsRequest::Time mtime) { cleanupAndInvoke(&uv_fs_utime, parent(), get(), path.data(), atime.count(), mtime.count(), &fsGenericCallback); } -UVW_INLINE bool FsReq::utimeSync(std::string path, FsRequest::Time atime, FsRequest::Time mtime) { +UVW_INLINE bool FsReq::utimeSync(const std::string &path, FsRequest::Time atime, FsRequest::Time mtime) { auto req = get(); cleanupAndInvokeSync(&uv_fs_utime, parent(), req, path.data(), atime.count(), mtime.count()); return !(req->result < 0); } -UVW_INLINE void FsReq::link(std::string old, std::string path) { +UVW_INLINE void FsReq::link(const std::string &old, const std::string &path) { cleanupAndInvoke(&uv_fs_link, parent(), get(), old.data(), path.data(), &fsGenericCallback); } -UVW_INLINE bool FsReq::linkSync(std::string old, std::string path) { +UVW_INLINE bool FsReq::linkSync(const std::string &old, const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_link, parent(), req, old.data(), path.data()); return !(req->result < 0); } -UVW_INLINE void FsReq::symlink(std::string old, std::string path, Flags flags) { +UVW_INLINE void FsReq::symlink(const std::string &old, const std::string &path, Flags flags) { cleanupAndInvoke(&uv_fs_symlink, parent(), get(), old.data(), path.data(), flags, &fsGenericCallback); } -UVW_INLINE bool FsReq::symlinkSync(std::string old, std::string path, Flags flags) { +UVW_INLINE bool FsReq::symlinkSync(const std::string &old, const std::string &path, Flags flags) { auto req = get(); cleanupAndInvokeSync(&uv_fs_symlink, parent(), req, old.data(), path.data(), flags); return !(req->result < 0); } -UVW_INLINE void FsReq::readlink(std::string path) { +UVW_INLINE void FsReq::readlink(const std::string &path) { cleanupAndInvoke(&uv_fs_readlink, parent(), get(), path.data(), &fsReadlinkCallback); } -UVW_INLINE std::pair> FsReq::readlinkSync(std::string path) { +UVW_INLINE std::pair> FsReq::readlinkSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_readlink, parent(), req, path.data()); bool err = req->result < 0; @@ -499,48 +499,48 @@ UVW_INLINE std::pair> FsReq::readlink } -UVW_INLINE void FsReq::realpath(std::string path) { +UVW_INLINE void FsReq::realpath(const std::string &path) { cleanupAndInvoke(&uv_fs_realpath, parent(), get(), path.data(), &fsGenericCallback); } -UVW_INLINE std::pair FsReq::realpathSync(std::string path) { +UVW_INLINE std::pair FsReq::realpathSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_realpath, parent(), req, path.data()); return std::make_pair(!(req->result < 0), req->path); } -UVW_INLINE void FsReq::chown(std::string path, Uid uid, Gid gid) { +UVW_INLINE void FsReq::chown(const std::string &path, Uid uid, Gid gid) { cleanupAndInvoke(&uv_fs_chown, parent(), get(), path.data(), uid, gid, &fsGenericCallback); } -UVW_INLINE bool FsReq::chownSync(std::string path, Uid uid, Gid gid) { +UVW_INLINE bool FsReq::chownSync(const std::string &path, Uid uid, Gid gid) { auto req = get(); cleanupAndInvokeSync(&uv_fs_chown, parent(), req, path.data(), uid, gid); return !(req->result < 0); } -UVW_INLINE void FsReq::lchown(std::string path, Uid uid, Gid gid) { +UVW_INLINE void FsReq::lchown(const std::string &path, Uid uid, Gid gid) { cleanupAndInvoke(&uv_fs_lchown, parent(), get(), path.data(), uid, gid, &fsGenericCallback); } -UVW_INLINE bool FsReq::lchownSync(std::string path, Uid uid, Gid gid) { +UVW_INLINE bool FsReq::lchownSync(const std::string &path, Uid uid, Gid gid) { auto req = get(); cleanupAndInvokeSync(&uv_fs_lchown, parent(), req, path.data(), uid, gid); return !(req->result < 0); } -UVW_INLINE void FsReq::opendir(std::string path) { +UVW_INLINE void FsReq::opendir(const std::string &path) { cleanupAndInvoke(&uv_fs_opendir, parent(), get(), path.data(), &fsGenericCallback); } -UVW_INLINE bool FsReq::opendirSync(std::string path) { +UVW_INLINE bool FsReq::opendirSync(const std::string &path) { auto req = get(); cleanupAndInvokeSync(&uv_fs_opendir, parent(), req, path.data()); return !(req->result < 0); diff --git a/src/uvw/fs.h b/src/uvw/fs.h index c4af1d4a..799b5626 100644 --- a/src/uvw/fs.h +++ b/src/uvw/fs.h @@ -500,7 +500,7 @@ public: * @param flags Flags made out of underlying constants. * @param mode Mode, as described in the official documentation. */ - void open(std::string path, Flags flags, int mode); + void open(const std::string &path, Flags flags, int mode); /** * @brief Sync [open](http://linux.die.net/man/2/open). @@ -539,7 +539,7 @@ public: * @param mode Mode, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool openSync(std::string path, Flags flags, int mode); + bool openSync(const std::string &path, Flags flags, int mode); /** * @brief Async [read](http://linux.die.net/man/2/preadv). @@ -804,14 +804,14 @@ public: * * @param path Path, as described in the official documentation. */ - void unlink(std::string path); + void unlink(const std::string &path); /** * @brief Sync [unlink](http://linux.die.net/man/2/unlink). * @param path Path, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool unlinkSync(std::string path); + bool unlinkSync(const std::string &path); /** * @brief Async [mkdir](http://linux.die.net/man/2/mkdir). @@ -822,7 +822,7 @@ public: * @param path Path, as described in the official documentation. * @param mode Mode, as described in the official documentation. */ - void mkdir(std::string path, int mode); + void mkdir(const std::string &path, int mode); /** * @brief Sync [mkdir](http://linux.die.net/man/2/mkdir). @@ -830,7 +830,7 @@ public: * @param mode Mode, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool mkdirSync(std::string path, int mode); + bool mkdirSync(const std::string &path, int mode); /** * @brief Async [mktemp](http://linux.die.net/man/3/mkdtemp). @@ -840,7 +840,7 @@ public: * * @param tpl Template, as described in the official documentation. */ - void mkdtemp(std::string tpl); + void mkdtemp(const std::string &tpl); /** * @brief Sync [mktemp](http://linux.die.net/man/3/mkdtemp). @@ -851,7 +851,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * The actual path of the newly created directory. */ - std::pair mkdtempSync(std::string tpl); + std::pair mkdtempSync(const std::string &tpl); /** * @brief Async [mkstemp](https://linux.die.net/man/3/mkstemp). @@ -861,7 +861,7 @@ public: * * @param tpl Template, as described in the official documentation. */ - void mkstemp(std::string tpl); + void mkstemp(const std::string &tpl); /** * @brief Sync [mkstemp](https://linux.die.net/man/3/mkstemp). @@ -883,7 +883,7 @@ public: * false otherwise. * * The second parameter is a composed value (see above). */ - std::pair> mkstempSync(std::string tpl); + std::pair> mkstempSync(const std::string &tpl); /** * @brief Async [lutime](http://linux.die.net/man/3/lutimes). @@ -897,7 +897,7 @@ public: * @param mtime `std::chrono::duration`, having the same meaning as * described in the official documentation. */ - void lutime(std::string path, Time atime, Time mtime); + void lutime(const std::string &path, Time atime, Time mtime); /** * @brief Sync [lutime](http://linux.die.net/man/3/lutimes). @@ -908,7 +908,7 @@ public: * described in the official documentation. * @return True in case of success, false otherwise. */ - bool lutimeSync(std::string path, Time atime, Time mtime); + bool lutimeSync(const std::string &path, Time atime, Time mtime); /** * @brief Async [rmdir](http://linux.die.net/man/2/rmdir). @@ -918,14 +918,14 @@ public: * * @param path Path, as described in the official documentation. */ - void rmdir(std::string path); + void rmdir(const std::string &path); /** * @brief Sync [rmdir](http://linux.die.net/man/2/rmdir). * @param path Path, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool rmdirSync(std::string path); + bool rmdirSync(const std::string &path); /** * @brief Async [scandir](http://linux.die.net/man/3/scandir). @@ -936,7 +936,7 @@ public: * @param path Path, as described in the official documentation. * @param flags Flags, as described in the official documentation. */ - void scandir(std::string path, int flags); + void scandir(const std::string &path, int flags); /** * @brief Sync [scandir](http://linux.die.net/man/3/scandir). @@ -948,7 +948,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * The number of directory entries selected. */ - std::pair scandirSync(std::string path, int flags); + std::pair scandirSync(const std::string &path, int flags); /** * @brief Gets entries populated with the next directory entry data. @@ -989,7 +989,7 @@ public: * * @param path Path, as described in the official documentation. */ - void stat(std::string path); + void stat(const std::string &path); /** * @brief Sync [stat](http://linux.die.net/man/2/stat). @@ -1000,7 +1000,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * An initialized instance of Stat. */ - std::pair statSync(std::string path); + std::pair statSync(const std::string &path); /** * @brief Async [lstat](http://linux.die.net/man/2/lstat). @@ -1010,7 +1010,7 @@ public: * * @param path Path, as described in the official documentation. */ - void lstat(std::string path); + void lstat(const std::string &path); /** * @brief Sync [lstat](http://linux.die.net/man/2/lstat). @@ -1021,7 +1021,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * An initialized instance of Stat. */ - std::pair lstatSync(std::string path); + std::pair lstatSync(const std::string &path); /** * @brief Async [statfs](http://linux.die.net/man/2/statfs). @@ -1034,7 +1034,7 @@ public: * * @param path Path, as described in the official documentation. */ - void statfs(std::string path); + void statfs(const std::string &path); /** * @brief Sync [statfs](http://linux.die.net/man/2/statfs). @@ -1048,7 +1048,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * An initialized instance of Statfs. */ - std::pair statfsSync(std::string path); + std::pair statfsSync(const std::string &path); /** * @brief Async [rename](http://linux.die.net/man/2/rename). @@ -1059,7 +1059,7 @@ public: * @param old Old path, as described in the official documentation. * @param path New path, as described in the official documentation. */ - void rename(std::string old, std::string path); + void rename(const std::string &old, const std::string &path); /** * @brief Sync [rename](http://linux.die.net/man/2/rename). @@ -1067,7 +1067,7 @@ public: * @param path New path, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool renameSync(std::string old, std::string path); + bool renameSync(const std::string &old, const std::string &path); /** * @brief Copies a file asynchronously from a path to a new one. @@ -1098,7 +1098,7 @@ public: * @param path New path, as described in the official documentation. * @param flags Optional additional flags. */ - void copyfile(std::string old, std::string path, Flags flags = Flags{}); + void copyfile(const std::string &old, const std::string &path, Flags flags = Flags{}); /** * @brief Copies a file synchronously from a path to a new one. @@ -1119,7 +1119,7 @@ public: * @param flags Optional additional flags. * @return True in case of success, false otherwise. */ - bool copyfileSync(std::string old, std::string path, Flags flags = Flags{}); + bool copyfileSync(const std::string &old, const std::string &path, Flags flags = Flags{}); /** * @brief Async [access](http://linux.die.net/man/2/access). @@ -1130,7 +1130,7 @@ public: * @param path Path, as described in the official documentation. * @param mode Mode, as described in the official documentation. */ - void access(std::string path, int mode); + void access(const std::string &path, int mode); /** * @brief Sync [access](http://linux.die.net/man/2/access). @@ -1138,7 +1138,7 @@ public: * @param mode Mode, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool accessSync(std::string path, int mode); + bool accessSync(const std::string &path, int mode); /** * @brief Async [chmod](http://linux.die.net/man/2/chmod). @@ -1149,7 +1149,7 @@ public: * @param path Path, as described in the official documentation. * @param mode Mode, as described in the official documentation. */ - void chmod(std::string path, int mode); + void chmod(const std::string &path, int mode); /** * @brief Sync [chmod](http://linux.die.net/man/2/chmod). @@ -1157,7 +1157,7 @@ public: * @param mode Mode, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool chmodSync(std::string path, int mode); + bool chmodSync(const std::string &path, int mode); /** * @brief Async [utime](http://linux.die.net/man/2/utime). @@ -1171,7 +1171,7 @@ public: * @param mtime `std::chrono::duration`, having the same meaning as * described in the official documentation. */ - void utime(std::string path, Time atime, Time mtime); + void utime(const std::string &path, Time atime, Time mtime); /** * @brief Sync [utime](http://linux.die.net/man/2/utime). @@ -1182,7 +1182,7 @@ public: * described in the official documentation. * @return True in case of success, false otherwise. */ - bool utimeSync(std::string path, Time atime, Time mtime); + bool utimeSync(const std::string &path, Time atime, Time mtime); /** * @brief Async [link](http://linux.die.net/man/2/link). @@ -1193,7 +1193,7 @@ public: * @param old Old path, as described in the official documentation. * @param path New path, as described in the official documentation. */ - void link(std::string old, std::string path); + void link(const std::string &old, const std::string &path); /** * @brief Sync [link](http://linux.die.net/man/2/link). @@ -1201,7 +1201,7 @@ public: * @param path New path, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool linkSync(std::string old, std::string path); + bool linkSync(const std::string &old, const std::string &path); /** * @brief Async [symlink](http://linux.die.net/man/2/symlink). @@ -1220,7 +1220,7 @@ public: * @param path New path, as described in the official documentation. * @param flags Optional additional flags. */ - void symlink(std::string old, std::string path, Flags flags = Flags{}); + void symlink(const std::string &old, const std::string &path, Flags flags = Flags{}); /** * @brief Sync [symlink](http://linux.die.net/man/2/symlink). @@ -1237,7 +1237,7 @@ public: * @param flags Flags, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool symlinkSync(std::string old, std::string path, Flags flags = Flags{}); + bool symlinkSync(const std::string &old, const std::string &path, Flags flags = Flags{}); /** * @brief Async [readlink](http://linux.die.net/man/2/readlink). @@ -1247,7 +1247,7 @@ public: * * @param path Path, as described in the official documentation. */ - void readlink(std::string path); + void readlink(const std::string &path); /** * @brief Sync [readlink](http://linux.die.net/man/2/readlink). @@ -1260,7 +1260,7 @@ public: * * A bunch of data read from the given path. * * The amount of data read from the given path. */ - std::pair> readlinkSync(std::string path); + std::pair> readlinkSync(const std::string &path); /** * @brief Async [realpath](http://linux.die.net/man/3/realpath). @@ -1270,7 +1270,7 @@ public: * * @param path Path, as described in the official documentation. */ - void realpath(std::string path); + void realpath(const std::string &path); /** * @brief Sync [realpath](http://linux.die.net/man/3/realpath). @@ -1281,7 +1281,7 @@ public: * * A boolean value that is true in case of success, false otherwise. * * The canonicalized absolute pathname. */ - std::pair realpathSync(std::string path); + std::pair realpathSync(const std::string &path); /** * @brief Async [chown](http://linux.die.net/man/2/chown). @@ -1293,7 +1293,7 @@ public: * @param uid UID, as described in the official documentation. * @param gid GID, as described in the official documentation. */ - void chown(std::string path, Uid uid, Gid gid); + void chown(const std::string &path, Uid uid, Gid gid); /** * @brief Sync [chown](http://linux.die.net/man/2/chown). @@ -1302,7 +1302,7 @@ public: * @param gid GID, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool chownSync(std::string path, Uid uid, Gid gid); + bool chownSync(const std::string &path, Uid uid, Gid gid); /** * @brief Async [lchown](https://linux.die.net/man/2/lchown). @@ -1314,7 +1314,7 @@ public: * @param uid UID, as described in the official documentation. * @param gid GID, as described in the official documentation. */ - void lchown(std::string path, Uid uid, Gid gid); + void lchown(const std::string &path, Uid uid, Gid gid); /** * @brief Sync [lchown](https://linux.die.net/man/2/lchown). @@ -1323,7 +1323,7 @@ public: * @param gid GID, as described in the official documentation. * @return True in case of success, false otherwise. */ - bool lchownSync(std::string path, Uid uid, Gid gid); + bool lchownSync(const std::string &path, Uid uid, Gid gid); /** * @brief Opens a path asynchronously as a directory stream. @@ -1337,7 +1337,7 @@ public: * * @param path The path to open as a directory stream. */ - void opendir(std::string path); + void opendir(const std::string &path); /** * @brief Opens a path synchronously as a directory stream. @@ -1349,7 +1349,7 @@ public: * @param path The path to open as a directory stream. * @return True in case of success, false otherwise. */ - bool opendirSync(std::string path); + bool opendirSync(const std::string &path); /** * @brief Closes asynchronously a directory stream. @@ -1459,4 +1459,5 @@ struct FsHelper { #include "fs.cpp" #endif + #endif // UVW_FS_INCLUDE_H diff --git a/src/uvw/fs_event.cpp b/src/uvw/fs_event.cpp index 65ed0208..85e428f3 100644 --- a/src/uvw/fs_event.cpp +++ b/src/uvw/fs_event.cpp @@ -3,7 +3,6 @@ #endif #include - #include "config.h" @@ -31,12 +30,12 @@ UVW_INLINE bool FsEventHandle::init() { } -UVW_INLINE void FsEventHandle::start(std::string path, Flags flags) { +UVW_INLINE void FsEventHandle::start(const std::string &path, Flags flags) { invoke(&uv_fs_event_start, get(), &startCallback, path.data(), flags); } -UVW_INLINE void FsEventHandle::start(std::string path, FsEventHandle::Event flag) { +UVW_INLINE void FsEventHandle::start(const std::string &path, FsEventHandle::Event flag) { start(std::move(path), Flags{flag}); } diff --git a/src/uvw/fs_event.h b/src/uvw/fs_event.h index 6cbc5a08..7d2ab41c 100644 --- a/src/uvw/fs_event.h +++ b/src/uvw/fs_event.h @@ -105,7 +105,7 @@ public: * @param path The file or directory to be monitored. * @param flags Additional flags to control the behavior. */ - void start(std::string path, Flags flags = Flags{}); + void start(const std::string &path, Flags flags = Flags{}); /** * @brief Starts watching the specified path. @@ -124,7 +124,7 @@ public: * @param path The file or directory to be monitored. * @param flag Additional flag to control the behavior. */ - void start(std::string path, Event flag); + void start(const std::string &path, Event flag); /** * @brief Stops polling the file descriptor. @@ -146,4 +146,5 @@ public: #include "fs_event.cpp" #endif + #endif // UVW_FS_EVENT_INCLUDE_H diff --git a/src/uvw/fs_poll.cpp b/src/uvw/fs_poll.cpp index f5cdbb97..885ecbe2 100644 --- a/src/uvw/fs_poll.cpp +++ b/src/uvw/fs_poll.cpp @@ -31,7 +31,7 @@ UVW_INLINE bool FsPollHandle::init() { } -UVW_INLINE void FsPollHandle::start(std::string file, FsPollHandle::Time interval) { +UVW_INLINE void FsPollHandle::start(const std::string &file, FsPollHandle::Time interval) { invoke(&uv_fs_poll_start, get(), &startCallback, file.data(), interval.count()); } diff --git a/src/uvw/fs_poll.h b/src/uvw/fs_poll.h index a264eb3b..f914b506 100644 --- a/src/uvw/fs_poll.h +++ b/src/uvw/fs_poll.h @@ -57,7 +57,7 @@ public: * @param file The path to the file to be checked. * @param interval Milliseconds between successive checks. */ - void start(std::string file, Time interval); + void start(const std::string &file, Time interval); /** * @brief Stops the handle. @@ -80,4 +80,5 @@ public: #include "fs_poll.cpp" #endif + #endif // UVW_FS_POLL_INCLUDE_H diff --git a/src/uvw/lib.cpp b/src/uvw/lib.cpp index 44308ed1..5df54489 100644 --- a/src/uvw/lib.cpp +++ b/src/uvw/lib.cpp @@ -10,7 +10,7 @@ namespace uvw { -UVW_INLINE SharedLib::SharedLib(UnderlyingType::ConstructorAccess ca, std::shared_ptr ref, std::string filename) noexcept +UVW_INLINE SharedLib::SharedLib(UnderlyingType::ConstructorAccess ca, std::shared_ptr ref, const std::string &filename) noexcept : UnderlyingType{ca, std::move(ref)} { opened = (0 == uv_dlopen(filename.data(), get())); diff --git a/src/uvw/lib.h b/src/uvw/lib.h index 7e8fff18..8c951316 100644 --- a/src/uvw/lib.h +++ b/src/uvw/lib.h @@ -21,7 +21,7 @@ namespace uvw { */ class SharedLib final: public UnderlyingType { public: - explicit SharedLib(ConstructorAccess ca, std::shared_ptr ref, std::string filename) noexcept; + explicit SharedLib(ConstructorAccess ca, std::shared_ptr ref, const std::string &filename) noexcept; ~SharedLib() noexcept; @@ -41,7 +41,7 @@ public: * @return A valid function pointer in case of success, `nullptr` otherwise. */ template - F * sym(std::string name) { + F * sym(const std::string &name) { static_assert(std::is_function_v); F *func; auto err = uv_dlsym(get(), name.data(), reinterpret_cast(&func)); @@ -67,4 +67,5 @@ private: #include "lib.cpp" #endif + #endif // UVW_LIB_INCLUDE_H diff --git a/src/uvw/pipe.cpp b/src/uvw/pipe.cpp index bad31511..b6933367 100644 --- a/src/uvw/pipe.cpp +++ b/src/uvw/pipe.cpp @@ -3,7 +3,6 @@ #endif #include - #include "config.h" @@ -25,12 +24,12 @@ UVW_INLINE void PipeHandle::open(FileHandle file) { } -UVW_INLINE void PipeHandle::bind(std::string name) { +UVW_INLINE void PipeHandle::bind(const std::string &name) { invoke(&uv_pipe_bind, get(), name.data()); } -UVW_INLINE void PipeHandle::connect(std::string name) { +UVW_INLINE void PipeHandle::connect(const std::string &name) { auto listener = [ptr = shared_from_this()](const auto &event, const auto &) { ptr->publish(event); }; diff --git a/src/uvw/pipe.h b/src/uvw/pipe.h index d37ea40a..576b2c88 100644 --- a/src/uvw/pipe.h +++ b/src/uvw/pipe.h @@ -69,7 +69,7 @@ public: * * @param name A valid file path. */ - void bind(std::string name); + void bind(const std::string &name); /** * @brief Connects to the Unix domain socket or the named pipe. @@ -81,7 +81,7 @@ public: * * @param name A valid domain socket or named pipe. */ - void connect(std::string name); + void connect(const std::string &name); /** * @brief Gets the name of the Unix domain socket or the named pipe. @@ -164,4 +164,5 @@ private: #include "pipe.cpp" #endif + #endif // UVW_PIPE_INCLUDE_H diff --git a/src/uvw/process.cpp b/src/uvw/process.cpp index a416e0ef..49f4c04a 100644 --- a/src/uvw/process.cpp +++ b/src/uvw/process.cpp @@ -82,7 +82,7 @@ UVW_INLINE int ProcessHandle::pid() noexcept { } -UVW_INLINE ProcessHandle &ProcessHandle::cwd(std::string path) noexcept { +UVW_INLINE ProcessHandle &ProcessHandle::cwd(const std::string &path) noexcept { poCwd = path; return *this; } diff --git a/src/uvw/process.h b/src/uvw/process.h index f19fcc4d..ac9e852d 100644 --- a/src/uvw/process.h +++ b/src/uvw/process.h @@ -137,7 +137,7 @@ public: * @param path The working directory to be used when `spawn()` is invoked. * @return A reference to this process handle. */ - ProcessHandle & cwd(std::string path) noexcept; + ProcessHandle & cwd(const std::string &path) noexcept; /** * @brief Sets flags that control how `spawn()` behaves. @@ -251,4 +251,5 @@ private: #include "process.cpp" #endif + #endif // UVW_PROCESS_INCLUDE_H diff --git a/src/uvw/tcp.cpp b/src/uvw/tcp.cpp index a1b0ec28..db6759c6 100644 --- a/src/uvw/tcp.cpp +++ b/src/uvw/tcp.cpp @@ -44,7 +44,7 @@ UVW_INLINE void TCPHandle::bind(const sockaddr &addr, Flags opts) { template -UVW_INLINE void TCPHandle::bind(std::string ip, unsigned int port, Flags opts) +UVW_INLINE void TCPHandle::bind(const std::string &ip, unsigned int port, Flags opts) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); @@ -71,7 +71,7 @@ UVW_INLINE Addr TCPHandle::peer() const noexcept { template -UVW_INLINE void TCPHandle::connect(std::string ip, unsigned int port) { +UVW_INLINE void TCPHandle::connect(const std::string &ip, unsigned int port) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); connect(reinterpret_cast(addr)); @@ -103,8 +103,8 @@ UVW_INLINE void TCPHandle::closeReset() { // explicit instantiations #ifdef UVW_AS_LIB -template void TCPHandle::bind(std::string, unsigned int, Flags); -template void TCPHandle::bind(std::string, unsigned int, Flags); +template void TCPHandle::bind(const std::string &, unsigned int, Flags); +template void TCPHandle::bind(const std::string &, unsigned int, Flags); template void TCPHandle::bind(Addr, Flags); template void TCPHandle::bind(Addr, Flags); @@ -115,11 +115,12 @@ template Addr TCPHandle::sock() const noexcept; template Addr TCPHandle::peer() const noexcept; template Addr TCPHandle::peer() const noexcept; -template void TCPHandle::connect(std::string, unsigned int); -template void TCPHandle::connect(std::string, unsigned int); +template void TCPHandle::connect(const std::string &, unsigned int); +template void TCPHandle::connect(const std::string &, unsigned int); template void TCPHandle::connect(Addr addr); template void TCPHandle::connect(Addr addr); #endif // UVW_AS_LIB + } diff --git a/src/uvw/tcp.h b/src/uvw/tcp.h index cd023948..d5019090 100644 --- a/src/uvw/tcp.h +++ b/src/uvw/tcp.h @@ -136,7 +136,7 @@ public: * @param opts Optional additional flags. */ template - void bind(std::string ip, unsigned int port, Flags opts = Flags{}); + void bind(const std::string &ip, unsigned int port, Flags opts = Flags{}); /** * @brief Binds the handle to an address and port. @@ -197,7 +197,7 @@ public: * @param port The port to which to bind. */ template - void connect(std::string ip, unsigned int port); + void connect(const std::string &ip, unsigned int port); /** * @brief Establishes an IPv4 or IPv6 TCP connection. @@ -238,8 +238,8 @@ private: // (extern) explicit instantiations #ifdef UVW_AS_LIB -extern template void TCPHandle::bind(std::string, unsigned int, Flags); -extern template void TCPHandle::bind(std::string, unsigned int, Flags); +extern template void TCPHandle::bind(const std::string &, unsigned int, Flags); +extern template void TCPHandle::bind(const std::string &, unsigned int, Flags); extern template void TCPHandle::bind(Addr, Flags); extern template void TCPHandle::bind(Addr, Flags); @@ -250,13 +250,14 @@ extern template Addr TCPHandle::sock() const noexcept; extern template Addr TCPHandle::peer() const noexcept; extern template Addr TCPHandle::peer() const noexcept; -extern template void TCPHandle::connect(std::string, unsigned int); -extern template void TCPHandle::connect(std::string, unsigned int); +extern template void TCPHandle::connect(const std::string &, unsigned int); +extern template void TCPHandle::connect(const std::string &, unsigned int); extern template void TCPHandle::connect(Addr addr); extern template void TCPHandle::connect(Addr addr); #endif // UVW_AS_LIB + /** * Internal details not to be documented. * @endcond @@ -270,4 +271,5 @@ extern template void TCPHandle::connect(Addr addr); #include "tcp.cpp" #endif + #endif // UVW_TCP_INCLUDE_H diff --git a/src/uvw/udp.cpp b/src/uvw/udp.cpp index f68ce4b3..915b6b3a 100644 --- a/src/uvw/udp.cpp +++ b/src/uvw/udp.cpp @@ -51,7 +51,7 @@ UVW_INLINE void UDPHandle::connect(const sockaddr &addr) { template -UVW_INLINE void UDPHandle::connect(std::string ip, unsigned int port) { +UVW_INLINE void UDPHandle::connect(const std::string &ip, unsigned int port) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); connect(reinterpret_cast(addr)); @@ -76,7 +76,7 @@ UVW_INLINE Addr UDPHandle::peer() const noexcept { template -UVW_INLINE void UDPHandle::bind(std::string ip, unsigned int port, Flags opts) { +UVW_INLINE void UDPHandle::bind(const std::string &ip, unsigned int port, Flags opts) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); bind(reinterpret_cast(addr), std::move(opts)); @@ -96,7 +96,7 @@ UVW_INLINE Addr UDPHandle::sock() const noexcept { template -UVW_INLINE bool UDPHandle::multicastMembership(std::string multicast, std::string iface, Membership membership) { +UVW_INLINE bool UDPHandle::multicastMembership(const std::string &multicast, const std::string &iface, Membership membership) { return (0 == uv_udp_set_membership(get(), multicast.data(), iface.data(), static_cast(membership))); } @@ -112,7 +112,7 @@ UVW_INLINE bool UDPHandle::multicastTtl(int val) { template -UVW_INLINE bool UDPHandle::multicastInterface(std::string iface) { +UVW_INLINE bool UDPHandle::multicastInterface(const std::string &iface) { return (0 == uv_udp_set_multicast_interface(get(), iface.data())); } @@ -144,7 +144,7 @@ UVW_INLINE void UDPHandle::send(const sockaddr &addr, std::unique_ptr da template -UVW_INLINE void UDPHandle::send(std::string ip, unsigned int port, std::unique_ptr data, unsigned int len) { +UVW_INLINE void UDPHandle::send(const std::string &ip, unsigned int port, std::unique_ptr data, unsigned int len) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); send(reinterpret_cast(addr), std::move(data), len); @@ -173,7 +173,7 @@ UVW_INLINE void UDPHandle::send(const sockaddr &addr, char *data, unsigned int l template -UVW_INLINE void UDPHandle::send(std::string ip, unsigned int port, char *data, unsigned int len) { +UVW_INLINE void UDPHandle::send(const std::string &ip, unsigned int port, char *data, unsigned int len) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); send(reinterpret_cast(addr), data, len); @@ -201,7 +201,7 @@ UVW_INLINE int UDPHandle::trySend(const sockaddr &addr, std::unique_ptr template -UVW_INLINE int UDPHandle::trySend(std::string ip, unsigned int port, std::unique_ptr data, unsigned int len) { +UVW_INLINE int UDPHandle::trySend(const std::string &ip, unsigned int port, std::unique_ptr data, unsigned int len) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); return trySend(reinterpret_cast(addr), std::move(data), len); @@ -229,7 +229,7 @@ UVW_INLINE int UDPHandle::trySend(const sockaddr &addr, char *data, unsigned int template -UVW_INLINE int UDPHandle::trySend(std::string ip, unsigned int port, char *data, unsigned int len) { +UVW_INLINE int UDPHandle::trySend(const std::string &ip, unsigned int port, char *data, unsigned int len) { typename details::IpTraits::Type addr; details::IpTraits::addrFunc(ip.data(), port, &addr); return trySend(reinterpret_cast(addr), data, len); @@ -265,8 +265,8 @@ UVW_INLINE size_t UDPHandle::sendQueueCount() const noexcept { // explicit instantiations #ifdef UVW_AS_LIB -template void UDPHandle::connect(std::string, unsigned int); -template void UDPHandle::connect(std::string, unsigned int); +template void UDPHandle::connect(const std::string &, unsigned int); +template void UDPHandle::connect(const std::string &, unsigned int); template void UDPHandle::connect(Addr); template void UDPHandle::connect(Addr); @@ -274,8 +274,8 @@ template void UDPHandle::connect(Addr); template Addr UDPHandle::peer() const noexcept; template Addr UDPHandle::peer() const noexcept; -template void UDPHandle::bind(std::string, unsigned int, Flags); -template void UDPHandle::bind(std::string, unsigned int, Flags); +template void UDPHandle::bind(const std::string &, unsigned int, Flags); +template void UDPHandle::bind(const std::string &, unsigned int, Flags); template void UDPHandle::bind(Addr, Flags); template void UDPHandle::bind(Addr, Flags); @@ -283,20 +283,20 @@ template void UDPHandle::bind(Addr, Flags); template Addr UDPHandle::sock() const noexcept; template Addr UDPHandle::sock() const noexcept; -template bool UDPHandle::multicastMembership(std::string, std::string, Membership); -template bool UDPHandle::multicastMembership(std::string, std::string, Membership); +template bool UDPHandle::multicastMembership(const std::string &, const std::string &, Membership); +template bool UDPHandle::multicastMembership(const std::string &, const std::string &, Membership); -template bool UDPHandle::multicastInterface(std::string); -template bool UDPHandle::multicastInterface(std::string); +template bool UDPHandle::multicastInterface(const std::string &); +template bool UDPHandle::multicastInterface(const std::string &); -template void UDPHandle::send(std::string, unsigned int, std::unique_ptr, unsigned int); -template void UDPHandle::send(std::string, unsigned int, std::unique_ptr, unsigned int); +template void UDPHandle::send(const std::string &, unsigned int, std::unique_ptr, unsigned int); +template void UDPHandle::send(const std::string &, unsigned int, std::unique_ptr, unsigned int); template void UDPHandle::send(Addr, std::unique_ptr, unsigned int); template void UDPHandle::send(Addr, std::unique_ptr, unsigned int); -template void UDPHandle::send(std::string, unsigned int, char *, unsigned int); -template void UDPHandle::send(std::string, unsigned int, char *, unsigned int); +template void UDPHandle::send(const std::string &, unsigned int, char *, unsigned int); +template void UDPHandle::send(const std::string &, unsigned int, char *, unsigned int); template void UDPHandle::send(Addr, char *, unsigned int); template void UDPHandle::send(Addr, char *, unsigned int); @@ -304,8 +304,8 @@ template void UDPHandle::send(Addr, char *, unsigned int); template int UDPHandle::trySend(const sockaddr &, std::unique_ptr, unsigned int); template int UDPHandle::trySend(const sockaddr &, std::unique_ptr, unsigned int); -template int UDPHandle::trySend(std::string, unsigned int, std::unique_ptr, unsigned int); -template int UDPHandle::trySend(std::string, unsigned int, std::unique_ptr, unsigned int); +template int UDPHandle::trySend(const std::string &, unsigned int, std::unique_ptr, unsigned int); +template int UDPHandle::trySend(const std::string &, unsigned int, std::unique_ptr, unsigned int); template int UDPHandle::trySend(Addr, std::unique_ptr, unsigned int); template int UDPHandle::trySend(Addr, std::unique_ptr, unsigned int); @@ -313,8 +313,8 @@ template int UDPHandle::trySend(Addr, std::unique_ptr, unsigned in template int UDPHandle::trySend(const sockaddr &, char *, unsigned int); template int UDPHandle::trySend(const sockaddr &, char *, unsigned int); -template int UDPHandle::trySend(std::string, unsigned int, char *, unsigned int); -template int UDPHandle::trySend(std::string, unsigned int, char *, unsigned int); +template int UDPHandle::trySend(const std::string &, unsigned int, char *, unsigned int); +template int UDPHandle::trySend(const std::string &, unsigned int, char *, unsigned int); template int UDPHandle::trySend(Addr, char *, unsigned int); template int UDPHandle::trySend(Addr, char *, unsigned int); @@ -323,4 +323,5 @@ template void UDPHandle::recv(); template void UDPHandle::recv(); #endif // UVW_AS_LIB + } diff --git a/src/uvw/udp.h b/src/uvw/udp.h index e4090a22..c250ecad 100644 --- a/src/uvw/udp.h +++ b/src/uvw/udp.h @@ -193,7 +193,7 @@ public: * @param port The port to which to bind. */ template - void connect(std::string ip, unsigned int port); + void connect(const std::string &ip, unsigned int port); /** * @brief Associates the handle to a remote address and port (either IPv4 or @@ -248,7 +248,7 @@ public: * @param opts Optional additional flags. */ template - void bind(std::string ip, unsigned int port, Flags opts = Flags{}); + void bind(const std::string &ip, unsigned int port, Flags opts = Flags{}); /** * @brief Binds the UDP handle to an IP address and port. @@ -293,7 +293,7 @@ public: * @return True in case of success, false otherwise. */ template - bool multicastMembership(std::string multicast, std::string iface, Membership membership); + bool multicastMembership(const std::string &multicast, const std::string &iface, Membership membership); /** * @brief Sets IP multicast loop flag. @@ -318,7 +318,7 @@ public: * @return True in case of success, false otherwise. */ template - bool multicastInterface(std::string iface); + bool multicastInterface(const std::string &iface); /** * @brief Sets broadcast on or off. @@ -372,7 +372,7 @@ public: * @param len The lenght of the submitted data. */ template - void send(std::string ip, unsigned int port, std::unique_ptr data, unsigned int len); + void send(const std::string &ip, unsigned int port, std::unique_ptr data, unsigned int len); /** * @brief Sends data over the UDP socket. @@ -432,7 +432,7 @@ public: * @param len The lenght of the submitted data. */ template - void send(std::string ip, unsigned int port, char *data, unsigned int len); + void send(const std::string &ip, unsigned int port, char *data, unsigned int len); /** * @brief Sends data over the UDP socket. @@ -481,7 +481,7 @@ public: * @return Number of bytes written. */ template - int trySend(std::string ip, unsigned int port, std::unique_ptr data, unsigned int len); + int trySend(const std::string &ip, unsigned int port, std::unique_ptr data, unsigned int len); /** * @brief Sends data over the UDP socket. @@ -524,7 +524,7 @@ public: * @return Number of bytes written. */ template - int trySend(std::string ip, unsigned int port, char *data, unsigned int len); + int trySend(const std::string &ip, unsigned int port, char *data, unsigned int len); /** * @brief Sends data over the UDP socket. @@ -587,8 +587,8 @@ private: // (extern) explicit instantiations #ifdef UVW_AS_LIB -extern template void UDPHandle::connect(std::string, unsigned int); -extern template void UDPHandle::connect(std::string, unsigned int); +extern template void UDPHandle::connect(const std::string &, unsigned int); +extern template void UDPHandle::connect(const std::string &, unsigned int); extern template void UDPHandle::connect(Addr); extern template void UDPHandle::connect(Addr); @@ -596,8 +596,8 @@ extern template void UDPHandle::connect(Addr); extern template Addr UDPHandle::peer() const noexcept; extern template Addr UDPHandle::peer() const noexcept; -extern template void UDPHandle::bind(std::string, unsigned int, Flags); -extern template void UDPHandle::bind(std::string, unsigned int, Flags); +extern template void UDPHandle::bind(const std::string &, unsigned int, Flags); +extern template void UDPHandle::bind(const std::string &, unsigned int, Flags); extern template void UDPHandle::bind(Addr, Flags); extern template void UDPHandle::bind(Addr, Flags); @@ -605,20 +605,20 @@ extern template void UDPHandle::bind(Addr, Flags); extern template Addr UDPHandle::sock() const noexcept; extern template Addr UDPHandle::sock() const noexcept; -extern template bool UDPHandle::multicastMembership(std::string, std::string, Membership); -extern template bool UDPHandle::multicastMembership(std::string, std::string, Membership); +extern template bool UDPHandle::multicastMembership(const std::string &, const std::string &, Membership); +extern template bool UDPHandle::multicastMembership(const std::string &, const std::string &, Membership); -extern template bool UDPHandle::multicastInterface(std::string); -extern template bool UDPHandle::multicastInterface(std::string); +extern template bool UDPHandle::multicastInterface(const std::string &); +extern template bool UDPHandle::multicastInterface(const std::string &); -extern template void UDPHandle::send(std::string, unsigned int, std::unique_ptr, unsigned int); -extern template void UDPHandle::send(std::string, unsigned int, std::unique_ptr, unsigned int); +extern template void UDPHandle::send(const std::string &, unsigned int, std::unique_ptr, unsigned int); +extern template void UDPHandle::send(const std::string &, unsigned int, std::unique_ptr, unsigned int); extern template void UDPHandle::send(Addr, std::unique_ptr, unsigned int); extern template void UDPHandle::send(Addr, std::unique_ptr, unsigned int); -extern template void UDPHandle::send(std::string, unsigned int, char *, unsigned int); -extern template void UDPHandle::send(std::string, unsigned int, char *, unsigned int); +extern template void UDPHandle::send(const std::string &, unsigned int, char *, unsigned int); +extern template void UDPHandle::send(const std::string &, unsigned int, char *, unsigned int); extern template void UDPHandle::send(Addr, char *, unsigned int); extern template void UDPHandle::send(Addr, char *, unsigned int); @@ -626,8 +626,8 @@ extern template void UDPHandle::send(Addr, char *, unsigned int); extern template int UDPHandle::trySend(const sockaddr &, std::unique_ptr, unsigned int); extern template int UDPHandle::trySend(const sockaddr &, std::unique_ptr, unsigned int); -extern template int UDPHandle::trySend(std::string, unsigned int, std::unique_ptr, unsigned int); -extern template int UDPHandle::trySend(std::string, unsigned int, std::unique_ptr, unsigned int); +extern template int UDPHandle::trySend(const std::string &, unsigned int, std::unique_ptr, unsigned int); +extern template int UDPHandle::trySend(const std::string &, unsigned int, std::unique_ptr, unsigned int); extern template int UDPHandle::trySend(Addr, std::unique_ptr, unsigned int); extern template int UDPHandle::trySend(Addr, std::unique_ptr, unsigned int); @@ -635,8 +635,8 @@ extern template int UDPHandle::trySend(Addr, std::unique_ptr, unsi extern template int UDPHandle::trySend(const sockaddr &, char *, unsigned int); extern template int UDPHandle::trySend(const sockaddr &, char *, unsigned int); -extern template int UDPHandle::trySend(std::string, unsigned int, char *, unsigned int); -extern template int UDPHandle::trySend(std::string, unsigned int, char *, unsigned int); +extern template int UDPHandle::trySend(const std::string &, unsigned int, char *, unsigned int); +extern template int UDPHandle::trySend(const std::string &, unsigned int, char *, unsigned int); extern template int UDPHandle::trySend(Addr, char *, unsigned int); extern template int UDPHandle::trySend(Addr, char *, unsigned int); @@ -645,6 +645,7 @@ extern template void UDPHandle::recv(); extern template void UDPHandle::recv(); #endif // UVW_AS_LIB + /** * Internal details not to be documented. * @endcond @@ -658,4 +659,5 @@ extern template void UDPHandle::recv(); #include "udp.cpp" #endif + #endif // UVW_UDP_INCLUDE_H diff --git a/src/uvw/util.cpp b/src/uvw/util.cpp index 95ef3252..921ba221 100644 --- a/src/uvw/util.cpp +++ b/src/uvw/util.cpp @@ -278,7 +278,7 @@ UVW_INLINE std::string Utilities::processTitle() { } -UVW_INLINE bool Utilities::processTitle(std::string title) { +UVW_INLINE bool Utilities::processTitle(const std::string &title) { return (0 == uv_set_process_title(title.c_str())); } diff --git a/src/uvw/util.h b/src/uvw/util.h index 72c3ca31..3796fb19 100644 --- a/src/uvw/util.h +++ b/src/uvw/util.h @@ -742,7 +742,7 @@ struct Utilities { * @param title The process title to be set. * @return True in case of success, false otherwise. */ - static bool processTitle(std::string title); + static bool processTitle(const std::string &title); /** * @brief Gets memory information (in bytes). @@ -846,4 +846,5 @@ Overloaded(Func...) -> Overloaded; #include "util.cpp" #endif + #endif // UVW_UTIL_INCLUDE_H