libutil++  1.9.3
 All Classes Functions Variables
Binary.h
1 /*
2 ** libutil++
3 ** $Id: Binary.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__Binary_H__
10 #define __libutilxx__sella__variant__Binary_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 Binary;
23  }
24 }
25 
27  public:
28  static const boost::regex & Pattern(void) { static boost::regex regex("^0x([0-9A-Fa-f]{2})*$"); return regex; }
29  static const int Type = 0x08;
30 
31  /* Constructors */
32  Binary() throw ();
33  Binary(const std::string &value) throw (TypeCastException);
34  Binary(const std::vector<uint8_t> &value) throw ();
35 
36  Binary(const Binary &other) throw ();
37  virtual ~Binary() throw ();
38 
39  /* Operators */
40  bool operator==(const Binary &other) const throw ();
41  bool operator!=(const Binary &other) const throw ();
42  Binary& operator=(const Binary &other) throw ();
43 
44  /* Public Member Functions */
45  const std::vector<uint8_t>& get() const throw (UnsupportedOperatorException);
46  std::vector<uint8_t>& get() throw (UnsupportedOperatorException);
47 
48  size_t size() const throw ();
49  bool empty() const throw ();
50  void clear() throw ();
51 
52 #if 1
53  virtual void msgpack(sella::util::MessagePack &mpack, uint32_t &offset) const throw (TypeCastException);
54 #else
55  virtual uint32_t msgpack(sella::util::MessagePack &mpack, uint32_t &offset) const throw (TypeCastException);
56 #endif
57  virtual void msgpackBufferSize(size_t &size) const throw ();
58  virtual std::string str(int type) const throw ();
59  virtual int getType(void) throw () { return Type; }
60 
61  static bool isType(const std::string &value) throw () { return isType(value.c_str(), value.size()); }
62  static bool isType(const char *value, size_t size) throw ();
63 };
64 
65 #endif
66 
67 /*
68 ** vim: noet ts=3 sw=3
69 */