-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIonNull.cpp
37 lines (30 loc) · 876 Bytes
/
IonNull.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
/* 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 "IonNull.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::Null::Null(Ion::Reader &reader) : Ion::ScalarValue(reader) {
type = Ion::Types::_NULL;
isNull = true;
}
void Ion::Null::getBytes() {
bytes.clear();
if (isNull) {
bytes.push_back(type.binaryTypeId << 4 | 0x0f);
} else {
Ion::Writer writer(true);
writer.writeNull(type);
bytes = writer.getBytes();
}
}
Ion::Null::Null() {
type = Ion::Types::_NULL;
isNull = true;
}