00001 00002 00003 00004 /*********************************************************************** 00005 Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by 00006 MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc. 00007 Others may also hold copyrights on code in this file. See the CREDITS 00008 file in the top directory of the distribution for details. 00009 00010 This file is part of MySQL++. 00011 00012 MySQL++ is free software; you can redistribute it and/or modify it 00013 under the terms of the GNU Lesser General Public License as published 00014 by the Free Software Foundation; either version 2.1 of the License, or 00015 (at your option) any later version. 00016 00017 MySQL++ is distributed in the hope that it will be useful, but WITHOUT 00018 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00019 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00020 License for more details. 00021 00022 You should have received a copy of the GNU Lesser General Public 00023 License along with MySQL++; if not, write to the Free Software 00024 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00025 USA 00026 ***********************************************************************/ 00027 00028 #ifndef MYSQLPP_TINY_INT_H 00029 #define MYSQLPP_TINY_INT_H 00030 00031 namespace mysqlpp { 00032 00042 00043 class tiny_int 00044 { 00045 public: 00049 tiny_int() { } 00050 00053 tiny_int(short int v) : 00054 value_(char(v)) 00055 { 00056 } 00057 00059 operator short int() const 00060 { 00061 return static_cast<short int>(value_); 00062 } 00063 00065 tiny_int& operator =(short int v) 00066 { 00067 value_ = char(v); 00068 return *this; 00069 } 00070 00072 tiny_int& operator +=(short int v) 00073 { 00074 value_ += char(v); 00075 return *this; 00076 } 00077 00079 tiny_int& operator -=(short int v) 00080 { 00081 value_ -= char(v); 00082 return *this; 00083 } 00084 00086 tiny_int& operator *=(short int v) 00087 { 00088 value_ *= char(v); 00089 return *this; 00090 } 00091 00093 tiny_int& operator /=(short int v) 00094 { 00095 value_ /= char(v); 00096 return *this; 00097 } 00098 00101 tiny_int& operator %=(short int v) 00102 { 00103 value_ %= char(v); 00104 return *this; 00105 } 00106 00108 tiny_int& operator &=(short int v) 00109 { 00110 value_ &= char(v); 00111 return *this; 00112 } 00113 00115 tiny_int& operator |=(short int v) 00116 { 00117 value_ |= char(v); 00118 return *this; 00119 } 00120 00122 tiny_int& operator ^=(short int v) 00123 { 00124 value_ ^= char(v); 00125 return *this; 00126 } 00127 00129 tiny_int& operator <<=(short int v) 00130 { 00131 value_ <<= char(v); 00132 return *this; 00133 } 00134 00136 tiny_int& operator >>=(short int v) 00137 { 00138 value_ >>= char(v); 00139 return *this; 00140 } 00141 00143 tiny_int& operator ++() 00144 { 00145 value_++; 00146 return *this; 00147 } 00148 00150 tiny_int& operator --() 00151 { 00152 value_--; 00153 return *this; 00154 } 00155 00157 tiny_int operator ++(int) 00158 { 00159 tiny_int tmp = value_; 00160 value_++; 00161 return tmp; 00162 } 00163 00166 tiny_int operator --(int) 00167 { 00168 tiny_int tmp = value_; 00169 value_--; 00170 return tmp; 00171 } 00172 00174 tiny_int operator -(const tiny_int& i) const 00175 { 00176 return value_ - i; 00177 } 00178 00180 tiny_int operator +(const tiny_int& i) const 00181 { 00182 return value_ + i; 00183 } 00184 00186 tiny_int operator *(const tiny_int& i) const 00187 { 00188 return value_ * i; 00189 } 00190 00192 tiny_int operator /(const tiny_int& i) const 00193 { 00194 return value_ / i; 00195 } 00196 00198 tiny_int operator %(const tiny_int& i) const 00199 { 00200 return value_ % i; 00201 } 00202 00204 tiny_int operator |(const tiny_int& i) const 00205 { 00206 return value_ | i; 00207 } 00208 00210 tiny_int operator &(const tiny_int& i) const 00211 { 00212 return value_ & i; 00213 } 00214 00216 tiny_int operator ^(const tiny_int& i) const 00217 { 00218 return value_ ^ i; 00219 } 00220 00222 tiny_int operator <<(const tiny_int& i) const 00223 { 00224 return value_ << i; 00225 } 00226 00228 tiny_int operator >>(const tiny_int& i) const 00229 { 00230 return value_ >> i; 00231 } 00232 00233 private: 00234 char value_; 00235 }; 00236 00237 } // end namespace mysqlpp 00238 00239 #endif