16 const char X00 =
'\0';
17 const int OID_SIZE = 12;
18 const int DB_PTR_SIZE = 12;
23 typedef std::vector<Element> array;
24 typedef std::array<unsigned char, OID_SIZE> oid;
25 typedef std::pair<std::string, std::string> regex;
26 typedef std::pair<std::string, std::array<unsigned char, DB_PTR_SIZE>> dbptr;
27 typedef std::pair<std::string, Document> jscode_scope;
28 typedef std::pair<unsigned char, std::string> binary;
38 Element(): m_data(nullptr), m_type(_UNKNOWN) {}
47 Element(
const T&
data,
const TypeInfo type = _UNKNOWN);
49 Element(
const char*
data,
const TypeInfo type = _UNKNOWN);
64 unsigned decode(
const unsigned char*
data,
const TypeInfo m_type);
71 void encode(std::ostringstream& oss)
const;
88 const T&
data()
const;
96 void data(T& t)
const {t = data<T>();}
111 operator std::string()
const;
114 friend class Document;
116 std::shared_ptr<void> m_data;
127 template <
typename T>
128 bool check_convert()
const;
136 template <
typename T>
137 void type_check()
const;
146 unsigned deserialize_bytes(
const unsigned char* bytes);
154 void serialize_bson(std::ostringstream& oss)
const;
162 template <
typename T>
163 std::string _to_std_str()
const;
172 template <
typename T>
173 std::string to_string();
181 template <
typename T>
182 TypeInfo default_type();
186 #include "template_spec/document.hpp"
187 #include "template_spec/floats.hpp"
188 #include "template_spec/strings.hpp"
189 #include "template_spec/ints.hpp"
190 #include "template_spec/bools.hpp"
191 #include "template_spec/vectors.hpp"
192 #include "template_spec/chararrs.hpp"
193 #include "template_spec/voids.hpp"
194 #include "template_spec/pairs.hpp"
195 #include "template_spec/jsscope.hpp"
196 #include "template_spec/binary.hpp"
Element(const unsigned char *data, const TypeInfo &type)
decoding constructor
Definition: element.h:56
void encode(std::ostringstream &oss) const
encodes this object ias a bytestring
Definition: element.cpp:74
Element()
Default Constructor.
Definition: element.h:38
static void encode(std::ostringstream &oss, const Element &e)
static encoders and decoders
Definition: element.h:103
Enumeration to keep track of types for bson.
Implementation of the BSON element class.
unsigned decode(const unsigned char *data, const TypeInfo m_type)
decodes a byte string into the calling object
Definition: element.cpp:22
const T & data() const
data accessor
Definition: element.hpp:26
void data(T &t) const
data accessor
Definition: element.h:96
TypeInfo get_type() const
type accessor
Definition: element.h:79