Skip to content

Commit

Permalink
Refactor nested namespace to C++17 style
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
  • Loading branch information
leoossa authored and Jenkins-dev committed Jul 3, 2024
1 parent a89b6cb commit 3646265
Show file tree
Hide file tree
Showing 201 changed files with 403 additions and 838 deletions.
6 changes: 2 additions & 4 deletions openvpn/acceptor/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
#define OPENVPN_ACCEPTOR_LISTENER_BASE_RC RC<thread_unsafe_refcount>
#endif

namespace openvpn {
namespace Acceptor {
namespace openvpn::Acceptor {

struct ListenerBase : public OPENVPN_ACCEPTOR_LISTENER_BASE_RC
{
Expand Down Expand Up @@ -91,5 +90,4 @@ struct Set : public std::vector<Item>
}
};

} // namespace Acceptor
} // namespace openvpn
} // namespace openvpn::Acceptor
6 changes: 2 additions & 4 deletions openvpn/acceptor/namedpipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include <openvpn/win/scoped_handle.hpp>
#include <openvpn/win/secattr.hpp>

namespace openvpn {
namespace Acceptor {
namespace openvpn::Acceptor {

class NamedPipe : public Base
{
Expand Down Expand Up @@ -113,5 +112,4 @@ class NamedPipe : public Base
Win::SecurityAttributes sa;
};

} // namespace Acceptor
} // namespace openvpn
} // namespace openvpn::Acceptor
6 changes: 2 additions & 4 deletions openvpn/acceptor/tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include <openvpn/acceptor/base.hpp>
#include <openvpn/ssl/sslconsts.hpp>

namespace openvpn {
namespace Acceptor {
namespace openvpn::Acceptor {

struct TCP : public Base
{
Expand Down Expand Up @@ -93,5 +92,4 @@ struct TCP : public Base
openvpn_io::ip::tcp::acceptor acceptor;
};

} // namespace Acceptor
} // namespace openvpn
} // namespace openvpn::Acceptor
6 changes: 2 additions & 4 deletions openvpn/acceptor/unix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

#include <openvpn/acceptor/base.hpp>

namespace openvpn {
namespace Acceptor {
namespace openvpn::Acceptor {

struct Unix : public Base
{
Expand Down Expand Up @@ -76,5 +75,4 @@ struct Unix : public Base
openvpn_io::basic_socket_acceptor<openvpn_io::local::stream_protocol> acceptor;
};

} // namespace Acceptor
} // namespace openvpn
} // namespace openvpn::Acceptor
6 changes: 2 additions & 4 deletions openvpn/addr/addrlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include <openvpn/common/rc.hpp>
#include <openvpn/addr/ip.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {

// A list of unique IP addresses
class AddrList : public std::vector<IP::Addr>, public RC<thread_unsafe_refcount>
Expand Down Expand Up @@ -59,7 +58,6 @@ class AddrList : public std::vector<IP::Addr>, public RC<thread_unsafe_refcount>
}
#endif
};
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#endif
6 changes: 2 additions & 4 deletions openvpn/addr/addrpair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#include <openvpn/common/split.hpp>
#include <openvpn/addr/ip.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {

// AddrMaskPair is basically an object that combines an IP address (v4 or v6)
// with a netmask or prefix length.
Expand Down Expand Up @@ -218,7 +217,6 @@ struct AddrMaskPair
}
};
OPENVPN_OSTREAM(AddrMaskPair, to_string)
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#endif
6 changes: 2 additions & 4 deletions openvpn/addr/addrspacesplit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#include <openvpn/common/exception.hpp>
#include <openvpn/addr/route.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {
class AddressSpaceSplitter : public RouteList
{
public:
Expand Down Expand Up @@ -108,5 +107,4 @@ class AddressSpaceSplitter : public RouteList
return type;
}
};
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP
12 changes: 5 additions & 7 deletions openvpn/addr/ip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@

#define OPENVPN_IP_THROW(ERR) throw openvpn::IP::ip_exception(ERR)

