Initial
This commit is contained in:
144
socket/SERVENT.HPP
Normal file
144
socket/SERVENT.HPP
Normal file
@@ -0,0 +1,144 @@
|
||||
#ifndef _SOCKET_SERVENT_HPP_
|
||||
#define _SOCKET_SERVENT_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
class ServEnt
|
||||
{
|
||||
public:
|
||||
ServEnt(void);
|
||||
ServEnt(const ServEnt &someServEnt);
|
||||
virtual ~ServEnt();
|
||||
ServEnt &operator=(const ServEnt &someServEnt);
|
||||
WORD operator==(const ServEnt &someServEnt)const;
|
||||
WORD serviceByName(const String &serverName,const String &protocol);
|
||||
String serviceName(void)const;
|
||||
void serviceName(const String &serviceName);
|
||||
Block<String> aliases(void)const;
|
||||
void aliases(Block<String> &aliases);
|
||||
short port(void)const;
|
||||
void port(short port);
|
||||
String protocol(void)const;
|
||||
void protocol(const String &protocol);
|
||||
private:
|
||||
void pureServiceName(char *lpServiceName);
|
||||
void pureAliases(char **lpAliases);
|
||||
void purePort(short port);
|
||||
void pureProtocol(char *lpProtocol);
|
||||
|
||||
String mNameService;
|
||||
Block<String> mAliasNames;
|
||||
short mPort;
|
||||
String mProtocol;
|
||||
};
|
||||
|
||||
inline
|
||||
ServEnt::ServEnt(void)
|
||||
: mPort(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt::ServEnt(const ServEnt &someServEnt)
|
||||
{
|
||||
*this=someServEnt;
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt::~ServEnt()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt &ServEnt::operator=(const ServEnt &someServEnt)
|
||||
{
|
||||
serviceName(someServEnt.serviceName());
|
||||
aliases(someServEnt.aliases());
|
||||
port(someServEnt.port());
|
||||
protocol(someServEnt.protocol());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD ServEnt::operator==(const ServEnt &someServEnt)const
|
||||
{
|
||||
return (serviceName()==someServEnt.serviceName()&&
|
||||
aliases()==someServEnt.aliases()&&
|
||||
port()==someServEnt.port()&&
|
||||
protocol()==someServEnt.protocol());
|
||||
}
|
||||
|
||||
inline
|
||||
String ServEnt::serviceName(void)const
|
||||
{
|
||||
return mNameService;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::serviceName(const String &serviceName)
|
||||
{
|
||||
mNameService=serviceName;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<String> ServEnt::aliases(void)const
|
||||
{
|
||||
return mAliasNames;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::aliases(Block<String> &aliases)
|
||||
{
|
||||
mAliasNames=aliases;
|
||||
}
|
||||
|
||||
inline
|
||||
short ServEnt::port(void)const
|
||||
{
|
||||
return ntohs(mPort);
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::port(short port)
|
||||
{
|
||||
mPort=htons(port);
|
||||
}
|
||||
|
||||
inline
|
||||
String ServEnt::protocol(void)const
|
||||
{
|
||||
return mProtocol;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::protocol(const String &protocol)
|
||||
{
|
||||
mProtocol=protocol;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::pureServiceName(char *lpServiceName)
|
||||
{
|
||||
serviceName(lpServiceName);
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::purePort(short portNumber)
|
||||
{
|
||||
mPort=portNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::pureProtocol(char *lpProtocol)
|
||||
{
|
||||
protocol(lpProtocol);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user