Subject | Hash | Author | Date (UTC) |
---|---|---|---|
second initial commit | fb7a7e999477c84f10b3d618f6b00347fd0a9ca7 | Your Name | 2019-11-23 01:38:14 |
initial commit | 3dc064f64d245d1dddcbdf8493b0be0a321cb65d | Your Name | 2019-11-22 20:10:24 |
File | Lines added | Lines deleted |
---|---|---|
.gitignore | 19 | 0 |
CMakeLists.txt | 3 | 0 |
include/jrf/image.h | 3 | 3 |
include/jrf/indices.h | 1 | 1 |
include/jrf/model.h | 3 | 3 |
include/jrf/vertices.h | 2 | 2 |
src/result.cpp | 63 | 0 |
File .gitignore added (mode: 100755) (index 0000000..8b21f22) | |||
1 | #qt creator | ||
2 | *.user | ||
3 | |||
4 | #spacemacs | ||
5 | .projectile | ||
6 | |||
7 | #atom | ||
8 | .atom-dbg.cson | ||
9 | CMakeSettings.json | ||
10 | |||
11 | #linux | ||
12 | *.directory | ||
13 | .* | ||
14 | |||
15 | #build | ||
16 | /build/* | ||
17 | |||
18 | #doxygen | ||
19 | /doc/* |
File CMakeLists.txt changed (mode: 100644) (index bbc5a71..0facd2c) | |||
1 | 1 | cmake_minimum_required(VERSION 3.5) | cmake_minimum_required(VERSION 3.5) |
2 | 2 | ||
3 | 3 | set(JRF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE) | set(JRF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE) |
4 | |||
5 | add_library(JRF STATIC src/result.cpp) | ||
6 | target_include_directories(JRF PUBLIC include) |
File include/jrf/image.h changed (mode: 100644) (index 012868e..1bc4c7c) | |||
... | ... | namespace jrf | |
24 | 24 | return width == other.width && height == other.height; | return width == other.width && height == other.height; |
25 | 25 | } | } |
26 | 26 | }; | }; |
27 | static_assert (sizeof (Extent) == 8); // Important for read & write file | ||
27 | static_assert (sizeof (Extent) == 8, "Important for read & write file"); | ||
28 | 28 | ||
29 | 29 | enum Format | enum Format |
30 | 30 | { | { |
... | ... | namespace jrf | |
32 | 32 | B8G8R8A8_SRGB = 50, | B8G8R8A8_SRGB = 50, |
33 | 33 | R8G8B8A8_SRGB = 152 | R8G8B8A8_SRGB = 152 |
34 | 34 | }; | }; |
35 | static_assert (sizeof(Format) == 4); // Important for read & write file | ||
35 | static_assert (sizeof(Format) == 4, "Important for read & write file"); | ||
36 | 36 | ||
37 | 37 | [[nodiscard]] inline bool init(Extent extent_, Format format_) | [[nodiscard]] inline bool init(Extent extent_, Format format_) |
38 | 38 | { | { |
... | ... | namespace jrf | |
84 | 84 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
85 | 85 | if (p_mediator->write(&format, sizeof(format)) != sizeof(format)) | if (p_mediator->write(&format, sizeof(format)) != sizeof(format)) |
86 | 86 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
87 | if (p_mediator->write(p_pixels, size) != size) | ||
87 | if (p_mediator->write(p_pixels, size) != int64_t(size)) | ||
88 | 88 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
89 | 89 | ||
90 | 90 | return Result::SUCCESS; | return Result::SUCCESS; |
File include/jrf/indices.h changed (mode: 100644) (index 7e7aa45..dd36734) | |||
... | ... | namespace jrf | |
115 | 115 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
116 | 116 | ||
117 | 117 | for (uint32_t i = 0; i < array_count; ++i) | for (uint32_t i = 0; i < array_count; ++i) |
118 | if (p_mediator->write(p_ind[i].p_data, p_ind[i].size) != p_ind[i].size) | ||
118 | if (p_mediator->write(p_ind[i].p_data, p_ind[i].size) != int64_t(p_ind[i].size)) | ||
119 | 119 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
120 | 120 | ||
121 | 121 | return Result::SUCCESS; | return Result::SUCCESS; |
File include/jrf/model.h changed (mode: 100644) (index b5dae63..a3634a8) | |||
... | ... | namespace jrf | |
155 | 155 | } break; | } break; |
156 | 156 | case ResourceMode::PATH: | case ResourceMode::PATH: |
157 | 157 | { | { |
158 | if (p_mediator->write(&u_vert.path, u_vert.path.size()) != u_vert.path.count()) | ||
158 | if (p_mediator->write(&u_vert.path, u_vert.path.size()) != int64_t(u_vert.path.count())) | ||
159 | 159 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
160 | 160 | } | } |
161 | 161 | } | } |
... | ... | namespace jrf | |
170 | 170 | } break; | } break; |
171 | 171 | case ResourceMode::PATH: | case ResourceMode::PATH: |
172 | 172 | { | { |
173 | if (p_mediator->write(&u_ind.path, u_ind.path.size()) != u_ind.path.size()) | ||
173 | if (p_mediator->write(&u_ind.path, u_ind.path.size()) != int64_t(u_ind.path.size())) | ||
174 | 174 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
175 | 175 | } | } |
176 | 176 | } | } |
... | ... | namespace jrf | |
184 | 184 | } break; | } break; |
185 | 185 | case ResourceMode::PATH: | case ResourceMode::PATH: |
186 | 186 | { | { |
187 | if (p_mediator->write(&u_image.path, u_image.path.size()) != u_image.path.size()) | ||
187 | if (p_mediator->write(&u_image.path, u_image.path.size()) != int64_t(u_image.path.size())) | ||
188 | 188 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
189 | 189 | } break; | } break; |
190 | 190 | default: break; | default: break; |
File include/jrf/vertices.h changed (mode: 100644) (index d8aaa3d..b62b48c) | |||
... | ... | namespace jrf | |
86 | 86 | { | { |
87 | 87 | if (p_mediator->write(&attr_count, sizeof(attr_count)) != sizeof (attr_count)) | if (p_mediator->write(&attr_count, sizeof(attr_count)) != sizeof (attr_count)) |
88 | 88 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
89 | if (p_mediator->write(p_attributes, sizeof (Attribute) * attr_count) != sizeof(Attribute)) | ||
89 | if (p_mediator->write(p_attributes, sizeof (Attribute) * attr_count) != sizeof(Attribute) * attr_count) | ||
90 | 90 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
91 | 91 | if (p_mediator->write(&vec_size, sizeof (vec_size)) != sizeof(vec_size)) | if (p_mediator->write(&vec_size, sizeof (vec_size)) != sizeof(vec_size)) |
92 | 92 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
... | ... | namespace jrf | |
94 | 94 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
95 | 95 | if (p_mediator->write(&vecs_size, sizeof (vecs_size)) != sizeof(vecs_size)) | if (p_mediator->write(&vecs_size, sizeof (vecs_size)) != sizeof(vecs_size)) |
96 | 96 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
97 | if (p_mediator->write(p_vecs, vecs_size) != vecs_size) | ||
97 | if (p_mediator->write(p_vecs, vecs_size) != int64_t(vecs_size)) | ||
98 | 98 | return Result::MEDIATOR_ERROR; | return Result::MEDIATOR_ERROR; |
99 | 99 | ||
100 | 100 | return Result::SUCCESS; | return Result::SUCCESS; |
File src/result.cpp added (mode: 100644) (index 0000000..164465e) | |||
1 | |||
2 | #include <jrf/result.h> | ||
3 | |||
4 | const char* jrf::to_str(jrf::Result result) | ||
5 | { | ||
6 | #define STR(x) case Result::x: return #x; | ||
7 | switch (result) | ||
8 | { | ||
9 | STR(SUCCESS) | ||
10 | STR(SRC_MTIME_LESS_THAN_JRF) | ||
11 | |||
12 | //parse | ||
13 | STR(TOO_MANY_ARGUMENTS) | ||
14 | STR(MISSING_ARGUMENTS) | ||
15 | STR(EXPECTED_FILE_PATH) | ||
16 | STR(INCORRECT_FORMAT) | ||
17 | STR(UNKNOWN_TYPE) | ||
18 | STR(EXPECTED_PARENTHESIS_OPEN) | ||
19 | STR(EXPECTED_PARENTHESIS_CLOSE) | ||
20 | STR(EXCESS_PARENTHESIS_CLOSE) | ||
21 | STR(EXPECTED_QUOTATION_MARKS) | ||
22 | STR(EXPECTED_NAME) | ||
23 | STR(EXPECTED_ARGUMENT) | ||
24 | STR(INCOMPATIBLE_RESOURCES) | ||
25 | STR(RESOURCE_PART_DUPLICATE) | ||
26 | STR(RESOURCE_PART_MISSING) | ||
27 | STR(RESOURCE_TYPE_MISMATCH) | ||
28 | STR(FILE_WRONG_HEADER) | ||
29 | |||
30 | //file | ||
31 | STR(FILE_OPEN_ERROR) | ||
32 | STR(DIRECTORY_ERROR) | ||
33 | STR(NO_DATA_FROM_SOURCE) | ||
34 | |||
35 | //zip | ||
36 | STR(ZIP_IN_ZIP_UNSUPPORTED) | ||
37 | STR(ZIP_ERROR) | ||
38 | |||
39 | //misc | ||
40 | STR(UNKNOWN_RESOURCE_TYPE) | ||
41 | STR(MEDIATOR_ERROR) | ||
42 | STR(ALLOCATION_FAIL) | ||
43 | |||
44 | //image | ||
45 | STR(COLOR_MAP_UNSUPPORTED) | ||
46 | STR(IMAGE_DATA_TYPE_UNSUPPORTED) | ||
47 | STR(PIXEL_SIZE_UNSUPPORTED) | ||
48 | STR(TGA_RLE_UNSUPPORTED) | ||
49 | STR(IMAGE_LAYERS_EXTENT_MISMATCH) | ||
50 | STR(IMAGE_LAYERS_FORMAT_MISMATCH) | ||
51 | |||
52 | //obj file | ||
53 | STR(OBJ_FILE_UNREADABLE) | ||
54 | STR(OBJ_FACE_HAVE_MORE_THAN_4_INDICES) | ||
55 | |||
56 | //indices | ||
57 | STR(INDEX_VALUE_OVERFLOW) | ||
58 | //vertices | ||
59 | STR(ATTRIBUTE_VERTICES_COUNT_MISMATCH) | ||
60 | } | ||
61 | return "unknown error"; | ||
62 | #undef STR | ||
63 | } |