mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 20:13:05 +02:00
4d9a751af2
Minor reorganization of unicode code.
57 lines
918 B
C++
57 lines
918 B
C++
//
|
|
// mode.hpp
|
|
// OpenVPN
|
|
//
|
|
// Copyright (c) 2012 OpenVPN Technologies, Inc. All rights reserved.
|
|
//
|
|
|
|
#ifndef OPENVPN_COMMON_MODE_H
|
|
#define OPENVPN_COMMON_MODE_H
|
|
|
|
// A client/server mode class.
|
|
|
|
namespace openvpn {
|
|
class Mode
|
|
{
|
|
public:
|
|
enum Type {
|
|
CLIENT,
|
|
SERVER,
|
|
};
|
|
|
|
Mode() : type_(CLIENT) {}
|
|
explicit Mode(const Type t) : type_(t) {}
|
|
|
|
bool is_server() const { return type_ == SERVER; }
|
|
bool is_client() const { return type_ == CLIENT; }
|
|
|
|
bool operator==(const Mode& other)
|
|
{
|
|
return type_ == other.type_;
|
|
}
|
|
|
|
bool operator!=(const Mode& other)
|
|
{
|
|
return type_ != other.type_;
|
|
}
|
|
|
|
const char *str() const
|
|
{
|
|
switch (type_)
|
|
{
|
|
case CLIENT:
|
|
return "CLIENT";
|
|
case SERVER:
|
|
return "SERVER";
|
|
default:
|
|
return "UNDEF_MODE";
|
|
}
|
|
}
|
|
|
|
private:
|
|
Type type_;
|
|
};
|
|
} // namespace openvpn
|
|
|
|
#endif // OPENVPN_COMMON_MODE_H
|