-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #13293 from Swiftb0y/chore/update-rekordbox-kaitai…
…-definitions chore: update rekordbox kaitai definitions
- Loading branch information
Showing
18 changed files
with
2,817 additions
and
1,371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
cmake_minimum_required (VERSION 3.11) | ||
project (kaitai_struct_cpp_stl_runtime CXX) | ||
enable_testing() | ||
|
||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
option(BUILD_TESTS "Build tests" ON) | ||
|
||
set (CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
find_package(ZLIB) | ||
find_package(Iconv) | ||
|
||
set (HEADERS | ||
kaitai/kaitaistream.h | ||
kaitai/kaitaistruct.h | ||
kaitai/exceptions.h | ||
) | ||
|
||
set (SOURCES | ||
kaitai/kaitaistream.cpp | ||
) | ||
|
||
set(STRING_ENCODING_TYPE "ICONV" CACHE STRING "Set the way strings have to be encoded (ICONV|WIN32API|NONE|...)") | ||
|
||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
||
add_library (${PROJECT_NAME} ${HEADERS} ${SOURCES}) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY PUBLIC_HEADER ${HEADERS}) | ||
target_include_directories(${PROJECT_NAME} INTERFACE ${PROJECT_SOURCE_DIR}) | ||
|
||
if (ZLIB_FOUND) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_ZLIB) | ||
endif() | ||
|
||
if(Iconv_FOUND) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE Iconv::Iconv) | ||
endif() | ||
|
||
include(Common.cmake) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
PUBLIC_HEADER DESTINATION include/kaitai | ||
) | ||
|
||
# Add the tests | ||
if(BUILD_TESTS) | ||
add_subdirectory(tests) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
if (STRING_ENCODING_TYPE STREQUAL "ICONV") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_ICONV) | ||
elseif (STRING_ENCODING_TYPE STREQUAL "WIN32API") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_WIN32API) | ||
elseif (STRING_ENCODING_TYPE STREQUAL "NONE") | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_NONE) | ||
else() | ||
# User action requested | ||
endif() | ||
|
||
# Maximum warnings emission, treat all warnings as errors | ||
# | ||
# This method was taken from https://www.pragmaticlinux.com/2022/07/enable-compiler-warnings-with-cmake/ | ||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX> | ||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
Copyright 2016-2019 Kaitai Project: MIT license | ||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
Copyright (c) 2016-2022 Kaitai Project | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
#ifndef KAITAI_EXCEPTIONS_H | ||
#define KAITAI_EXCEPTIONS_H | ||
|
||
#include <kaitai/kaitaistream.h> | ||
|
||
#include <string> | ||
#include <stdexcept> | ||
|
||
// We need to use "noexcept" in virtual destructor of our exceptions | ||
// subclasses. Different compilers have different ideas on how to | ||
// achieve that: C++98 compilers prefer `throw()`, C++11 and later | ||
// use `noexcept`. We define KS_NOEXCEPT macro for that. | ||
|
||
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) | ||
#define KS_NOEXCEPT noexcept | ||
#else | ||
#define KS_NOEXCEPT throw() | ||
#endif | ||
|
||
namespace kaitai { | ||
|
||
/** | ||
* Common ancestor for all errors related to `bytes_to_str` operation. Also used | ||
* to signal misc non-specific `bytes_to_str` failures. | ||
*/ | ||
class bytes_to_str_error: public std::runtime_error { | ||
public: | ||
bytes_to_str_error(const std::string what): | ||
std::runtime_error(std::string("bytes_to_str error: ") + what) {} | ||
|
||
virtual ~bytes_to_str_error() KS_NOEXCEPT {}; | ||
}; | ||
|
||
/** | ||
* Exception to signal that `bytes_to_str` operation was requested to use some encoding | ||
* that is not available in given runtime environment. | ||
*/ | ||
class unknown_encoding: public bytes_to_str_error { | ||
public: | ||
unknown_encoding(const std::string enc_name): | ||
bytes_to_str_error(std::string("unknown encoding: `") + enc_name + std::string("`")) {} | ||
|
||
virtual ~unknown_encoding() KS_NOEXCEPT {}; | ||
}; | ||
|
||
/** | ||
* Exception to signal that `bytes_to_str` operation failed to decode given byte sequence. | ||
*/ | ||
class illegal_seq_in_encoding: public bytes_to_str_error { | ||
public: | ||
illegal_seq_in_encoding(const std::string what): | ||
bytes_to_str_error("illegal sequence: " + what) {} | ||
|
||
virtual ~illegal_seq_in_encoding() KS_NOEXCEPT {}; | ||
}; | ||
|
||
/** | ||
* Common ancestor for all error originating from Kaitai Struct usage. | ||
* Stores KSY source path, pointing to an element supposedly guilty of | ||
* an error. | ||
*/ | ||
class kstruct_error: public std::runtime_error { | ||
public: | ||
kstruct_error(const std::string what, const std::string src_path): | ||
std::runtime_error(src_path + ": " + what), | ||
m_src_path(src_path) | ||
{ | ||
} | ||
|
||
virtual ~kstruct_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const std::string m_src_path; | ||
}; | ||
|
||
/** | ||
* Error that occurs when default endianness should be decided with | ||
* a switch, but nothing matches (although using endianness expression | ||
* implies that there should be some positive result). | ||
*/ | ||
class undecided_endianness_error: public kstruct_error { | ||
public: | ||
undecided_endianness_error(const std::string src_path): | ||
kstruct_error("unable to decide on endianness for a type", src_path) | ||
{ | ||
} | ||
|
||
virtual ~undecided_endianness_error() KS_NOEXCEPT {}; | ||
}; | ||
|
||
/** | ||
* Common ancestor for all validation failures. Stores pointer to | ||
* KaitaiStream IO object which was involved in an error. | ||
*/ | ||
class validation_failed_error: public kstruct_error { | ||
public: | ||
validation_failed_error(const std::string what, kstream* io, const std::string src_path): | ||
kstruct_error("at pos " + kstream::to_string(io->pos()) + ": validation failed: " + what, src_path), | ||
m_io(io) | ||
{ | ||
} | ||
|
||
// "at pos #{io.pos}: validation failed: #{msg}" | ||
|
||
virtual ~validation_failed_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
kstream* m_io; | ||
}; | ||
|
||
/** | ||
* Signals validation failure: we required "actual" value to be equal to | ||
* "expected", but it turned out that it's not. | ||
*/ | ||
template<typename T> | ||
class validation_not_equal_error: public validation_failed_error { | ||
public: | ||
validation_not_equal_error(const T& expected, const T& actual, kstream* io, const std::string src_path): | ||
validation_failed_error("not equal", io, src_path), | ||
m_expected(expected), | ||
m_actual(actual) | ||
{ | ||
} | ||
|
||
// "not equal, expected #{expected.inspect}, but got #{actual.inspect}" | ||
|
||
virtual ~validation_not_equal_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const T& m_expected; | ||
const T& m_actual; | ||
}; | ||
|
||
/** | ||
* Signals validation failure: we required "actual" value to be greater | ||
* than or equal to "min", but it turned out that it's not. | ||
*/ | ||
template<typename T> | ||
class validation_less_than_error: public validation_failed_error { | ||
public: | ||
validation_less_than_error(const T& min, const T& actual, kstream* io, const std::string src_path): | ||
validation_failed_error("not in range", io, src_path), | ||
m_min(min), | ||
m_actual(actual) | ||
{ | ||
} | ||
|
||
// "not in range, min #{min.inspect}, but got #{actual.inspect}" | ||
|
||
virtual ~validation_less_than_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const T& m_min; | ||
const T& m_actual; | ||
}; | ||
|
||
/** | ||
* Signals validation failure: we required "actual" value to be less | ||
* than or equal to "max", but it turned out that it's not. | ||
*/ | ||
template<typename T> | ||
class validation_greater_than_error: public validation_failed_error { | ||
public: | ||
validation_greater_than_error(const T& max, const T& actual, kstream* io, const std::string src_path): | ||
validation_failed_error("not in range", io, src_path), | ||
m_max(max), | ||
m_actual(actual) | ||
{ | ||
} | ||
|
||
// "not in range, max #{max.inspect}, but got #{actual.inspect}" | ||
|
||
virtual ~validation_greater_than_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const T& m_max; | ||
const T& m_actual; | ||
}; | ||
|
||
/** | ||
* Signals validation failure: we required "actual" value to be from | ||
* the list, but it turned out that it's not. | ||
*/ | ||
template<typename T> | ||
class validation_not_any_of_error: public validation_failed_error { | ||
public: | ||
validation_not_any_of_error(const T& actual, kstream* io, const std::string src_path): | ||
validation_failed_error("not any of the list", io, src_path), | ||
m_actual(actual) | ||
{ | ||
} | ||
|
||
// "not any of the list, got #{actual.inspect}" | ||
|
||
virtual ~validation_not_any_of_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const T& m_actual; | ||
}; | ||
|
||
/** | ||
* Signals validation failure: we required "actual" value to match | ||
* the expression, but it turned out that it doesn't. | ||
*/ | ||
template<typename T> | ||
class validation_expr_error: public validation_failed_error { | ||
public: | ||
validation_expr_error(const T& actual, kstream* io, const std::string src_path): | ||
validation_failed_error("not matching the expression", io, src_path), | ||
m_actual(actual) | ||
{ | ||
} | ||
|
||
// "not matching the expression, got #{actual.inspect}" | ||
|
||
virtual ~validation_expr_error() KS_NOEXCEPT {}; | ||
|
||
protected: | ||
const T& m_actual; | ||
}; | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.