Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2024 Muhammad Nawaz | ||
3 | * Licensed under the MIT License. See LICENSE file for more information. | ||
4 | */ | ||
5 | // [ END OF LICENSE c6bd0f49d040fca8d8a9cb05868e66aa63f0e2e0 ] | ||
6 | |||
7 | #include "deserializers/array_deserializer.hpp" | ||
8 | |||
9 | 295 | ArrayDeserializer::ArrayDeserializer(const std::string& param_name, char start, bool skip_name, | |
10 | PrimitiveType items_type, char separator, bool has_running_name, | ||
11 | 295 | bool has_20_separator) | |
12 | : BaseDeserializer(param_name, start, skip_name) | ||
13 | 295 | , items_type_(items_type) | |
14 | 295 | , separator_(separator) | |
15 | 295 | , has_running_name_(has_running_name) | |
16 | 295 | , has_20_separator_(has_20_separator) | |
17 | { | ||
18 | 295 | } | |
19 | |||
20 | 105 | std::string ArrayDeserializer::Deserialize(const char* beg, const char* const end) | |
21 | { | ||
22 | 105 | const char* cursor = beg; | |
23 | |||
24 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | CheckNSkipStart(cursor); |
25 | |||
26 |
4/4✓ Branch 0 taken 44 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 8 times.
|
105 | if (skip_name_ && !has_running_name_) { |
27 |
1/2✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
|
36 | CheckNSkipName(cursor, end); |
28 |
1/2✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
|
36 | CheckNSkipChar(cursor, end, '='); |
29 | } | ||
30 | |||
31 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | CheckData(cursor, end); |
32 | |||
33 | 105 | std::string ret; | |
34 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | ret.reserve(static_cast<size_t>(end - beg + 64)); |
35 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | ret.push_back('['); |
36 | |||
37 |
4/5✓ Branch 0 taken 31 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
105 | switch (items_type_) { |
38 | 31 | case PrimitiveType::BOOLEAN: | |
39 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 2 taken 5 times.
|
31 | DeserializeBooleanArray(cursor, end, ret); |
40 | 26 | break; | |
41 | |||
42 | 30 | case PrimitiveType::INTEGER: | |
43 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 2 taken 11 times.
|
30 | DeserializeIntegerArray(cursor, end, ret); |
44 | 19 | break; | |
45 | |||
46 | 21 | case PrimitiveType::NUMBER: | |
47 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 2 taken 5 times.
|
21 | DeserializeNumberArray(cursor, end, ret); |
48 | 16 | break; | |
49 | |||
50 | 23 | case PrimitiveType::STRING: | |
51 |
2/2✓ Branch 1 taken 22 times.
✓ Branch 2 taken 1 times.
|
23 | DeserializeStringArray(cursor, end, ret); |
52 | 22 | break; | |
53 | |||
54 | ✗ | default: | |
55 | ✗ | break; | |
56 | } | ||
57 | |||
58 |
1/2✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
|
83 | CheckEnd(cursor, end); |
59 | |||
60 |
1/2✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
|
83 | if (',' == ret.back()) { |
61 | 83 | ret.back() = ']'; | |
62 | } else { | ||
63 | ✗ | ret.push_back(']'); | |
64 | } | ||
65 | |||
66 | 166 | return ret; | |
67 | 22 | } | |
68 |