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 private: 00046 char value; 00047 00048 public: 00052 tiny_int() { } 00053 00056 tiny_int(short int v) : 00057 value(char(v)) 00058 { 00059 } 00060 00062 operator short int() const 00063 { 00064 return static_cast<short int>(value); 00065 } 00066 00068 tiny_int& operator =(short int v) 00069 { 00070 value = char(v); 00071 return *this; 00072 } 00073 00075 tiny_int& operator +=(short int v) 00076 { 00077 value += char(v); 00078 return *this; 00079 } 00080 00082 tiny_int& operator -=(short int v) 00083 { 00084 value -= char(v); 00085 return *this; 00086 } 00087 00089 tiny_int& operator *=(short int v) 00090 { 00091 value *= char(v); 00092 return *this; 00093 } 00094 00096 tiny_int& operator /=(short int v) 00097 { 00098 value /= char(v); 00099 return *this; 00100 } 00101 00104 tiny_int& operator %=(short int v) 00105 { 00106 value %= char(v); 00107 return *this; 00108 } 00109 00111 tiny_int& operator &=(short int v) 00112 { 00113 value &= char(v); 00114 return *this; 00115 } 00116 00118 tiny_int& operator |=(short int v) 00119 { 00120 value |= char(v); 00121 return *this; 00122 } 00123 00125 tiny_int& operator ^=(short int v) 00126 { 00127 value ^= char(v); 00128 return *this; 00129 } 00130 00132 tiny_int& operator <<=(short int v) 00133 { 00134 value <<= char(v); 00135 return *this; 00136 } 00137 00139 tiny_int& operator >>=(short int v) 00140 { 00141 value >>= char(v); 00142 return *this; 00143 } 00144 00146 tiny_int& operator ++() 00147 { 00148 value++; 00149 return *this; 00150 } 00151 00153 tiny_int& operator --() 00154 { 00155 value--; 00156 return *this; 00157 } 00158 00160 tiny_int operator ++(int) 00161 { 00162 tiny_int tmp = value; 00163 value++; 00164 return tmp; 00165 } 00166 00169 tiny_int operator --(int) 00170 { 00171 tiny_int tmp = value; 00172 value--; 00173 return tmp; 00174 } 00175 00177 tiny_int operator -(const tiny_int& i) const 00178 { 00179 return value - i; 00180 } 00181 00183 tiny_int operator +(const tiny_int& i) const 00184 { 00185 return value + i; 00186 } 00187 00189 tiny_int operator *(const tiny_int& i) const 00190 { 00191 return value * i; 00192 } 00193 00195 tiny_int operator /(const tiny_int& i) const 00196 { 00197 return value / i; 00198 } 00199 00201 tiny_int operator %(const tiny_int& i) const 00202 { 00203 return value % i; 00204 } 00205 00207 tiny_int operator |(const tiny_int& i) const 00208 { 00209 return value | i; 00210 } 00211 00213 tiny_int operator &(const tiny_int& i) const 00214 { 00215 return value & i; 00216 } 00217 00219 tiny_int operator ^(const tiny_int& i) const 00220 { 00221 return value ^ i; 00222 } 00223 00225 tiny_int operator <<(const tiny_int& i) const 00226 { 00227 return value << i; 00228 } 00229 00231 tiny_int operator >>(const tiny_int& i) const 00232 { 00233 return value >> i; 00234 } 00235 }; 00236 00237 } // end namespace mysqlpp 00238 00239 #endif