Skip to content
Snippets Groups Projects
Commit 82357e8e authored by Daniel Müller's avatar Daniel Müller :speech_balloon:
Browse files

Wrap everything in namespace

- Put the whole library in namespace netlib
parent 30a82550
Branches
No related tags found
No related merge requests found
Pipeline #71639 passed
......@@ -5,6 +5,8 @@
// Include the all-in-one headerfile. This will include all other headers
#include "netlib.hpp"
using namespace netlib;
void example_IpAddr()
{
// IpAddr takes an address as string and automatically detects if it is
......
......@@ -4,6 +4,10 @@
#include <string>
#include <netinet/in.h>
namespace netlib
{
/**
* @brief The IpAddr class represents an ip address that can either be of type
* Ipv4 or of type Ipv6.
......@@ -129,4 +133,7 @@ public:
};
} // namespace netlib
#endif // _IPADDR_HPP
\ No newline at end of file
......@@ -5,6 +5,10 @@
#include "ipaddr.hpp"
namespace netlib
{
/**
* @brief Provide multiple ways to resolve hostnames to Ipv4 and/or Ipv6
* addresses.
......@@ -112,4 +116,6 @@ public:
};
} // namespace netlib
#endif // _RESOLVER_HPP
\ No newline at end of file
......@@ -6,6 +6,10 @@
#include "ipaddr.hpp"
namespace netlib
{
/**
* @brief SockAddr represents the combination of an ip address and a port number.
*
......@@ -134,4 +138,7 @@ public:
};
} // namespace netlib
#endif // _SOCKADDR_HPP
\ No newline at end of file
......@@ -6,6 +6,10 @@
#include <filesystem>
namespace netlib
{
/**
* @brief Listen to a local ip address + port and accept incomming connections
* as TcpStreams.
......@@ -113,4 +117,7 @@ public:
};
} // namespace netlib
#endif // _TCPLISTENER_HPP
\ No newline at end of file
......@@ -5,6 +5,10 @@
#include "sockaddr.hpp"
namespace netlib
{
/**
* @brief The TcpStream represents tcp a connection with another endpoint and is
* used to send and receive data through that connection.
......@@ -227,4 +231,6 @@ public:
};
} // namespace netlib
#endif // _TCPSTREAM_HPP
\ No newline at end of file
......@@ -3,6 +3,10 @@
#include "sockaddr.hpp"
namespace netlib
{
/**
* @brief The UdpSocket can be used to receive UDP packets from and send UDP
* packets to any target address.
......@@ -209,4 +213,7 @@ public:
};
} // namespace netlib
#endif // _UDPSOCKET_HPP
\ No newline at end of file
......@@ -5,6 +5,8 @@
#include <cstring>
#include <arpa/inet.h>
using namespace netlib;
IpAddr::IpAddr()
: IpAddr("0.0.0.0")
{ }
......
......@@ -8,6 +8,7 @@
#include <netdb.h>
#include <arpa/inet.h>
using namespace netlib;
IpAddr Resolver::resolveHostnameAF(const std::string &hostname, int af)
{
......
......@@ -5,6 +5,8 @@
#include <arpa/inet.h>
using namespace netlib;
SockAddr::SockAddr()
: SockAddr{IpAddr::V4("0.0.0.0"), 0}
{ }
......
......@@ -5,6 +5,8 @@
#include <unistd.h>
#include <sys/socket.h>
using namespace netlib;
// TODO: More and better error handling
TcpListener::TcpListener(SockAddr _local)
......
......@@ -7,6 +7,8 @@
#include <netinet/in.h>
#include <poll.h>
using namespace netlib;
TcpStream::TcpStream(SockAddr _remote)
: remote{_remote}, sockfd{0}
{ }
......
......@@ -6,6 +6,7 @@
#include <sys/socket.h>
#include <poll.h>
using namespace netlib;
UdpSocket::UdpSocket()
: UdpSocket{"0.0.0.0", 0}
......
......@@ -7,6 +7,7 @@
#include "netlib.hpp"
using namespace netlib;
TEST_CASE("Test IpAddr::V4") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment