mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #873, nullable interface for value objects
This commit is contained in:
committed by
Mathew Sutcliffe
parent
273427d3d9
commit
f0cbe3b332
60
src/blackmisc/nullable.h
Normal file
60
src/blackmisc/nullable.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_NULLABLE_H
|
||||
#define BLACKMISC_NULLABLE_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
//! Nullable value object
|
||||
class BLACKMISC_EXPORT INullable
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexIsNull = BlackMisc::CPropertyIndex::GlobalIndexINullable,
|
||||
};
|
||||
|
||||
//! Constructor, init to null
|
||||
INullable(std::nullptr_t null);
|
||||
|
||||
//! Null?
|
||||
bool isNull() const { return m_isNull; }
|
||||
|
||||
//! Null?
|
||||
void setNull(bool null) { m_isNull = null; }
|
||||
|
||||
//! Can given index be handled
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
INullable() {}
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const INullable &compareValue) const;
|
||||
|
||||
bool m_isNull = false; //!< null?
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user