forked from argandas/ardubson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ardubsonElement.h
56 lines (49 loc) · 1.26 KB
/
ardubsonElement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
ardubson.h - Library for the BSON (Binary-JSON) format.
Created by Hugo Arganda (argandas), April 6, 2016.
Released into the public domain.
*/
/*
Check BSON specification at:
http://bsonspec.org/spec.html
*/
#ifndef ardubson_element_h
#define ardubson_element_h
#include "Arduino.h"
#include "ardubsonTypes.h"
#include "ardubsonConfig.h"
class BSONElement
{
public:
BSONElement(void);
BSONElement& Fill(char* data, int len);
// Methods
char* rawData();
int len();
/* Create new element */
BSONElement& Key(const char *key);
void Value(const char *value);
void Value(const char *value, int size);
void Value(int16_t value);
void Value(int32_t value);
void Value(int64_t value);
void Value(bool value);
// Get attibutes
char getType(void);
char* getKey(void);
// Assertions
bool isBool(void);
bool isInt(void);
bool isString(void);
// Get values
char* getString(void);
int getInt(void);
bool getBool(void);
private:
bool put(const char* source, int size);
char* e_type;
char* e_name;
char e_data[BSON_ELM_SIZE];
int _len;
};
#endif