📄 ftpdatatypes.h
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Thomas Oswald
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INC_FTPDATATYPES_H
#define INC_FTPDATATYPES_H
#include <vector>
#include "Definements.h"
#include "time.h" // for clock()
namespace nsFTP
{
typedef std::vector<char> TByteVector;
// constants
const TCHAR ANONYMOUS_USER[] = _T("anonymous");
enum T_enConstants {
DEFAULT_FTP_PORT = 21, ///< The default port that an FTP service listens to on a remote host
FTP_ERROR = -1,
FTP_OK = 0,
FTP_NOTOK = 1, };
/// Data Structure
class CStructure
{
public:
enum T_enFileStructure { scFile, scRecord, scPage };
CStructure(const CStructure& structure) :
m_enStructure(structure.AsEnum()) {}
bool operator==(const T_enFileStructure& rhs) const { return m_enStructure==rhs; }
bool operator!=(const T_enFileStructure& rhs) const { return m_enStructure!=rhs; }
bool operator==(const CStructure& rhs) const { return m_enStructure==rhs.AsEnum(); }
bool operator!=(const CStructure& rhs) const { return m_enStructure!=rhs.AsEnum(); }
CStructure& operator=(const CStructure& rhs) { m_enStructure = rhs.AsEnum(); return *this; }
T_enFileStructure AsEnum() const { return m_enStructure; }
static const CStructure File() { return scFile; }
static const CStructure Record() { return scRecord; }
static const CStructure Page() { return scPage; }
private:
CStructure(T_enFileStructure enStructure) : m_enStructure(enStructure) {}
T_enFileStructure m_enStructure;
};
/// Transmission Modes
class CTransferMode
{
public:
enum T_enTransferMode { tmStream, tmBlock, tmCompressed };
CTransferMode(const CTransferMode& transferMode) :
m_enTransferMode(transferMode.AsEnum()) {}
bool operator==(const T_enTransferMode& rhs) const { return m_enTransferMode==rhs; }
bool operator!=(const T_enTransferMode& rhs) const { return m_enTransferMode!=rhs; }
bool operator==(const CTransferMode& rhs) const { return m_enTransferMode==rhs.AsEnum(); }
bool operator!=(const CTransferMode& rhs) const { return m_enTransferMode!=rhs.AsEnum(); }
CTransferMode& operator=(const CTransferMode& rhs) { m_enTransferMode = rhs.AsEnum(); return *this; }
T_enTransferMode AsEnum() const { return m_enTransferMode; }
static const CTransferMode Stream() { return tmStream; }
static const CTransferMode Block() { return tmBlock; }
static const CTransferMode Compressed() { return tmCompressed; }
private:
CTransferMode(T_enTransferMode enTransferMode) : m_enTransferMode(enTransferMode) {}
T_enTransferMode m_enTransferMode;
};
class CFirewallType;
typedef std::vector<CFirewallType> TFirewallTypeVector;
/// Firewall Type
class CFirewallType
{
public:
// don't change order of enumeration
enum T_enFirewallType {
ftNone, ftSiteHostName, ftUserAfterLogon, ftProxyOpen, ftTransparent,
ftUserWithNoLogon, ftUserFireIDatRemotehost, ftUserRemoteIDatRemoteHostFireID,
ftUserRemoteIDatFireIDatRemoteHost };
CFirewallType() : m_enFirewallType(ftNone) {}
CFirewallType(const CFirewallType& firewallType) :
m_enFirewallType(firewallType.AsEnum()) {}
bool operator==(const T_enFirewallType& rhs) const { return m_enFirewallType==rhs; }
bool operator!=(const T_enFirewallType& rhs) const { return m_enFirewallType!=rhs; }
bool operator==(const CFirewallType& rhs) const { return m_enFirewallType==rhs.AsEnum(); }
bool operator!=(const CFirewallType& rhs) const { return m_enFirewallType!=rhs.AsEnum(); }
CFirewallType& operator=(const CFirewallType& rhs) { m_enFirewallType = rhs.AsEnum(); return *this; }
T_enFirewallType AsEnum() const { return m_enFirewallType; }
tstring AsDisplayString() const;
tstring AsStorageString() const;
static void GetAllTypes(TFirewallTypeVector& vTypes);
static const CFirewallType None() { return ftNone; }
static const CFirewallType SiteHostName() { return ftSiteHostName; }
static const CFirewallType UserAfterLogon() { return ftUserAfterLogon; }
static const CFirewallType ProxyOpen() { return ftProxyOpen; }
static const CFirewallType Transparent() { return ftTransparent; }
static const CFirewallType UserWithNoLogon() { return ftUserWithNoLogon; }
static const CFirewallType UserFireIDatRemotehost() { return ftUserFireIDatRemotehost; }
static const CFirewallType UserRemoteIDatRemoteHostFireID() { return ftUserRemoteIDatRemoteHostFireID; }
static const CFirewallType UserRemoteIDatFireIDatRemoteHost() { return ftUserRemoteIDatFireIDatRemoteHost; }
private:
CFirewallType(T_enFirewallType enFirewallType) : m_enFirewallType(enFirewallType) {}
T_enFirewallType m_enFirewallType;
};
/// @brief Representation Type - 1st param (see CRepresentation)
class CType
{
public:
enum T_enType { tyASCII, tyEBCDIC, tyImage, tyLocalByte };
CType(const CType& type) :
m_enType(type.AsEnum()) {}
bool operator==(const T_enType& rhs) const { return m_enType==rhs; }
bool operator!=(const T_enType& rhs) const { return m_enType!=rhs; }
bool operator==(const CType& rhs) const { return m_enType==rhs.AsEnum(); }
bool operator!=(const CType& rhs) const { return m_enType!=rhs.AsEnum(); }
CType& operator=(const CType& rhs) { m_enType = rhs.AsEnum(); return *this; }
T_enType AsEnum() const { return m_enType; }
static const CType ASCII() { return tyASCII; }
static const CType EBCDIC() { return tyEBCDIC; }
static const CType Image() { return tyImage; }
static const CType LocalByte() { return tyLocalByte; }
private:
CType(T_enType enType) : m_enType(enType) {}
T_enType m_enType;
};
/// @brief Representation Type - 2nd param (see CRepresentation)
class CTypeFormat
{
public:
enum T_enTypeFormat { tfNonPrint, tfTelnetFormat, tfCarriageControl };
CTypeFormat(const CTypeFormat& typeFormat) :
m_enTypeFormat(typeFormat.AsEnum()) {}
bool operator==(const T_enTypeFormat& rhs) const { return m_enTypeFormat==rhs; }
bool operator!=(const T_enTypeFormat& rhs) const { return m_enTypeFormat!=rhs; }
bool operator==(const CTypeFormat& rhs) const { return m_enTypeFormat==rhs.AsEnum(); }
bool operator!=(const CTypeFormat& rhs) const { return m_enTypeFormat!=rhs.AsEnum(); }
CTypeFormat& operator=(const CTypeFormat& rhs) { m_enTypeFormat = rhs.AsEnum(); return *this; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -