libutil++  1.9.3
 All Classes Functions Variables
Nullable.h
1 /*
2 ** libutil++
3 ** $Id: Nullable.h 1653 2016-02-28 19:54:59Z 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__Nullable_H__
10 #define __libutilxx__sella__variant__Nullable_H__
11 
12 #include "../../common.h"
13 #include "TypeCastException.h"
14 #include "UnsupportedOperatorException.h"
15 #include "../util/MessagePack.h"
16 
17 #include <stdlib.h>
18 #include <stdint.h>
19 
20 #include <boost/regex.hpp>
21 
22 #include <memory>
23 #include <vector>
24 
25 namespace sella {
26  namespace variant {
27  class Nullable;
28  }
29 }
30 
32  public:
33  typedef std::shared_ptr<Nullable> shared;
34 
35  static const int Type = 0x00;
36 
37  const static int JSON = 0x00;
38  const static int CJSON = 0x01;
39  const static int MSGPACK = 0x02;
40  const static int XML = 0x03;
41  const static int CSV = 0x04;
42 
43  public:
44  /* Constructors */
45  Nullable() throw ();
46  Nullable(std::shared_ptr<void> &value) throw ();
47  Nullable(std::shared_ptr<void> &&value) throw ();
48 
49  Nullable(const Nullable &other) throw () = delete;
50  virtual ~Nullable() throw ();
51 
52  /* Operators */
53  Nullable& operator=(const Nullable &other) throw () = delete;
54 
55  /* Public Member Functions */
56  virtual void shrink_to_fit() throw ();
57  virtual std::string str(int type) const throw () = 0;
58  virtual int getType(void) throw () = 0;
59  virtual void msgpack(sella::util::MessagePack &mpack, uint32_t &offset) const throw (TypeCastException) = 0;
60  virtual void msgpackBufferSize(size_t &size) const throw () = 0;
61 
62  bool isNull() const throw ();
63 
64  protected:
65  std::vector<std::string> tokenize(const std::string &value, const boost::regex &pattern) const throw (TypeCastException);
66 
67  std::shared_ptr<void> value;
68 };
69 
70 #endif
71 
72 /*
73 ** vim: noet ts=3 sw=3
74 */