1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtCore module of the Qt eXTension library
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
26 \class QxtNullable QxtNullable
28 \brief distinct null value compatible with any data type.
30 in general it's a templated abstraction to allow any data type to be
31 expressed with a null value distinct from any real value. An example
32 of such a use is for optional arguments.
34 prepare a function for argument skipping:
37 void somefunction( qxtNull(int,a) , qxtNull(int,b) )
56 somefunction(SKIP,1,2);
58 somefunction(3,SKIP,6);
66 #include <qxtglobal.h>
68 /*! \relates QxtNullable
69 * defines a skipable argument with type \a t and variable name \a n
71 #define qxtNull(t,n) QxtNullable<t> n = QxtNullable<t>()
76 class /*QXT_CORE_EXPORT*/ QxtNullable
80 QxtNullable(const T& p);
83 ///determinates if the Value is set to something meaningfull
91 void operator=(const T& p);
98 QxtNullable<T>::QxtNullable(QxtNull)
104 QxtNullable<T>::QxtNullable(const T& p)
106 val = const_cast<T*>(&p);
110 QxtNullable<T>::QxtNullable()
116 QxtNullable<T>::operator T() const
122 T& QxtNullable<T>::value() const
128 bool QxtNullable<T>::isNull() const
134 void QxtNullable<T>::nullify()
140 void QxtNullable<T>::operator=(const T& p)
142 val = const_cast<T*>(&p);