enum.h

来自「QT4的utils库源码包.解压后运行./configure配置,然后make.」· C头文件 代码 · 共 67 行

H
67
字号
#ifndef OOENUM_H#define OOENUM_H#include "myexport.h"#include <QStringList>#include <QTextStream>#include <QMap>typedef QMap<QString, int> NameMap;//start/** @short An object-oriented enumerator class which  uses strings instead of compiler symbols,  and provides bidirectional mapping between  QStrings and int values. No compiler symbols  are introduced.  */class UTILS_EXPORT Enum {public:    Enum(int enumval = 0);    virtual ~Enum();    /** Converts from the int value to a String */    virtual QString toString() const;    /** Converts from a string to the internal enum value.          returns false if an invalid string is passed in. */    virtual bool fromString(QString str) =0;    virtual operator int() const ;    bool operator=(int other);    bool operator=(QString other);        bool operator==(const Enum& other) const {        return m_Val == other.m_Val;    }            virtual QStringList names() const = 0;protected:    //end    /** Adds symbols to the map with enum values starting           at 0         @param nameMap - the map containing strings to numbers         @param nameList - a string list of names to add to the map         @param initialized - if true, do nothing (to avoid repeat-redundant calls                  - if false, set to true after initializing.    */    static NameMap& initMap(NameMap& nameMap,                            QStringList nameList, bool  & initialized, int startIndex = 0);    //start    int m_Val;};/* optional */QTextStream& operator<<(QTextStream& ts, const Enum& pref);//end#endif 

⌨️ 快捷键说明

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