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

📄 object.h

📁 pwlib源码库
💻 H
📖 第 1 页 / 共 5 页
字号:
    ) const { return Compare(obj) != EqualTo; }    /** Compare the two objects.           @return       TRUE if objects are less than.     */    bool operator<(      const PObject & obj   // Object to compare against.    ) const { return Compare(obj) == LessThan; }    /** Compare the two objects.           @return       TRUE if objects are greater than.     */    bool operator>(      const PObject & obj   // Object to compare against.    ) const { return Compare(obj) == GreaterThan; }    /** Compare the two objects.           @return       TRUE if objects are less than or equal.     */    bool operator<=(      const PObject & obj   // Object to compare against.    ) const { return Compare(obj) != GreaterThan; }    /** Compare the two objects.           @return       TRUE if objects are greater than or equal.     */    bool operator>=(      const PObject & obj   // Object to compare against.    ) const { return Compare(obj) != LessThan; }  //@}  /**@name I/O functions */  //@{    /** Output the contents of the object to the stream. The exact output is       dependent on the exact semantics of the descendent class. This is       primarily used by the standard #operator<<# function.       The default behaviour is to print the class name.     */    virtual void PrintOn(      ostream &strm   // Stream to print the object into.    ) const;    /** Input the contents of the object from the stream. The exact input is       dependent on the exact semantics of the descendent class. This is       primarily used by the standard #operator>># function.       The default behaviour is to do nothing.     */    virtual void ReadFrom(      istream &strm   // Stream to read the objects contents from.    );    /** Global function for using the standard << operator on objects descended       from PObject. This simply calls the objects #PrintOn()# function.              @return the #strm# parameter.     */    inline friend ostream & operator<<(      ostream &strm,       // Stream to print the object into.      const PObject & obj  // Object to print to the stream.    ) { obj.PrintOn(strm); return strm; }    /** Global function for using the standard >> operator on objects descended       from PObject. This simply calls the objects #ReadFrom()# function.       @return the #strm# parameter.     */    inline friend istream & operator>>(      istream &strm,   // Stream to read the objects contents from.      PObject & obj    // Object to read inormation into.    ) { obj.ReadFrom(strm); return strm; }  /**@name Miscellaneous functions */  //@{    /** Create a copy of the class on the heap. The exact semantics of the       descendent class determine what is required to make a duplicate of the       instance. Not all classes can even {\bf do} a clone operation.              The main user of the clone function is the #PDictionary# class as       it requires copies of the dictionary keys.       The default behaviour is for this function to assert.       @return       pointer to new copy of the class instance.     */    virtual PObject * Clone() const;    /** This function yields a hash value required by the #PDictionary#       class. A descendent class that is required to be the key of a dictionary       should override this function. The precise values returned is dependent       on the semantics of the class. For example, the #PString# class       overrides it to provide a hash function for distinguishing text strings.       The default behaviour is to return the value zero.       @return       hash function value for class instance.     */    virtual PINDEX HashFunction() const;  //@}};///////////////////////////////////////////////////////////////////////////////// Platform independent types// All these classes encapsulate primitive types such that they may be// transfered in a platform independent manner. In particular it is used to// do byte swapping for little endien and big endien processor architectures// as well as accommodating structure packing rules for memory structures.#define PANSI_CHAR 1#define PLITTLE_ENDIAN 2#define PBIG_ENDIAN 3#if 0class PStandardType/* Encapsulate a standard 8 bit character into a portable format. This would   rarely need to do translation, only if the target platform uses EBCDIC   would it do anything.   The platform independent form here is always 8 bit ANSI. */{  public:    PStandardType(      type newVal   // Value to initialise data in platform dependent form.    ) { data = newVal; }    /* Create a new instance of the platform independent type using platform       dependent data, or platform independent streams.     */    operator type() { return data; }    /* Get the platform dependent value for the type.       @return       data for instance.     */    friend ostream & operator<<(ostream & strm, const PStandardType & val)      { return strm << (type)val; }    /* Output the platform dependent value for the type to the stream.       @return       the stream output was made to.     */    friend istream & operator>>(istream & strm, PStandardType & val)      { type data; strm >> data; val = PStandardType(data); return strm; }    /* Input the platform dependent value for the type from the stream.       @return       the stream input was made from.     */  private:    type data;};#endif#define PI_SAME(name, type) \  struct name { \    name() { } \    name(type value) { data = value; } \    name(const name & value) { data = value.data; } \    name & operator =(type value) { data = value; return *this; } \    name & operator =(const name & value) { data = value.data; return *this; } \    operator type() const { return data; } \    friend ostream & operator<<(ostream & s, const name & v) { return s << v.data; } \    friend istream & operator>>(istream & s, name & v) { return s >> v.data; } \    private: type data; \  }#define PI_LOOP(src, dst) \    BYTE *s = ((BYTE *)&src)+sizeof(src); BYTE *d = (BYTE *)&dst; \    while (s != (BYTE *)&src) *d++ = *--s;#define PI_DIFF(name, type) \  struct name { \    name() { } \    name(type value) { operator=(value); } \    name(const name & value) { data = value.data; } \    name & operator =(type value) { PI_LOOP(value, data); return *this; } \    name & operator =(const name & value) { data = value.data; return *this; } \    operator type() const { type value; PI_LOOP(data, value); return value; } \    friend ostream & operator<<(ostream & s, const name & value) { return s << (type)value; } \    friend istream & operator>>(istream & s, name & v) { type val; s >> val; v = val; return s; } \    private: type data; \  }#ifndef PCHAR8#define PCHAR8 PANSI_CHAR#endif#if PCHAR8==PANSI_CHARPI_SAME(PChar8, char);#endifPI_SAME(PInt8, signed char);PI_SAME(PUInt8, unsigned char);#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PInt16l, PInt16);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PInt16l, PInt16);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PInt16b, PInt16);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PInt16b, PInt16);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PUInt16l, WORD);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PUInt16l, WORD);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PUInt16b, WORD);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PUInt16b, WORD);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PInt32l, PInt32);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PInt32l, PInt32);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PInt32b, PInt32);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PInt32b, PInt32);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PUInt32l, DWORD);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PUInt32l, DWORD);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PUInt32b, DWORD);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PUInt32b, DWORD);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PInt64l, PInt64);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PInt64l, PInt64);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PInt64b, PInt64);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PInt64b, PInt64);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PUInt64l, PUInt64);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PUInt64l, PUInt64);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PUInt64b, PUInt64);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PUInt64b, PUInt64);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PFloat32l, float);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PFloat32l, float);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PFloat32b, float);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PFloat32b, float);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PFloat64l, double);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PFloat64l, double);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PFloat64b, double);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PFloat64b, double);#endif#ifndef NO_LONG_DOUBLE // stupid OSX compiler#if PBYTE_ORDER==PLITTLE_ENDIANPI_SAME(PFloat80l, long double);#elif PBYTE_ORDER==PBIG_ENDIANPI_DIFF(PFloat80l, long double);#endif#if PBYTE_ORDER==PLITTLE_ENDIANPI_DIFF(PFloat80b, long double);#elif PBYTE_ORDER==PBIG_ENDIANPI_SAME(PFloat80b, long double);#endif#endif#undef PI_LOOP#undef PI_SAME#undef PI_DIFF///////////////////////////////////////////////////////////////////////////////// Miscellaneous/*$MACRO PARRAYSIZE(array)   This macro is used to calculate the number of array elements in a static   array. */#define PARRAYSIZE(array) ((PINDEX)(sizeof(array)/sizeof(array[0])))/*$MACRO PMIN(v1, v2)   This macro is used to calculate the minimum of two values. As this is a   macro the expression in #v1# or #v2# is executed   twice so extreme care should be made in its use. */#define PMIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))/*$MACRO PMAX(v1, v2)   This macro is used to calculate the maximum of two values. As this is a   macro the expression in #v1# or #v2# is executed   twice so extreme care should be made in its use. */#define PMAX(v1, v2) ((v1) > (v2) ? (v1) : (v2))/*$MACRO PABS(val)   This macro is used to calculate an absolute value. As this is a macro the   expression in #val# is executed twice so extreme care should be   made in its use. */#define PABS(v) ((v) < 0 ? -(v) : (v))#endif // _POBJECT_H// End Of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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