ArnLib  4.0.x
Active Registry Network
Arn::EnumTxt Class Reference

Class Enum text. More...

#include <MQFlags.hpp>

Classes

struct  IncludeMode
 

Public Member Functions

 EnumTxt (const QMetaObject *metaObj, bool isFlag, const _InitEnumTxt *initTxt, const _InitSubEnum *initSubEnum, const char *name)
 
 EnumTxt (bool isFlag=false, const QString &name=QString())
 Create a dynamic runtime handled EnumTxt. More...
 
 ~EnumTxt ()
 
void setTxtRef (const char *txt, int enumVal, quint16 nameSpace)
 
void setTxt (const char *txt, int enumVal, quint16 nameSpace)
 Set an additional text for an enum val in a namespace. More...
 
const char * getTxt (int enumVal, quint16 nameSpace=0, bool *isFound=arnNullptr) const
 Returns the text for a enum value in a namespace. More...
 
void setTxtString (const QString &txt, int enumVal, quint16 nameSpace)
 Set an additional text for an enum val in a namespace. More...
 
QString getTxtString (int enumVal, quint16 nameSpace=0, bool *isFound=arnNullptr) const
 Returns the text for a enum value in a namespace. More...
 
int getEnumVal (const char *txt, int defaultVal=0, quint16 nameSpace=0, bool *isFound=arnNullptr) const
 Returns the enum value for a text in a namespace. More...
 
int getEnumVal (const QString &txt, int defaultVal=0, quint16 nameSpace=0, bool *isFound=arnNullptr) const
 Returns the enum value for a text in a namespace. More...
 
bool getSubEnumVal (const char *txt, int &subEnumVal, uint &bitMask, quint16 nameSpace=0) const
 Returns the shifted enum value and the mask for a subEnum text in a namespace. More...
 
bool getSubEnumVal (const QString &txt, int &subEnumVal, uint &bitMask, quint16 nameSpace=0) const
 Returns the shifted enum value and the mask for a subEnum text in a namespace. More...
 
void addFlagsTo (Arn::XStringMap &xsm, const IncludeMode &incMode, quint16 nameSpace=0, bool neverHumanize=false) const
 Adds enum flags to a XStringMap. More...
 
