⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warcollector.h

📁 ftpserver very good sample
💻 H
字号:
/** @name Base class for streaming input * * #include "WarCollector.h" <BR> * * @doc This class is used as a base-class as a * string class substitute for controlled, streaming * input with various datatypes *   * @see something */#ifndef WAR_COLLECTOR_H#define WAR_COLLECTOR_H/* SYSTEM INCLUDES */#ifndef WAR_STDLIB_H_INCLUDED#   include <stdlib.h>#endif#ifndef WAR_CTYPE_H_INCLUDED#   define WAR_CTYPE_H_INCLUDED#   include <ctype.h>#endif#ifndef WAR_VECTOR_INCLUDED#   include <vector>#endif#ifndef WAR_STRING_INCLUDED#   include <string>#endif#ifndef WAR_MALLOC_H_INCLUDED# define WAR_MALLOC_H_INCLUDED#   include <malloc.h>#endif#ifndef WAR_ASSERT_H_INCLUDED#   define WAR_ASSERT_H_INCLUDED#   include <assert.h>#endif/* PROJECT INCLUDES */#ifndef WAR_TYPES_H#   include "WarTypes.h"#endif#ifndef WAR_ITOA_H#   include "WarItoa.h"#endif#ifndef WAR_ERROR_H#   include "WarError.h"#endif#ifndef WAR_EXCEPTION_H#   include "WarException.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */enum war_endl_e {    /** */    war_endl = '\n'};#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplustemplate <class charT=char>class WarCollector {public:    typedef charT type_t;    enum SecurityModeE    {        SM_NONE,        SM_ERASE    };    // LIFECYCLE        /**    * Default constructor.    */    WarCollector<charT>(const SecurityModeE securityMode = SM_NONE);        /**    * Copy constructor.    *    * @param from The value to copy to this object.    */    template <class T>    WarCollector<charT>(const T& from,        const SecurityModeE securityMode = SM_NONE)        : mSecurityMode(securityMode)    {        *this << from;    }        /**    * Destructor.    */    virtual ~WarCollector<charT>(void);        // OPERATORS    /** Assignment operator */       /**    * Assignment operator.    *    * @param from The value to assign to this object.    *    * @return A reference to this object.    */    template <class T>    WarCollector<charT>& operator =        (WarCollector<T>& from)    {        Reset();        return *this << from;    }    /**    * Assignment operator.    *    * @param from The value to assign to this object.    *    * @return A reference to this object.    */    WarCollector<charT>& operator=(std::string& from);        /**    * Assignment operator.    *    * @param from The value to assign to this object.    *    * @return A reference to this object.    */    WarCollector<charT>& operator=(war_ccstr_t from);    bool operator == (const charT *strName);        // OPERATIONS    void ExpandNewline();            /**    * Reset the object. The string is emptied.    *    * @param from The value to assign to this object.    *    * @return A reference to this object.    */    void Reset();        // ACCESS    const std::basic_string<charT>& GetValue() const;        // INQUIRY    /**    * Add a value    *    * Usually called from within "<<" operators    *    * @param from The value to add to this object.    *    * @return A reference to this object.    */        WarCollector<charT>& Add(const std::basic_string<charT>& from);    WarCollector<charT>& Add(const charT * from);    WarCollector<charT>& Add(const charT from);    /**    * Add an integer value    *    * Usually called from within "<<" operators    *    * @param from The value to add to this object.    *    * @return A reference to this object.    */    WarCollector<charT>& AddInt16(const war_int16_t& from);    WarCollector<charT>& AddInt32(const war_int32_t& from);    WarCollector<charT>& AddInt64(const war_int64_t& from);    WarCollector<charT>& AddInt16u(const war_uint16_t& from);    WarCollector<charT>& AddInt32u(const war_uint32_t& from);    WarCollector<charT>& AddInt64u(const war_uint64_t& from);    /**    * Add a newline    *    * Usually called from within "<<" operators    *    * @param from The value to add to this object.    *    * @return A reference to this object.    */    virtual WarCollector<charT>& AddEndln(const war_endl_e& from);     /**    * Add an error    *    * Usually called from within "<<" operators    *    * @param Ignored in the default implementation.    *    * @return A reference to this object.    */    virtual WarCollector<charT>& AddError(const WarError& from);    /** Generic handler to enumerations       * in derived classes      */    virtual WarCollector<charT>& AddEnumValue1(int enumValue)        throw(WarException);    virtual WarCollector<charT>& AddEnumValue2(int enumValue)        throw(WarException);    virtual WarCollector<charT>& AddEnumValue3(int enumValue)        throw(WarException);    virtual WarCollector<charT>& AddEnumValue4(int enumValue)        throw(WarException);    bool MustErase() const;    int Strnicmp(const char * right, size_t length) const;    int Strnicmp(const wchar_t * right, size_t length) const;    int Stricmp(const char * right) const;    int Stricmp(const wchar_t * right) const;    int Strcmp(const char * right) const;    int Strcmp(const wchar_t * right) const;    int Strncmp(const wchar_t * right, const size_t length) const;        std::basic_string<charT> mString;private:    SecurityModeE mSecurityMode; // Erase buffer when finished, used for password buffers};/* INLINE METHODS *//* EXTERNAL REFERENCES *//** */WarCollector<char>& operator << (WarCollector<char>& c,                            const struct in_addr& val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const char val);/** */WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const wchar_t val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const wchar_t val);WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const char val);/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_int16_t val);/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_int32_t val);#if defined(NEED_TYPE_TEMPLATE) || defined(_MSC_VER)template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const int val);#endif/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_int64_t& val);/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_uint16_t val);#if defined(NEED_TYPE_TEMPLATE) || defined(_MSC_VER)template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const unsigned val);#endiftemplate <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_uint32_t val);/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_uint64_t& val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const war_ccstr_t val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const war_cwstr_t val);/** */WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const war_ccstr_t val);/** */WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const war_cwstr_t val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const std::string& val);/** */WarCollector<char>& operator << (WarCollector<char>& c,                            const std::wstring& val);/** */WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const std::string& val);/** */WarCollector<wchar_t>& operator << (WarCollector<wchar_t>& c,                            const std::wstring& val);/** */template <class charT, class collT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const WarCollector<collT>& val);template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const war_endl_e& val);/** */template <class charT>WarCollector<charT>& operator << (WarCollector<charT>& c,                            const WarError& val);#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* _WAR_COLLECTOR_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -