There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*************************************************************************** | ||
qgsoptionalexpression.sip - QgsOptionalExpression | ||
|
||
--------------------- | ||
begin : 8.9.2016 | ||
copyright : (C) 2016 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
/** | ||
* \ingroup core | ||
* | ||
* QgsOptionalExpression is a container for an expression with an additional enabled/disabled flag. | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
class QgsOptionalExpression | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsoptionalexpression.h> | ||
%End | ||
public: | ||
/** | ||
* A QgsOptionalExpression is disabled by default if default constructed. | ||
*/ | ||
QgsOptionalExpression(); | ||
|
||
/** | ||
* A QgsOptionalExpression is enabled by default if constructed with an expression. | ||
*/ | ||
QgsOptionalExpression( const QgsExpression& data ); | ||
|
||
/** | ||
* A QgsOptionalExptression constructed with enabled status and data | ||
*/ | ||
QgsOptionalExpression( const QgsExpression& data, bool enabled ); | ||
|
||
/** | ||
* Compare this QgsOptionalExptression to another one. | ||
* | ||
* This will compare the enabled flag and call the == operator | ||
* of the contained class. | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
bool operator== ( const QgsOptionalExpression& other ) const; | ||
operator bool () const; | ||
|
||
/** | ||
* Check if this optional is enabled | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
bool enabled() const; | ||
|
||
/** | ||
* Set if this optional is enabled | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
void setEnabled( bool enabled ); | ||
|
||
/** | ||
* Access the payload data | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
QgsExpression data() const; | ||
|
||
/** | ||
* Set the payload data | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
void setData( const QgsExpression& data ); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*************************************************************************** | ||
qgsoptional.cpp - QgsOptional | ||
--------------------- | ||
begin : 7.9.2016 | ||
copyright : (C) 2016 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgsoptional.h" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/*************************************************************************** | ||
qgsoptional.h - QgsOptional | ||
--------------------- | ||
begin : 7.9.2016 | ||
copyright : (C) 2016 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSOPTIONAL_H | ||
#define QGSOPTIONAL_H | ||
|
||
/** | ||
* \ingroup core | ||
* | ||
* \brief | ||
* QgsOptional is a container for other classes and adds an additional enabled/disabled flag. | ||
* | ||
* Often it is used for configuration options which can be enabled or disabled but also have | ||
* more internal configuration information that should not be lost when disabling and re-enabling. | ||
* | ||
* @note Added in QGIS 3.0 | ||
* @note For python you need to use implementations for specific template classes | ||
*/ | ||
template<class T> | ||
class CORE_EXPORT QgsOptional | ||
{ | ||
public: | ||
/** | ||
* A QgsOptional is disabled by default if default constructed. | ||
*/ | ||
QgsOptional() | ||
: mEnabled( false ) | ||
{ | ||
} | ||
|
||
/** | ||
* A QgsOptional is enabled by default if constructed with payload. | ||
*/ | ||
QgsOptional( const T& data ) | ||
: mEnabled( true ) | ||
, mData( data ) | ||
{ | ||
} | ||
|
||
/** | ||
* A QgsOptional constructed with enabled status and data | ||
*/ | ||
QgsOptional( const T& data, bool enabled ) | ||
: mEnabled( enabled ) | ||
, mData( data ) | ||
{ | ||
} | ||
|
||
/** | ||
* Compare this QgsOptional to another one. | ||
* | ||
* This will compare the enabled flag and call the == operator | ||
* of the contained class. | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
bool operator== ( const QgsOptional<T>& other ) const | ||
{ | ||
return mEnabled == other.mEnabled && mData == other.mData; | ||
} | ||
|
||
/** | ||
* Boolean operator. Will return true if this optional is enabled. | ||
*/ | ||
operator bool() const | ||
{ | ||
return mEnabled; | ||
} | ||
|
||
/** | ||
* Check if this optional is enabled | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
bool enabled() const | ||
{ | ||
return mEnabled; | ||
} | ||
|
||
/** | ||
* Set if this optional is enabled | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
void setEnabled( bool enabled ) | ||
{ | ||
mEnabled = enabled; | ||
} | ||
|
||
/** | ||
* Access the payload data | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
const T* operator->() const | ||
{ | ||
return &mData; | ||
} | ||
|
||
/** | ||
* Access the payload data | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
T data() const | ||
{ | ||
return mData; | ||
} | ||
|
||
/** | ||
* Set the payload data | ||
* | ||
* @note Added in QGIS 3.0 | ||
*/ | ||
void setData( const T& data ) | ||
{ | ||
mData = data; | ||
} | ||
|
||
private: | ||
T mData; | ||
bool mEnabled; | ||
}; | ||
|
||
#endif // QGSOPTIONAL_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*************************************************************************** | ||
qgsoptionalexpression - %{Cpp:License:ClassName} | ||
--------------------- | ||
begin : 8.9.2016 | ||
copyright : (C) 2016 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSOPTIONALEXPRESSION_H | ||
#define QGSOPTIONALEXPRESSION_H | ||
|
||
#include "qgsoptional.h" | ||
#include "qgsexpression.h" | ||
|
||
/** | ||
* An expression with an additional enabled flag. | ||
* | ||
* This can be used for configuration options where an expression can be enabled | ||
* or diabled but when disabled it shouldn't lose it's information for the case | ||
* it gets re-enabled later on and a user shoulnd't be force to redo the configuration. | ||
* | ||
* Added in QGIS 3.0 | ||
*/ | ||
typedef QgsOptional<QgsExpression> QgsOptionalExpression; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
m-kuhn
via email
Author
Member
|
||
|
||
#endif // QGSOPTIONALEXPRESSION_H |
Hi @m-kuhn, I can't build QGIS in vs2010 and vs2015 from this commit. I get these unresolve external symbols.
What can I do to resolve it? I should create a new bug entry in the issues repo?
Thanks in advance