void addSubEnumTo (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 Adds sub enum flags to a XStringMap. More...
 
void addBitSetTo (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 Adds bit set for enum flags to a XStringMap. More...
 
void addBitSet (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 
QString getBitSet (quint16 nameSpace=0, bool neverHumanize=false) const
 returns the bit set string for enum flags More...
 
void addSubEnumPlainTo (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 Adds all sub enum plain and shifted to a XStringMap. More...
 
QString flagsToString (int val, quint16 nameSpace=0) const
 returns text string for enum flags More...
 
QStringList flagsToStringList (int val, quint16 nameSpace=0) const
 returns string list for enum flags More...
 
int flagsFromString (const QString &flagString, quint16 nameSpace=0)
 returns enum flags from string More...
 
int flagsFromStringList (const QStringList &flagStrings, quint16 nameSpace=0)
 returns enum flags from string list More...
 
void addEnumSetTo (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 Adds enum set to a XStringMap. More...
 
void addEnumSet (Arn::XStringMap &xsm, quint16 nameSpace=0, bool neverHumanize=false) const
 
QString getEnumSet (quint16 nameSpace=0, bool neverHumanize=false) const
 returns the enum set string More...
 
QStringList getBasicTextList (quint16 nameSpace=0, bool neverHumanize=false) const
 returns a string list containing the most basic texts More...
 
void addSubEnum (const EnumTxt &subEnum, uint bitMask, uint factor)
 Adds an other EnumTxt as a subEnum to this flag EnumTxt. More...
 
const char * name () const
 returns the name of the enum (class) More...
 
int enumCount () const
 returns number of enumerators in the enum (class) More...
 
void setMissingTxt (quint16 toNameSpace, quint16 fromNameSpace=0, bool neverHumanize=false)
 Copies missing enum texts from one namespace to another. More...
 
bool isFlag () const
 Returns true if this is a flag usage. More...
 
void clear ()
 Clear this dynamic instance to its starting state. More...
 
bool loadEnumSet (const Arn::XStringMap &xsm, const QString &name=QString())
 Loads the instance by an enum set XStringMap. More...
 
bool loadEnumSet (const QString &xstr, const QString &name=QString())
 Loads the instance by an enum set XString. More...
 
bool loadBitSet (const Arn::XStringMap &xsm, const QString &name=QString())
 Loads the instance by an bit set (flags) XStringMap. More...
 
bool loadBitSet (const QString &xstr, const QString &name=QString())
 Loads the instance by an bit set (flags) XString. More...
 
int subEnumCount () const
 Returns number of subEnums in this bitSet (class) More...
 
QString subEnumNameAt (int idx, quint16 nameSpace=0) const
 Returns the name of a SubEnum. More...
 
bool subEnumPropAt (int idx, uint &bitMask, uchar &bitPos) const
 Returns the properties of a SubEnum. More...
 
const EnumTxtsubEnumAt (int idx) const
 Returns a pointer to a SubEnum. More...
 

Static Public Member Functions

static QString humanize (const QString &txt)
 returns the humanized text More...
 
static QByteArray numToStr (uint num)
 
static uint strToNum (const QByteArray &str, bool *isOk=arnNullptr)
 
static uchar strToBitpos (const QByteArray &str, bool *isOk=arnNullptr)
 

Detailed Description

Class Enum text.

Example usage

class AllowLevelT {
Q_GADGET
Q_ENUMS(E)
public:
enum E {
Low = 0,
Mid,
High
};
MQ_DECLARE_ENUMTXT( AllowLevelT)
};
class AllowClassT {
Q_GADGET
Q_ENUMS(E)
public:
enum E {
None = 0x00,
Read = 0x01,
AllowLevB0 = 0x02,
AllowLevB1 = 0x04,
Create = 0x08,
Delete = 0x10,
AllowLev = AllowLevB0 | AllowLevB1,
All = 0xff
};
MQ_DECLARE_FLAGSTXT( AllowClassT)
MQ_SUBETXT_ADD_RELDEF( AllowLevelT, AllowLev, AllowLevB0)
)
MQ_SUBETXT_ADD_RELOP( AllowLevelT, AllowLev, AllowLevB0)
enum NS {NsEnum, NsHuman};
{ NsHuman, Read, "Allow Read" },
{ NsHuman, Delete, "Allow Delete" }
)
};
class ConnectStatT {
Q_GADGET
Q_ENUMS(E)
public:
enum E {
Init = 0,
Connected,
Error,
Disconnected,
TriedAll
};
MQ_DECLARE_ENUMTXT( ConnectStatT)
enum NS {NsEnum, NsHuman};
{ NsHuman, Init, "Initialized" },
{ NsHuman, Error, "Connect error" },
{ NsHuman, MQ_NSTXT_FILL_MISSING_FROM( NsEnum) }
)
};

Definition at line 212 of file MQFlags.hpp.

Constructor & Destructor Documentation

◆ EnumTxt() [1/2]

Arn::EnumTxt::EnumTxt ( const QMetaObject *  metaObj,
bool  isFlag,
const _InitEnumTxt initTxt,
const _InitSubEnum initSubEnum,
const char *  name 
)

Definition at line 63 of file MQFlags.cpp.

◆ EnumTxt() [2/2]

Arn::EnumTxt::EnumTxt ( bool  isFlag = false,
const QString &  name = QString() 
)
explicit

Create a dynamic runtime handled EnumTxt.

This is used for handling general Enums that is not statically assigned via QMetaObject. Example usage

Arn::EnumTxt myFlags( true, "MyFlags");
myFlags.loadBitSet( "B0=Flag1 B5=Flag2 0=None 0x21=FlagAll");
Parameters
[in]isFlagis true when using Flags (bitSet), otherwise use plain Enums.
[in]nameis the name of these Enums / Flags.

Definition at line 77 of file MQFlags.cpp.

◆ ~EnumTxt()

Arn::EnumTxt::~EnumTxt ( )

Definition at line 87 of file MQFlags.cpp.

Member Function Documentation

◆ addBitSet()

void Arn::EnumTxt::addBitSet ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const
inline

Definition at line 399 of file MQFlags.hpp.

◆ addBitSetTo()

void Arn::EnumTxt::addBitSetTo ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

Adds bit set for enum flags to a XStringMap.

Example

xsm.add("T", "Test");
AllowClassT::txt().addBitSetTo( xsm, 0, true);

wiil give xsm containing: T=Test B0=Read B3=Create B4=Delete 0=None 0xff=All SE6:B1=AllowLev E0=Low E1=Mid E2=High

Parameters
[out]xsmis the XStringMap to be added to.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
addFlagsTo()
addSubEnumTo()
humanize()

Definition at line 262 of file MQFlags.cpp.

◆ addEnumSet()

void Arn::EnumTxt::addEnumSet ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const
inline

Definition at line 503 of file MQFlags.hpp.

◆ addEnumSetTo()

void Arn::EnumTxt::addEnumSetTo ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

Adds enum set to a XStringMap.

Example

xsm.add("T", "Test");
ConnectStatT::txt().addEnumSetTo( xsm);

wiil give xsm containing: T=Test 0=Init 1=Connected 2=Error 3=Disconnected 4=Tried all

Parameters
[out]xsmis the XStringMap to be added to.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
getEnumSet()
humanize()

Definition at line 406 of file MQFlags.cpp.

◆ addFlagsTo()

void Arn::EnumTxt::addFlagsTo ( Arn::XStringMap xsm,
const IncludeMode incMode,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

Adds enum flags to a XStringMap.

Example

xsm.add("T", "Test");
AllowClassT::txt().addFlagsTo( xsm, IncludeMode::OnlySingle1Bits, 0, true);

wiil give xsm containing: T=Test B0=Read B3=Create B4=Delete

Parameters
[out]xsmis the XStringMap to be added to.
[in]incModespecifies what to include (SingleBits / MultiBits / SubEnumBits / "Any").
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
addBitSetTo()
humanize()

Definition at line 193 of file MQFlags.cpp.

◆ addSubEnum()

void Arn::EnumTxt::addSubEnum ( const EnumTxt subEnum,
uint  bitMask,
uint  factor 
)

Adds an other EnumTxt as a subEnum to this flag EnumTxt.

Example

// In class usage example, following is done behind the scene
AllowClassT::txt().addSubEnum( AlowLevelT::txt(), AllowClassT::AllowLev, AllowClassT::AllowLevB0);
Parameters
[in]subEnumis the other EnumTxt to be included as a subEnum.
[in]bitMaskis used for selecting the subEnum among the flags.
[in]factoris multiplying the base enum before it is masked in as subEnum to flags.
Returns
the flags enum value.

Definition at line 451 of file MQFlags.cpp.

◆ addSubEnumPlainTo()

void Arn::EnumTxt::addSubEnumPlainTo ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

Adds all sub enum plain and shifted to a XStringMap.

Also adds bitmask and name of the sub enum All enums must have unique names Example

xsm.add("T", "Test");
AllowClassT::txt().addSubEnumPlainTo( xsm, 0, true);

wiil give xsm containing: T=Test 6=AllowLev 0=Low 2=Mid 4=High

Parameters
[out]xsmis the XStringMap to be added to.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
addBitSetTo()
humanize()

Definition at line 281 of file MQFlags.cpp.

◆ addSubEnumTo()

void Arn::EnumTxt::addSubEnumTo ( Arn::XStringMap xsm,
quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

Adds sub enum flags to a XStringMap.

Example

xsm.add("T", "Test");
AllowClassT::txt().addSubEnumTo( xsm, 0, true);

wiil give xsm containing: T=Test SE6:B1=AllowLev E0=Low E1=Mid E2=High

Parameters
[out]xsmis the XStringMap to be added to.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
addBitSetTo()
humanize()

Definition at line 236 of file MQFlags.cpp.

◆ clear()

void Arn::EnumTxt::clear ( )

Clear this dynamic instance to its starting state.

Clear will do nothing if this instance was created staticly with a QMetaObject.

Definition at line 574 of file MQFlags.cpp.

◆ enumCount()

int Arn::EnumTxt::enumCount ( ) const

returns number of enumerators in the enum (class)

Example

qDebug() << ConnectStatT::txt().enumCount();

wiil print: 5

Returns
the count of enumerators.

Definition at line 736 of file MQFlags.cpp.

◆ flagsFromString()

int Arn::EnumTxt::flagsFromString ( const QString &  flagString,
quint16  nameSpace = 0 
)

returns enum flags from string

Example

QString flagString = "Create | Delete | Low";
int val = AllowClassT::txt().flagsFromString( flagString);

wiil give val: 0x18 (0x08 + 0x10 + 0x00)

Parameters
[in]flagStringis the flags text.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Returns
the flags enum value.
See also
flagsFromStringList()

Definition at line 354 of file MQFlags.cpp.

◆ flagsFromStringList()

int Arn::EnumTxt::flagsFromStringList ( const QStringList &  flagStrings,
quint16  nameSpace = 0 
)

returns enum flags from string list

Example

QStringList flagStrings;
flagStrings << "Create" << "Delete" << "High";
int val = AllowClassT::txt().flagsFromString( flagStrings);

wiil give val: 0x1c (0x08 + 0x10 + 0x04)

Parameters
[in]flagStringsis the flags text list.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Returns
the flags enum value.
See also
flagsFromString()

Definition at line 362 of file MQFlags.cpp.

◆ flagsToString()

QString Arn::EnumTxt::flagsToString ( int  val,
quint16  nameSpace = 0 
) const

returns text string for enum flags

Example

AllowClassT allow;
allow = allow.Create | allow.Delete;
allow.setSubEnum( AllowLevelT::Mid);
qDebug() << allow.txt().flagsToString( allow);

wiil print: "Create | Delete | Mid"

Parameters
[in]valis the flags enum value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Returns
the flags text string.
See also
flagsToStringList()

Definition at line 305 of file MQFlags.cpp.

◆ flagsToStringList()

QStringList Arn::EnumTxt::flagsToStringList ( int  val,
quint16  nameSpace = 0 
) const

returns string list for enum flags

Example

AllowClassT allow;
allow = allow.Create | allow.Delete;
allow.setSubEnum( AllowLevelT::Low);
QStringList allowList = allow.txt().flagsToStringList( allow);

wiil give allowList containing: "Create", "Delete", "Low"

Parameters
[in]valis the flags enum value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Returns
the flags string list.
See also
flagsToString()

Definition at line 313 of file MQFlags.cpp.

◆ getBasicTextList()

QStringList Arn::EnumTxt::getBasicTextList ( quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

returns a string list containing the most basic texts

For a EnumSet this is the complete text list. For a BitSet this is the texts for all the single 1-bits except those used for SubEnums. Example

qDebug() << AllowClassT::txt().getBasicTextList( 0, true);

wiil print: "Read" "Create" "Delete"

Parameters
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
Returns
the basic string list.
See also
humanize()

Definition at line 437 of file MQFlags.cpp.

◆ getBitSet()

QString Arn::EnumTxt::getBitSet ( quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

returns the bit set string for enum flags

Example

qDebug() << AllowClassT::txt().getBitSet();

wiil print: "B0=Read B3=Create B4=Delete 0=None 0xff=All SE6:B1=AllowLev E0=Low E1=Mid E2=High"

Parameters
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
Returns
the bit set string.
See also
humanize()

Definition at line 271 of file MQFlags.cpp.

◆ getEnumSet()

QString Arn::EnumTxt::getEnumSet ( quint16  nameSpace = 0,
bool  neverHumanize = false 
) const

returns the enum set string

Example

qDebug() << ConnectStatT::txt().getEnumSet();

wiil print: "0=Init 1=Connected 2=Error 3=Disconnected 4=Tried_all"

Parameters
[in]nameSpaceis the usage set for this enum, e.g human readable.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
Returns
the enum set string.
See also
humanize()

Definition at line 429 of file MQFlags.cpp.

◆ getEnumVal() [1/2]

int Arn::EnumTxt::getEnumVal ( const char *  txt,
int  defaultVal = 0,
quint16  nameSpace = 0,
bool *  isFound = arnNullptr 
) const

Returns the enum value for a text in a namespace.

Parameters
[in]txtis the enum text.
[in]defaultValis the returned value when txt is not found.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[out]isFoundreturns status when pointer is none null.
Returns
the enum value.
See also
setTxt();

Definition at line 142 of file MQFlags.cpp.

◆ getEnumVal() [2/2]

int Arn::EnumTxt::getEnumVal ( const QString &  txt,
int  defaultVal = 0,
quint16  nameSpace = 0,
bool *  isFound = arnNullptr 
) const

Returns the enum value for a text in a namespace.

Parameters
[in]txtis the enum text.
[in]defaultValis the returned value when txt is not found.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[out]isFoundreturns status when pointer is none null.
Returns
the enum value.
See also
setTxt();
setTxtString();

Definition at line 163 of file MQFlags.cpp.

◆ getSubEnumVal() [1/2]

bool Arn::EnumTxt::getSubEnumVal ( const char *  txt,
int &  subEnumVal,
uint &  bitMask,
quint16  nameSpace = 0 
) const

Returns the shifted enum value and the mask for a subEnum text in a namespace.

The enum value returned is shifted (with factor) to directly fit the flags enum. Example usage

int subEnumVal;
uint bitMask;
AllowClassT::txt().getSubEnumVal( "Mid", subEnumVal, bitMask);
qDebug() << subEnumVal << bitMask

wiil print: 2 and 6

Parameters
[in]txtis the subEnum text.
[out]subEnumValis the returned shifted value when txt is found as a subEnum.
[out]bitMaskis the returned value when txt is found as a subEnum.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Return values
istrue when txt is found as a subEnum.
See also
setTxt();
addSubEnum();

Definition at line 169 of file MQFlags.cpp.

◆ getSubEnumVal() [2/2]

bool Arn::EnumTxt::getSubEnumVal ( const QString &  txt,
int &  subEnumVal,
uint &  bitMask,
quint16  nameSpace = 0 
) const

Returns the shifted enum value and the mask for a subEnum text in a namespace.

The enum value returned is shifted (with factor) to directly fit the flags enum. Example usage

int subEnumVal;
uint bitMask;
AllowClassT::txt().getSubEnumVal( "High", subEnumVal, bitMask);
qDebug() << subEnumVal << bitMask

wiil print: 4 and 6

Parameters
[in]txtis the subEnum text.
[out]subEnumValis the returned shifted value when txt is found as a subEnum.
[out]bitMaskis the returned value when txt is found as a subEnum.
[in]nameSpaceis the usage set for this enum, e.g human readable.
Return values
istrue when txt is found as a subEnum.
See also
setTxtString();
addSubEnum();

Definition at line 187 of file MQFlags.cpp.

◆ getTxt()

const char * Arn::EnumTxt::getTxt ( int  enumVal,
quint16  nameSpace = 0,
bool *  isFound = arnNullptr 
) const

Returns the text for a enum value in a namespace.

Parameters
[in]enumValis the referenced value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[out]isFoundreturns status when pointer is none null.
Returns
the enum text.
See also
setTxt();

Definition at line 121 of file MQFlags.cpp.

◆ getTxtString()

QString Arn::EnumTxt::getTxtString ( int  enumVal,
quint16  nameSpace = 0,
bool *  isFound = arnNullptr 
) const

Returns the text for a enum value in a namespace.

Parameters
[in]enumValis the referenced value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
[out]isFoundreturns status when pointer is none null.
Returns
the enum text.
See also
setTxt();
setTxtString();

Definition at line 136 of file MQFlags.cpp.

◆ humanize()

QString Arn::EnumTxt::humanize ( const QString &  txt)
static

returns the humanized text

The input text can be Chamel-case or '_' word separeted. First output char will always be upper case and the following chars will always be lower case.

Example output

"MySimpelCase" ==> "My simpel case"
"My_Simpel_case" ==> "My simpel case"
"count123ms" ==> "Count 123 ms"
"DDTIsBad" ==> "DDT is bad"
Parameters
[in]txtis the text to be humanized.
Returns
the humanized text.

Definition at line 497 of file MQFlags.cpp.

◆ isFlag()

bool Arn::EnumTxt::isFlag ( ) const

Returns true if this is a flag usage.

Return values
istrue when this is a flag, false when plain enum.

Definition at line 568 of file MQFlags.cpp.

◆ loadBitSet() [1/2]

bool Arn::EnumTxt::loadBitSet ( const Arn::XStringMap xsm,
const QString &  name = QString() 
)

Loads the instance by an bit set (flags) XStringMap.

Example output

Arn::XStringMap xsm( "B0=Read B3=Create 0=None SE6:B1=AllowLev E0=Low E1=Mid E2=High");
Arn::EnumTxt myFlags;
myFlags.loadBitSet( xsm, "MyFlags");
Parameters
[in]xsmis the XStringMap containing the flags representation.
[in]nameis the name of this flag collection.
Return values
returnstrue if successful.

Definition at line 625 of file MQFlags.cpp.

◆ loadBitSet() [2/2]

bool Arn::EnumTxt::loadBitSet ( const QString &  xstr,
const QString &  name = QString() 
)

Loads the instance by an bit set (flags) XString.

Example output

QString xstr( "B0=Read B3=Create 0=None SE6:B1=AllowLev E0=Low E1=Mid E2=High");
Arn::EnumTxt myFlags;
myFlags.loadBitSet( xstr, "MyFlags");
Parameters
[in]xstris the XString containing the flags representation.
[in]nameis the name of this flag collection.
Return values
returnstrue if successful.

Definition at line 689 of file MQFlags.cpp.

◆ loadEnumSet() [1/2]

bool Arn::EnumTxt::loadEnumSet ( const Arn::XStringMap xsm,
const QString &  name = QString() 
)

Loads the instance by an enum set XStringMap.

Example output

Arn::XStringMap xsm( "0=Arn 1=Is 0x2=Great");
Arn::EnumTxt myEnum;
myEnum.loadEnumSet( xsm, "MyEnum");
Parameters
[in]xsmis the XStringMap containing the enum representation.
[in]nameis the name of this enum collection.
Return values
returnstrue if successful.

Definition at line 599 of file MQFlags.cpp.

◆ loadEnumSet() [2/2]

bool Arn::EnumTxt::loadEnumSet ( const QString &  xstr,
const QString &  name = QString() 
)

Loads the instance by an enum set XString.

Example output

QString xstr( "0=Arn 0x1=Is 2=Great");
Arn::EnumTxt myEnum;
myEnum.loadEnumSet( xstr, "MyEnum");
Parameters
[in]xstris the XString containing the enum representation.
[in]nameis the name of this enum collection.
Return values
returnstrue if successful.

Definition at line 619 of file MQFlags.cpp.

◆ name()

const char * Arn::EnumTxt::name ( ) const

returns the name of the enum (class)

Example

qDebug() << ConnectStatT::txt().name();

wiil print: "ConnectStatT"

Returns
the enum (class) name.

Definition at line 730 of file MQFlags.cpp.

◆ numToStr()

QByteArray Arn::EnumTxt::numToStr ( uint  num)
static

Definition at line 745 of file MQFlags.cpp.

◆ setMissingTxt()

void Arn::EnumTxt::setMissingTxt ( quint16  toNameSpace,
quint16  fromNameSpace = 0,
bool  neverHumanize = false 
)

Copies missing enum texts from one namespace to another.

The standard 0 namespace contains all enum texts as defined and can not be altered. All the other wanted namespaces can have customized enum texts, but then there can be enum values without a text in such namespace. This function can be used to fill in those missing texts from another namespace, which typically is 0 as it contains all texts.

Parameters
[in]toNameSpaceis the altered one. Can not be 0.
[in]fromNameSpaceis the one to copy from.
[in]neverHumanizeif true never applies the enum text humanize algorithm.
See also
humanize()

Definition at line 469 of file MQFlags.cpp.

◆ setTxt()

void Arn::EnumTxt::setTxt ( const char *  txt,
int  enumVal,
quint16  nameSpace 
)

Set an additional text for an enum val in a namespace.

The namespace with index 0 is the standard namespace that automatically gets its texts from the definition of the enum.

Example usage

AllowClassT allow;
allow.txt().setTxt("Test - Create", allow.Create, AllowClassT::NsHuman);
allow = allow.Create;
qDebug() << allow.toString() << allow.toString( AllowClassT::NsHuman)

wiil print: "Create" and "Test - Create"

Parameters
[in]txtis the new enum text.
[in]enumValis the referenced value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
See also
getTxt();

Definition at line 107 of file MQFlags.cpp.

◆ setTxtRef()

void Arn::EnumTxt::setTxtRef ( const char *  txt,
int  enumVal,
quint16  nameSpace 
)

Definition at line 100 of file MQFlags.cpp.

◆ setTxtString()

void Arn::EnumTxt::setTxtString ( const QString &  txt,
int  enumVal,
quint16  nameSpace 
)

Set an additional text for an enum val in a namespace.

Parameters
[in]txtis the new enum text.
[in]enumValis the referenced value.
[in]nameSpaceis the usage set for this enum, e.g human readable.
See also
setTxt();
getTxtString();

Definition at line 130 of file MQFlags.cpp.

◆ strToBitpos()

uchar Arn::EnumTxt::strToBitpos ( const QByteArray &  str,
bool *  isOk = arnNullptr 
)
static

Definition at line 765 of file MQFlags.cpp.

◆ strToNum()

uint Arn::EnumTxt::strToNum ( const QByteArray &  str,
bool *  isOk = arnNullptr 
)
static

Definition at line 754 of file MQFlags.cpp.

◆ subEnumAt()

const EnumTxt * Arn::EnumTxt::subEnumAt ( int  idx) const

Returns a pointer to a SubEnum.

Example output

QString xstr( "B0=Read B3=Create 0=None SE6:B1=AllowLev E0=Low E1=Mid E2=High");
Arn::EnumTxt myFlags;
myFlags.loadBitSet( xstr, "MyFlags");
const Arn::EnumTxt* sube = myFlags.subEnumAt( 0);
qDebug() << sube->getEnumSet( 0, false);

wiil print: "0=Low 1=Mid 2=High"

Parameters
[in]idxis the index of the SubEnum.
Return values
returnsa pointer to SubEnum for inbound idx, otherwise arnNullPtr.

Definition at line 722 of file MQFlags.cpp.

◆ subEnumCount()

int Arn::EnumTxt::subEnumCount ( ) const

Returns number of subEnums in this bitSet (class)

Example

qDebug() << AllowClassT::txt().subEnumCount();

wiil print: 1

Returns
the count of sub enums.

Definition at line 695 of file MQFlags.cpp.

◆ subEnumNameAt()

QString Arn::EnumTxt::subEnumNameAt ( int  idx,
quint16  nameSpace = 0 
) const

Returns the name of a SubEnum.

Name is taken by the registered bitmask of the SubEnum. When using static creation of this instance, there must be a declared enum for the bitmask of the SubEnum. E.g. in AllowClassT this enum is AllowLev. When using dynamic creation of flags, loading a BitSet, the name of the SubEnum is set in the process. This is also true when using addSubEnum(). Example

qDebug() << AllowClassT::txt().subEnumNameAt( 0);

wiil print: "AllowLev"

Parameters
[in]idxis the index of the SubEnum.
[in]nameSpaceis the nameSpace for the registered name (by bitMask).
Return values
returnsthe SubEnum name for inbound idx, otherwise QString().

Definition at line 702 of file MQFlags.cpp.

◆ subEnumPropAt()

bool Arn::EnumTxt::subEnumPropAt ( int  idx,
uint &  bitMask,
uchar &  bitPos 
) const

Returns the properties of a SubEnum.

Example

uint bitMask; uchar bitPos; qDebug() << AllowClassT::txt().subEnumNameAt( 0, bitMask, bitPos) << bitMask << bitPos;

wiil print: true 6 1

Parameters
[in]idxis the index of the SubEnum.
[out]bitMaskis the bitmask for the SubEnum.
[out]bitPosis the position for the starting bit of the SubEnum.
Return values
returnstrue for inbound idx, otherwise false.

Definition at line 711 of file MQFlags.cpp.


The documentation for this class was generated from the following files: