-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIonBool.cpp
38 lines (30 loc) · 923 Bytes
/
IonBool.cpp
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
/* Copyright (C) Siqi.Wu - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Written by Siqi.Wu <[email protected]>, July 2021
*/
#include "IonBool.h"
#include "IonWriter.h"
#include "ionc/ion.h"
#include <cstdlib>
#include <algorithm>
#ifndef ION_OK
#define ION_OK(x) if (x) { printf("In %s, line %d, %s Error: %s\n", __FUNCTION__, __LINE__, __func__, ion_error_to_str(x)); }
#endif
Ion::Bool::Bool(Ion::Reader &reader) : Ion::ScalarValue(reader) {
iERR err = ion_reader_read_bool(reader.reader, &value);
ION_OK(err)
type = Ion::Types::BOOL;
}
void Ion::Bool::getBytes() {
bytes.clear();
if (isNull) {
bytes.push_back(type.binaryTypeId << 4 | 0x0f);
} else {
Ion::Writer writer(true);
writer.writeBoolean(*this);
bytes = writer.getBytes();
}
}
Ion::Bool::Bool(bool value) {
this->value = value;
}