MySQL++ Reference Manual

MySQL++: autoflag.h Source File

MySQL++ 3.3.0

autoflag.h
Go to the documentation of this file.
1
5 /***********************************************************************
6 Copyright © 2007 by Educational Technology Resources, Inc.
7 Others may also hold copyrights on code in this file. See the
8 CREDITS.txt file in the top directory of the distribution for details.
9
10 This file is part of MySQL++.
11
12 MySQL++ is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published
14 by the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with MySQL++; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 USA
26 ***********************************************************************/
27
28 #if !defined(MYSQLPP_AUTOFLAG_H)
29 #define MYSQLPP_AUTOFLAG_H
30
31 namespace mysqlpp {
32
36
37 template <class T = bool>
38 class AutoFlag
39 {
40 public:
42 AutoFlag(T& ref) :
43 referent_(ref)
44 {
45 referent_ = true;
46 }
47
49 ~AutoFlag()
50 {
51 referent_ = false;
52 }
53
54 private:
55 T& referent_;
56 };
57
58 } // end namespace mysqlpp
59
60 #endif // !defined(MYSQLPP_AUTOFLAG_H)
61
mysqlpp::AutoFlag
A template for setting a flag on a variable as long as the object that set it is in scope....
Definition: autoflag.h:39
mysqlpp::AutoFlag::AutoFlag
AutoFlag(T &ref)
Constructor: sets ref to true.
Definition: autoflag.h:42
mysqlpp::AutoFlag::~AutoFlag
~AutoFlag()
Destructor: sets referent passed to ctor to false.
Definition: autoflag.h:49