2
* PROGRAM: Firebird aux classes.
4
* DESCRIPTION: Firebird's SQL tri-state emulation class.
6
* The contents of this file are subject to the Initial
7
* Developer's Public License Version 1.0 (the "License");
8
* you may not use this file except in compliance with the
9
* License. You may obtain a copy of the License at
10
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
12
* Software distributed under the License is distributed AS IS,
13
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
14
* See the License for the specific language governing rights
15
* and limitations under the License.
17
* The Original Code was created by Claudio Valderrama on 28-Aug-2007
18
* for the Firebird Open Source RDBMS project.
20
* Copyright (c) 2007 Claudio Valderrama
21
* and all contributors signed below.
23
* All Rights Reserved.
24
* Contributor(s): ______________________________________.
29
#ifndef CLASSES_TRISTATE_H
30
#define CLASSES_TRISTATE_H
39
explicit TriState(bool input);
41
void operator=(bool input);
45
bool assignOnce(bool input);
46
bool isUnknown() const;
47
bool isAssigned() const;
54
// The var is left uninitialized.
55
inline TriState::TriState()
56
: m_init(false), m_val(false)
60
// The var is initialized to the explicit value.
61
inline TriState::TriState(bool input)
62
: m_init(true), m_val(input)
66
// The var receives a T/F value.
67
inline void TriState::operator=(bool input)
73
// The var is coerced to a T/F value as result.
74
inline bool TriState::asBool() const
76
return m_init && m_val;
79
// The var is returned to its uninitialized state.
80
inline void TriState::reset()
82
m_init = m_val = false;
85
// The assignment succeeds only if the var is uninitialized.
86
inline bool TriState::assignOnce(bool input)
96
// Tests whether the var is uninitialized.
97
inline bool TriState::isUnknown() const
102
// Tests whether the var is initialized.
103
inline bool TriState::isAssigned() const
108
// The var is toggled between T and F only if it's already initialized.
109
inline bool TriState::toggle()
119
#endif // CLASSES_TRISTATE_H