namespace openvpn {
// This is our fundamental IP address class that handles IPv4 or IPv6
// IP addresses. It is implemented as a discriminated union of IPv4::Addr
// and IPv6::Addr.
namespace IP {
namespace openvpn::IP {

OPENVPN_EXCEPTION(ip_exception);

// This is our fundamental IP address class that handles IPv4 or IPv6
// IP addresses. It is implemented as a discriminated union of IPv4::Addr
// and IPv6::Addr.
class Addr
{
public:
Expand Down Expand Up @@ -1132,8 +1131,7 @@ class Addr
};

OPENVPN_OSTREAM(Addr, to_string)
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#ifdef USE_OPENVPN_HASH
OPENVPN_HASH_METHOD(openvpn::IP::Addr, hashval);
Expand Down
8 changes: 2 additions & 6 deletions openvpn/addr/iperr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include <openvpn/common/stringtempl2.hpp>
#endif

namespace openvpn {
namespace IP {
namespace internal {
namespace openvpn::IP::internal {

#ifndef OPENVPN_LEGACY_TITLE_ABSTRACTION

Expand Down Expand Up @@ -112,6 +110,4 @@ inline std::string format_error(const std::string &ipstr, const char *title, con
}

#endif
} // namespace internal
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP::internal
6 changes: 2 additions & 4 deletions openvpn/addr/pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
#include <openvpn/addr/ip.hpp>
#include <openvpn/addr/range.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {

// Maintain a pool of IP addresses.
// A should be IP::Addr, IPv4::Addr, or IPv6::Addr.
Expand Down Expand Up @@ -163,7 +162,6 @@ class PoolType
};

typedef PoolType<IP::Addr> Pool;
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#endif
6 changes: 2 additions & 4 deletions openvpn/addr/randaddr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
#include <openvpn/common/exception.hpp>
#include <openvpn/random/randapi.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {

inline IPv4::Addr random_addr_v4(RandomAPI &prng)
{
Expand Down Expand Up @@ -64,5 +63,4 @@ inline Route random_subnet(const Route &templ,
& Addr::netmask_from_prefix_len(templ.addr.version(), prefix_len),
prefix_len);
}
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP
6 changes: 2 additions & 4 deletions openvpn/addr/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

#include <openvpn/addr/ip.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {

// Denote a range of IP addresses with a start and extent,
// where A represents an address class.
Expand Down Expand Up @@ -157,7 +156,6 @@ class RangePartitionType

typedef RangeType<IP::Addr> Range;
typedef RangePartitionType<IP::Addr> RangePartition;
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#endif
6 changes: 2 additions & 4 deletions openvpn/addr/regex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

#include <string>

namespace openvpn {
namespace IP {
namespace openvpn::IP {
inline std::string v4_regex()
{
const std::string ipv4seg = "(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])";
Expand All @@ -55,7 +54,6 @@ inline std::string v6_regex()
")";
// clang-format on
}
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#endif
6 changes: 2 additions & 4 deletions openvpn/addr/regex_static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

#include <openvpn/addr/regex.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {
inline const std::regex re_v4(v4_regex(), std::regex_constants::ECMAScript | std::regex_constants::nosubs);
inline const std::regex re_v6(v6_regex(), std::regex_constants::ECMAScript | std::regex_constants::nosubs);

Expand All @@ -46,5 +45,4 @@ inline bool is_ip_address(const std::string &host)
{
return is_ipv4_address(host) || is_ipv6_address(host);
}
} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP
6 changes: 2 additions & 4 deletions openvpn/addr/route.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
#include <openvpn/common/hash.hpp>
#include <openvpn/addr/ip.hpp>

namespace openvpn {
namespace IP {
namespace openvpn::IP {
// Basic route object
template <typename ADDR>
class RouteType
Expand Down Expand Up @@ -433,8 +432,7 @@ inline Route route_from_string(const std::string &rtstr,

#endif

} // namespace IP
} // namespace openvpn
} // namespace openvpn::IP

#ifdef USE_OPENVPN_HASH
OPENVPN_HASH_METHOD(openvpn::IP::Route, hash_value);
Expand Down
6 changes: 2 additions & 4 deletions openvpn/apple/cf/cf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
return cls(); \
}

namespace openvpn {
namespace CF {
namespace openvpn::CF {
enum Rule
{
CREATE, // create rule
Expand Down Expand Up @@ -471,7 +470,6 @@ inline Data plist(CFTypeRef obj)
nullptr));
}

} // namespace CF
} // namespace openvpn
} // namespace openvpn::CF

#endif // OPENVPN_APPLECRYPTO_CF_CF_H
6 changes: 2 additions & 4 deletions openvpn/apple/cf/cfhelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
// defined in cf.hpp. They add additional convenience methods, such as dictionary
// lookup.

namespace openvpn {
namespace CF {
namespace openvpn::CF {

// essentially a vector of void *, used as source for array and dictionary constructors
typedef BufferAllocatedType<CFTypeRef, thread_unsafe_refcount> SrcList;
Expand Down Expand Up @@ -256,6 +255,5 @@ inline void array_append_index(MutableArray &array, CFIndex value)
Number num = number_from_index(value);
arrayAppendValue(array(), num());
}
} // namespace CF
} // namespace openvpn
} // namespace openvpn::CF
#endif
4 changes: 1 addition & 3 deletions openvpn/apple/cf/cfhost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

#include <openvpn/apple/cf/cf.hpp>

namespace openvpn {
namespace CF {
namespace openvpn::CF {
OPENVPN_CF_WRAP(Host, host_cast, CFHostRef, CFHostGetTypeID)
}
} // namespace openvpn

#endif
6 changes: 2 additions & 4 deletions openvpn/apple/cf/cfrunloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

#include <openvpn/apple/cf/cf.hpp>

namespace openvpn {
namespace CF {
namespace openvpn::CF {
OPENVPN_CF_WRAP(RunLoop, runloop_cast, CFRunLoopRef, CFRunLoopGetTypeID)
OPENVPN_CF_WRAP(RunLoopSource, runloop_source_cast, CFRunLoopSourceRef, CFRunLoopSourceGetTypeID);
} // namespace CF
} // namespace openvpn
} // namespace openvpn::CF

#endif
6 changes: 2 additions & 4 deletions openvpn/apple/cf/cfsec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@

// Define C++ wrappings for Apple security-related objects.

namespace openvpn {
namespace CF {
namespace openvpn::CF {
OPENVPN_CF_WRAP(Cert, cert_cast, SecCertificateRef, SecCertificateGetTypeID)
OPENVPN_CF_WRAP(Key, key_cast, SecKeyRef, SecKeyGetTypeID)
OPENVPN_CF_WRAP(Identity, identity_cast, SecIdentityRef, SecIdentityGetTypeID)
Expand All @@ -51,8 +50,7 @@ OPENVPN_CF_WRAP(Trust, trust_cast, SecTrustRef, SecTrustGetTypeID)
OPENVPN_CF_WRAP(Keychain, keychain_cast, SecKeychainRef, SecKeychainGetTypeID)
OPENVPN_CF_WRAP(Access, access_cast, SecAccessRef, SecAccessGetTypeID)
#endif
} // namespace CF
} // namespace openvpn::CF

} // namespace openvpn

#endif // OPENVPN_APPLECRYPTO_CF_CFSEC_H
4 changes: 1 addition & 3 deletions openvpn/apple/cf/cfsocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

#include <openvpn/apple/cf/cf.hpp>

namespace openvpn {
namespace CF {
namespace openvpn::CF {
OPENVPN_CF_WRAP(Socket, socket_cast, CFSocketRef, CFSocketGetTypeID)
}
} // namespace openvpn

#endif
6 changes: 2 additions & 4 deletions openvpn/apple/cf/cfstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

#include <openvpn/apple/cf/cf.hpp>

namespace openvpn {
namespace CF {
namespace openvpn::CF {
OPENVPN_CF_WRAP(ReadStream, read_stream_cast, CFReadStreamRef, CFReadStreamGetTypeID)
OPENVPN_CF_WRAP(WriteStream, write_stream_cast, CFWriteStreamRef, CFWriteStreamGetTypeID)
} // namespace CF
} // namespace openvpn
} // namespace openvpn::CF

#endif
Loading

0 comments on commit 3646265

Please sign in to comment.