QxNull

From qtnode

Jump to: navigation, search

QxNull is a helper class that expresses a null value for function in the Qx Library. You will generally not need to instantiate a QxNull object; rather, use the QXNULL global variable provided. For an example of usage, see QxNullable.

Contents

Public Members

QxNull::isNull

An enum, evaluating to true, useful for specialized templates.

const T& operator=(const T& p)

Does nothing. A value cannot be assigned to a null; this function is provided to allow templates possibly involving QxNull to compile.

bool operator==(const T& p)

Returns true if p is a QxNull, otherwise returns false.

Related Non-Members

QxNull QXNULL

A predefined null value available at the global scope.

SKIP

An alias for QXNULL, selected to be more intuitive in parameter lists.

Header File qxnull.h

#ifndef QXNULL_H
#define QXNULL_H
extern struct QxNull {
    inline operator int() const { return 0; }
    enum { isNull = true };

    template<typename T>
    inline const T& operator=(const T& p) { return p; }

    template<typename T>
    inline bool operator==(const T& p) { return false; }
    inline bool operator==(const QxNull& p) { return true; }
} QXNULL;

#ifndef QX_NO_MACROS
#define SKIP QXNULL
#endif
#endif

Source Code qxnull.cpp

#include "qxnull.h"
QxNull QXNULL;

Licensing

QxNull is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1 or greater, or under the terms of the Q Public Library as published by Trolltech.

QxNull is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the appropriate license agreement for more details.

Personal tools