00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_64BIT_INTEGERS
00048 #define STLSOFT_INCL_STLSOFT_UTIL_HPP_64BIT_INTEGERS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define STLSOFT_VER_STLSOFT_UTIL_HPP_64BIT_INTEGERS_MAJOR 5
00052 # define STLSOFT_VER_STLSOFT_UTIL_HPP_64BIT_INTEGERS_MINOR 1
00053 # define STLSOFT_VER_STLSOFT_UTIL_HPP_64BIT_INTEGERS_REVISION 1
00054 # define STLSOFT_VER_STLSOFT_UTIL_HPP_64BIT_INTEGERS_EDIT 130
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00062 # include <stlsoft/stlsoft.h>
00063 #endif
00064
00065
00066
00067
00068
00069 #ifndef _STLSOFT_NO_NAMESPACE
00070 namespace stlsoft
00071 {
00072 #endif
00073
00074
00075
00076
00077
00078 #ifndef _STLSOFT_NO_NAMESPACE
00079 namespace sinteger64_util
00080 {
00081 #endif
00082
00087 class sinteger64
00088 {
00089 public:
00090 typedef sinteger64 class_type;
00091
00092 public:
00093 sinteger64();
00094 sinteger64(ss_sint8_t i);
00095 sinteger64(ss_sint16_t i);
00096 sinteger64(ss_sint32_t i);
00097 sinteger64(ss_sint32_t high, ss_sint32_t low);
00098 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00099 sinteger64(int i);
00100 #endif
00101 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00102 sinteger64(long i);
00103 #endif
00104
00105 class_type& operator =(class_type const& rhs);
00106 class_type& operator =(ss_sint8_t i);
00107 class_type& operator =(ss_sint16_t i);
00108 class_type& operator =(ss_sint32_t i);
00109 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00110 class_type& operator =(int i);
00111 #endif
00112 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00113 class_type& operator =(long i);
00114 #endif
00115
00116 class_type& operator +=(class_type const& rhs);
00117 class_type& operator +=(ss_sint8_t i);
00118 class_type& operator +=(ss_sint16_t i);
00119 class_type& operator +=(ss_sint32_t i);
00120 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00121 class_type& operator +=(int i);
00122 #endif
00123 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00124 class_type& operator +=(long i);
00125 #endif
00126
00127 class_type& operator -=(class_type const& rhs);
00128 class_type& operator -=(ss_sint8_t i);
00129 class_type& operator -=(ss_sint16_t i);
00130 class_type& operator -=(ss_sint32_t i);
00131 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00132 class_type& operator -=(int i);
00133 #endif
00134 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00135 class_type& operator -=(long i);
00136 #endif
00137
00138 class_type& operator *=(class_type const& rhs);
00139 class_type& operator *=(ss_sint8_t i);
00140 class_type& operator *=(ss_sint16_t i);
00141 class_type& operator *=(ss_sint32_t i);
00142 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00143 class_type& operator *=(int i);
00144 #endif
00145 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00146 class_type& operator *=(long i);
00147 #endif
00148
00149 class_type& operator /=(class_type const& rhs);
00150 class_type& operator /=(ss_sint8_t i);
00151 class_type& operator /=(ss_sint16_t i);
00152 class_type& operator /=(ss_sint32_t i);
00153 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00154 class_type& operator /=(int i);
00155 #endif
00156 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00157 class_type& operator /=(long i);
00158 #endif
00159
00160 class_type& operator %=(class_type const& rhs);
00161 class_type& operator %=(ss_sint8_t i);
00162 class_type& operator %=(ss_sint16_t i);
00163 class_type& operator %=(ss_sint32_t i);
00164 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00165 class_type& operator %=(int i);
00166 #endif
00167 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00168 class_type& operator %=(long i);
00169 #endif
00170
00171 public:
00172 ss_sint_t compare(class_type const& rhs) const;
00173 ss_sint_t compare(ss_sint8_t i) const;
00174 ss_sint_t compare(ss_sint16_t i) const;
00175 ss_sint_t compare(ss_sint32_t i) const;
00176 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00177 ss_sint_t compare(int i) const;
00178 #endif
00179 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00180 ss_sint_t compare(long i) const;
00181 #endif
00182
00183
00184 private:
00185 ss_sint32_t m_low;
00186 ss_sint32_t m_high;
00187 };
00188
00189 #ifndef _STLSOFT_NO_NAMESPACE
00190 }
00191
00192 using ::stlsoft::sinteger64_util::sinteger64;
00193 #endif
00194
00195
00196
00197
00198
00199 #ifndef _STLSOFT_NO_NAMESPACE
00200 namespace sinteger64_util
00201 {
00202 #endif
00203
00204
00205
00206 inline ss_bool_t operator ==(sinteger64 const& lhs, sinteger64 const& rhs)
00207 {
00208 return 0 == lhs.compare(rhs);
00209 }
00210
00211
00212
00213 inline ss_bool_t operator !=(sinteger64 const& lhs, sinteger64 const& rhs)
00214 {
00215 return 0 != lhs.compare(rhs);
00216 }
00217
00218
00219
00220 inline ss_bool_t operator <(sinteger64 const& lhs, sinteger64 const& rhs)
00221 {
00222 return lhs.compare(rhs) < 0;
00223 }
00224
00225
00226
00227 inline ss_bool_t operator >(sinteger64 const& lhs, sinteger64 const& rhs)
00228 {
00229 return lhs.compare(rhs) > 0;
00230 }
00231
00232
00233
00234 inline ss_bool_t operator <=(sinteger64 const& lhs, sinteger64 const& rhs)
00235 {
00236 return lhs.compare(rhs) <= 0;
00237 }
00238
00239
00240
00241 inline ss_bool_t operator >=(sinteger64 const& lhs, sinteger64 const& rhs)
00242 {
00243 return lhs.compare(rhs) >= 0;
00244 }
00245
00246
00247
00248 inline sinteger64 operator +(sinteger64 const& lhs, sinteger64 const& rhs)
00249 {
00250 sinteger64 result(lhs);
00251
00252 result += rhs;
00253
00254 return result;
00255 }
00256
00257
00258
00259 inline sinteger64 operator -(sinteger64 const& lhs, sinteger64 const& rhs)
00260 {
00261 sinteger64 result(lhs);
00262
00263 result -= rhs;
00264
00265 return result;
00266 }
00267
00268
00269
00270 inline sinteger64 operator *(sinteger64 const& lhs, sinteger64 const& rhs)
00271 {
00272 sinteger64 result(lhs);
00273
00274 result *= rhs;
00275
00276 return result;
00277 }
00278
00279
00280
00281 inline sinteger64 operator /(sinteger64 const& lhs, sinteger64 const& rhs)
00282 {
00283 sinteger64 result(lhs);
00284
00285 result /= rhs;
00286
00287 return result;
00288 }
00289
00290
00291
00292 inline sinteger64 operator %(sinteger64 const& lhs, sinteger64 const& rhs)
00293 {
00294 sinteger64 result(lhs);
00295
00296 result %= rhs;
00297
00298 return result;
00299 }
00300
00301 #ifndef _STLSOFT_NO_NAMESPACE
00302 }
00303 #endif
00304
00305
00306
00307
00308
00309 #ifdef STLSOFT_UNITTEST
00310 # include "./unittest/64bit_integers_unittest_.h"
00311 #endif
00312
00313
00314
00315
00316
00317 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00318
00319 #ifndef _STLSOFT_NO_NAMESPACE
00320 namespace sinteger64_util
00321 {
00322 #endif
00323
00324 inline sinteger64::sinteger64()
00325 {}
00326
00327 inline sinteger64::sinteger64(ss_sint8_t i)
00328 : m_low(i)
00329 , m_high(0)
00330 {}
00331
00332 inline sinteger64::sinteger64(ss_sint16_t i)
00333 : m_low(i)
00334 , m_high(0)
00335 {}
00336
00337 inline sinteger64::sinteger64(ss_sint32_t i)
00338 : m_low(i)
00339 , m_high(0)
00340 {}
00341
00342 inline sinteger64::sinteger64(ss_sint32_t high, ss_sint32_t low)
00343 : m_low(low)
00344 , m_high(high)
00345 {}
00346
00347 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00348 inline sinteger64::sinteger64(int i)
00349 : m_low(i)
00350 , m_high(0)
00351 {}
00352 #endif
00353
00354 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00355 inline sinteger64::sinteger64(long i)
00356 : m_low(i)
00357 , m_high(0)
00358 {}
00359 #endif
00360
00361 inline sinteger64::class_type& sinteger64::operator =(class_type const& rhs)
00362 {
00363 m_high = rhs.m_high;
00364 m_low = rhs.m_low;
00365
00366 return *this;
00367 }
00368
00369 inline sinteger64::class_type& sinteger64::operator =(ss_sint8_t i)
00370 {
00371 m_high = 0;
00372 m_low = i;
00373
00374 return *this;
00375 }
00376
00377 inline sinteger64::class_type& sinteger64::operator =(ss_sint16_t i)
00378 {
00379 m_high = 0;
00380 m_low = i;
00381
00382 return *this;
00383 }
00384
00385 inline sinteger64::class_type& sinteger64::operator =(ss_sint32_t i)
00386 {
00387 m_high = 0;
00388 m_low = i;
00389
00390 return *this;
00391 }
00392
00393 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00394 inline sinteger64::class_type& sinteger64::operator =(int i)
00395 {
00396 m_high = 0;
00397 m_low = i;
00398
00399 return *this;
00400 }
00401 #endif
00402
00403 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00404 inline sinteger64::class_type& sinteger64::operator =(long i)
00405 {
00406 m_high = 0;
00407 m_low = i;
00408
00409 return *this;
00410 }
00411 #endif
00412
00413 inline sinteger64::class_type& sinteger64::operator +=(class_type const& rhs)
00414 {
00415 m_low += rhs.m_low;
00416 m_high += rhs.m_high;
00417
00418 if( rhs.m_low > 0 &&
00419 m_low < rhs.m_low)
00420 {
00421 ++m_high;
00422 }
00423 else if(rhs.m_low < 0 &&
00424 m_low > rhs.m_low)
00425 {
00426 --m_high;
00427 }
00428
00429 return *this;
00430 }
00431
00432 inline sinteger64::class_type& sinteger64::operator +=(ss_sint8_t i)
00433 {
00434 return operator +=(class_type(i));
00435 }
00436
00437 inline sinteger64::class_type& sinteger64::operator +=(ss_sint16_t i)
00438 {
00439 return operator +=(class_type(i));
00440 }
00441
00442 inline sinteger64::class_type& sinteger64::operator +=(ss_sint32_t i)
00443 {
00444 return operator +=(class_type(i));
00445 }
00446
00447 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00448 inline sinteger64::class_type& sinteger64::operator +=(int i)
00449 {
00450 return operator +=(class_type(i));
00451 }
00452 #endif
00453
00454 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00455 inline sinteger64::class_type& sinteger64::operator +=(long i)
00456 {
00457 return operator +=(class_type(i));
00458 }
00459 #endif
00460
00461 inline sinteger64::class_type& sinteger64::operator -=(class_type const& rhs)
00462 {
00463 m_low -= rhs.m_low;
00464 m_high -= rhs.m_high;
00465
00466 if( rhs.m_low > 0 &&
00467 m_low < rhs.m_low)
00468 {
00469 ++m_high;
00470 }
00471 else if(rhs.m_low < 0 &&
00472 m_low > rhs.m_low)
00473 {
00474 --m_high;
00475 }
00476
00477 return *this;
00478 }
00479
00480 inline sinteger64::class_type& sinteger64::operator -=(ss_sint8_t i)
00481 {
00482 return operator -=(class_type(i));
00483 }
00484
00485 inline sinteger64::class_type& sinteger64::operator -=(ss_sint16_t i)
00486 {
00487 return operator -=(class_type(i));
00488 }
00489
00490 inline sinteger64::class_type& sinteger64::operator -=(ss_sint32_t i)
00491 {
00492 return operator -=(class_type(i));
00493 }
00494
00495 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00496 inline sinteger64::class_type& sinteger64::operator -=(int i)
00497 {
00498 return operator -=(class_type(i));
00499 }
00500 #endif
00501
00502 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00503 inline sinteger64::class_type& sinteger64::operator -=(long i)
00504 {
00505 return operator -=(class_type(i));
00506 }
00507 #endif
00508
00509 inline sinteger64::class_type& sinteger64::operator *=(class_type const& rhs)
00510 {
00511 m_low *= rhs.m_low;
00512 m_high *= rhs.m_high;
00513
00514 if( rhs.m_low > 0 &&
00515 m_low < rhs.m_low)
00516 {
00517 ++m_high;
00518 }
00519 else if(rhs.m_low < 0 &&
00520 m_low > rhs.m_low)
00521 {
00522 --m_high;
00523 }
00524
00525 return *this;
00526 }
00527
00528 inline sinteger64::class_type& sinteger64::operator *=(ss_sint8_t i)
00529 {
00530 return operator *=(class_type(i));
00531 }
00532
00533 inline sinteger64::class_type& sinteger64::operator *=(ss_sint16_t i)
00534 {
00535 return operator *=(class_type(i));
00536 }
00537
00538 inline sinteger64::class_type& sinteger64::operator *=(ss_sint32_t i)
00539 {
00540 return operator *=(class_type(i));
00541 }
00542
00543 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00544 inline sinteger64::class_type& sinteger64::operator *=(int i)
00545 {
00546 return operator *=(class_type(i));
00547 }
00548 #endif
00549
00550 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00551 inline sinteger64::class_type& sinteger64::operator *=(long i)
00552 {
00553 return operator *=(class_type(i));
00554 }
00555 #endif
00556
00557
00558
00559 inline sinteger64::class_type& sinteger64::operator /=(ss_sint8_t i)
00560 {
00561 return operator /=(class_type(i));
00562 }
00563
00564 inline sinteger64::class_type& sinteger64::operator /=(ss_sint16_t i)
00565 {
00566 return operator /=(class_type(i));
00567 }
00568
00569 inline sinteger64::class_type& sinteger64::operator /=(ss_sint32_t i)
00570 {
00571 return operator /=(class_type(i));
00572 }
00573
00574 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00575 inline sinteger64::class_type& sinteger64::operator /=(int i)
00576 {
00577 return operator /=(class_type(i));
00578 }
00579 #endif
00580
00581 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00582 inline sinteger64::class_type& sinteger64::operator /=(long i)
00583 {
00584 return operator /=(class_type(i));
00585 }
00586 #endif
00587
00588
00589
00590
00591 inline sinteger64::class_type& sinteger64::operator %=(ss_sint8_t i)
00592 {
00593 return operator %=(class_type(i));
00594 }
00595
00596 inline sinteger64::class_type& sinteger64::operator %=(ss_sint16_t i)
00597 {
00598 return operator %=(class_type(i));
00599 }
00600
00601 inline sinteger64::class_type& sinteger64::operator %=(ss_sint32_t i)
00602 {
00603 return operator %=(class_type(i));
00604 }
00605
00606 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00607 inline sinteger64::class_type& sinteger64::operator %=(int i)
00608 {
00609 return operator %=(class_type(i));
00610 }
00611 #endif
00612
00613 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00614 inline sinteger64::class_type& sinteger64::operator %=(long i)
00615 {
00616 return operator %=(class_type(i));
00617 }
00618 #endif
00619
00620
00621 inline ss_sint_t sinteger64::compare(class_type const& rhs) const
00622 {
00623 ss_sint_t res = m_high - rhs.m_high;
00624
00625 if(0 == res)
00626 {
00627 res = m_low - rhs.m_low;
00628 }
00629
00630 return res;
00631 }
00632
00633 inline ss_sint_t sinteger64::compare(ss_sint8_t i) const
00634 {
00635 return compare(class_type(0, i));
00636 }
00637
00638 inline ss_sint_t sinteger64::compare(ss_sint16_t i) const
00639 {
00640 return compare(class_type(0, i));
00641 }
00642
00643 inline ss_sint_t sinteger64::compare(ss_sint32_t i) const
00644 {
00645 return compare(class_type(0, i));
00646 }
00647
00648 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00649 inline ss_sint_t sinteger64::compare(int i) const
00650 {
00651 return compare(class_type(0, i));
00652 }
00653 #endif
00654
00655 #ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
00656 inline ss_sint_t sinteger64::compare(long i) const
00657 {
00658 return compare(class_type(0, i));
00659 }
00660 #endif
00661
00662 #ifndef _STLSOFT_NO_NAMESPACE
00663 }
00664 #endif
00665
00666 #endif
00667
00668
00669
00670 #ifndef _STLSOFT_NO_NAMESPACE
00671 }
00672 #endif
00673
00674
00675
00676 #endif
00677
00678