ACF $AcfVersion:0$
Namespaces | Macros | Variables
istd.h File Reference
#include <limits>
#include <QtCore/QtGlobal>
#include <QtCore/QByteArray>
#include <QtCore/QString>
#include <QtCore/QStringList>

Go to the source code of this file.

Namespaces

namespace  istd
 Standard library.
 

Macros

#define I_EPSILON   std::numeric_limits<double>::epsilon()
 Some very small number.
 
#define I_HUGE_NUMBER   10e20
 Some very big number.
 
#define I_INFINITY   std::numeric_limits<double>::infinity()
 Infinite value.
 
#define I_IF_DEBUG(instructions)   instructions
 
#define I_CRITICAL()   Q_ASSERT(false)
 
#define NULL   0
 
#define I_ENUM_GET_VALUES(Enum, ...)
 Get all values of an enumeration as a list of intergers.
 
#define I_ENUM_GET_STRINGS(Enum, ...)
 Get all values of an enumeration as strings.
 
#define I_DECLARE_ENUM(Enum, ...)
 Create meta information for an existing enumeration.
 
#define I_DECLARE_FLAGS(Enum, ...)
 

Variables

static const double I_BIG_EPSILON = 1.0e-8
 
static const QChar QCHAR_POW2 = QChar(0x00B2)
 Commonly used symbols.
 
static const QChar QCHAR_POW3 = QChar(0x00B3)
 
static const QChar QCHAR_DEGREE = QChar(0x00B0)
 
static const QChar QCHAR_PERMILLE = QChar(0x2030)
 

Macro Definition Documentation

◆ I_CRITICAL

#define I_CRITICAL ( )    Q_ASSERT(false)

Definition at line 60 of file istd.h.

◆ I_DECLARE_ENUM

#define I_DECLARE_ENUM (   Enum,
  ... 
)
Value:
I_ENUM_GET_VALUES(Enum, __VA_ARGS__)\
I_ENUM_GET_STRINGS(Enum, __VA_ARGS__)\
static QByteArray ToString(Enum enumValue){\
static QByteArray emptyString;\
QStringList values = Enum##GetStrings();\
QList<int> enumValues = Enum##GetValues();\
Q_ASSERT(enumValues.count() == values.count());\
for (int i = 0; i < enumValues.count(); ++i){\
if (enumValues[i] == enumValue){\
return values[i].toUtf8();\
}\
}\
return emptyString;\
}\
static bool FromString(const QByteArray& enumString, Enum& enumValue){\
QStringList values = Enum##GetStrings();\
QList<int> enumValues = Enum##GetValues();\
Q_ASSERT(enumValues.count() == values.count());\
for (int i = 0; i < enumValues.count(); ++i){\
if (values[i].toUtf8() == enumString){\
enumValue = Enum(enumValues[i]);\
return true;\
}\
}\
return false;\
}
#define I_ENUM_GET_VALUES(Enum,...)
Get all values of an enumeration as a list of intergers.
Definition istd.h:81

Create meta information for an existing enumeration.

Definition at line 127 of file istd.h.

◆ I_DECLARE_FLAGS

#define I_DECLARE_FLAGS (   Enum,
  ... 
)

Definition at line 155 of file istd.h.

◆ I_ENUM_GET_STRINGS

#define I_ENUM_GET_STRINGS (   Enum,
  ... 
)
Value:
static QStringList Enum##GetStrings(){\
QString enumValuesString = #__VA_ARGS__;\
QStringList values = enumValuesString.split(",");\
for (int i = 0; i < values.count(); ++i){\
QString rawValue = values[i].simplified();\
QStringList splitNames = rawValue.split("_");\
if (splitNames.isEmpty()){\
values[i] = rawValue;\
}\
else{\
QString formattedValue = rawValue;\
for (int partIndex = 1; partIndex < splitNames.count(); ++partIndex){\
QString partValue = splitNames[partIndex].toLower();\
if (partIndex == 1){\
formattedValue = partValue;\
}\
else{\
formattedValue += partValue.at(0).toUpper() + partValue.mid(1);\
}\
}\
values[i] = formattedValue;\
}\
}\
return values;\
}

Get all values of an enumeration as strings.

Definition at line 97 of file istd.h.

◆ I_ENUM_GET_VALUES

#define I_ENUM_GET_VALUES (   Enum,
  ... 
)
Value:
static QList<int> Enum##GetValues(){\
QList<int> values;\
int vars[] = {0, __VA_ARGS__};\
int count = (sizeof(vars) / sizeof(int));\
for(int i = 0; i < count; ++i){\
if (i > 0){\
values << vars[i];\
}\
}\
return values;\
}

Get all values of an enumeration as a list of intergers.

Definition at line 81 of file istd.h.

◆ I_EPSILON

#define I_EPSILON   std::numeric_limits<double>::epsilon()

Some very small number.

Definition at line 31 of file istd.h.

◆ I_HUGE_NUMBER

#define I_HUGE_NUMBER   10e20

Some very big number.

Definition at line 37 of file istd.h.

◆ I_IF_DEBUG

#define I_IF_DEBUG (   instructions)    instructions

Definition at line 59 of file istd.h.

◆ I_INFINITY

#define I_INFINITY   std::numeric_limits<double>::infinity()

Infinite value.

Definition at line 43 of file istd.h.

◆ NULL

#define NULL   0

Definition at line 74 of file istd.h.

Variable Documentation

◆ I_BIG_EPSILON

const double I_BIG_EPSILON = 1.0e-8
static

◆ QCHAR_DEGREE

const QChar QCHAR_DEGREE = QChar(0x00B0)
static

Definition at line 51 of file istd.h.

◆ QCHAR_PERMILLE

const QChar QCHAR_PERMILLE = QChar(0x2030)
static

Definition at line 52 of file istd.h.

◆ QCHAR_POW2

const QChar QCHAR_POW2 = QChar(0x00B2)
static

Commonly used symbols.

Definition at line 49 of file istd.h.

◆ QCHAR_POW3

const QChar QCHAR_POW3 = QChar(0x00B3)
static

Definition at line 50 of file istd.h.