libutil++  1.9.3
 All Classes Functions Variables
Unsigned.h
1 /*
2 ** libutil++
3 ** $Id: Unsigned.h 1702 2016-08-13 23:26:06Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 #ifndef __libutilxx__sella__variant__Unsigned_H__
10 #define __libutilxx__sella__variant__Unsigned_H__
11 
12 #include "../../common.h"
13 #include "TypeCastException.h"
14 #include "Nullable.h"
15 
16 #include <memory>
17 
18 #include <boost/regex.hpp>
19 
20 namespace sella {
21  namespace variant {
22  class Unsigned;
23  }
24 }
25 
27  public:
28  // (?<![-]) == Assert previous character is not a minus, \b == Boundry for match.
29  static const boost::regex & Pattern(void) { static boost::regex regex("^(?<![-])\\b[+]?[0-9]+$"); return regex; }
30  static const int Type = 0x04;
31 
32  /* Constructors */
33  Unsigned() throw ();
34  Unsigned(const std::string &value) throw (TypeCastException);
35  Unsigned(uint64_t value) throw ();
36 
37  Unsigned(const Unsigned &other) throw ();
38  virtual ~Unsigned() throw ();
39 
40  /* Operators */
41  bool operator==(const Unsigned &other) const throw ();
42  bool operator!=(const Unsigned &other) const throw ();
43  bool operator>(const Unsigned &other) const throw ();
44  bool operator<(const Unsigned &other) const throw ();
45  bool operator!() throw ();
46  Unsigned& operator=(const Unsigned &other) throw ();
47  Unsigned& operator=(uint64_t other) throw ();
48  Unsigned& operator++() throw ();
49  Unsigned& operator--() throw ();
50  Unsigned& operator+=(uint64_t value) throw ();
51  Unsigned& operator-=(uint64_t value) throw ();
52  Unsigned& operator*=(uint64_t value) throw ();
53  Unsigned& operator/=(uint64_t value) throw ();
54  Unsigned& operator^=(uint64_t value) throw ();
55  Unsigned& operator%=(uint64_t value) throw ();
56  Unsigned& operator&=(uint64_t value) throw ();
57  Unsigned& operator|=(uint64_t value) throw ();
58  Unsigned& operator<<=(int bits) throw ();
59  Unsigned& operator>>=(int bits) throw ();
60 
61  /* Public Member Functions */
62  uint64_t get() const throw (UnsupportedOperatorException);
63 
64  virtual void msgpack(sella::util::MessagePack &mpack, uint32_t &offset) const throw (TypeCastException);
65  virtual void msgpackBufferSize(size_t &size) const throw ();
66  virtual std::string str(int type) const throw ();
67  virtual int getType(void) throw () { return Type; }
68 
69  static bool isType(const std::string &value) throw () { return isType(value.c_str(), value.size()); }
70  static bool isType(const char *value, size_t size) throw ();
71 };
72 
73 #endif
74 
75 /*
76 ** vim: noet ts=3 sw=3
77 */