-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vitaly
committed
May 5, 2020
1 parent
c6086af
commit e5b1814
Showing
11 changed files
with
213 additions
and
7 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,8 @@ | ||
// ============================================================================ | ||
// Copyright (c) 2017-2020, by Vitaly Grigoriev, <Vit.link420@gmail.com>. | ||
// This file is part of PdlFramework open source project under MIT License. | ||
// ============================================================================ | ||
|
||
#include "BinaryData.hpp" | ||
|
||
|
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,75 @@ | ||
// ============================================================================ | ||
// Copyright (c) 2017-2020, by Vitaly Grigoriev, <Vit.link420@gmail.com>. | ||
// This file is part of PdlFramework open source project under MIT License. | ||
// ============================================================================ | ||
|
||
#pragma once | ||
|
||
// ////////////// DATA ENDIAN TYPE //////////////// | ||
// | ||
// Little Endian Model. | ||
// |7______0|15______8|23______16|31______24| | ||
// | ||
// Big Endian Model. | ||
// |31______24|23______16|15______8|7______0| | ||
// | ||
// Reverse Big Endian Model. | ||
// |24______31|16______23|8______15|0______7| | ||
// | ||
// Endian Independent Model. | ||
// |0______7|8______15|16______23|24______31| | ||
// | ||
// | ||
// Another endian models (not supported). | ||
// | ||
// Middle Endian Big Model. (PDP-11) | ||
// |23______16|31______24|7______0|15______8| | ||
// | ||
// Middle Endian Little Model. (Honeywell 316) | ||
// |15______8|7______0|31______24|23______16| | ||
// | ||
// //////////////////////////////////////////////// | ||
|
||
|
||
namespace pdl::common::data | ||
{ | ||
|
||
/** | ||
* @defgroup BYTE_CONSTANTS Byte defines. | ||
* @brief This group of constants defines all bytes which are used in BinaryData class. | ||
* @{ | ||
*/ | ||
inline constexpr std::byte HighByte = std::byte(0xFF); | ||
inline constexpr std::byte LowByte = std::byte(0x00); | ||
|
||
inline constexpr std::byte HighPartByte = std::byte(0xF0); | ||
inline constexpr std::byte LowPartByte = std::byte(0x0F); | ||
|
||
inline constexpr std::byte HighAlternateByte = std::byte(0xAA); | ||
inline constexpr std::byte LowAlternateByte = std::byte(0x55); | ||
|
||
inline constexpr std::byte HighBitsInHalvesByte = std::byte(0xCC); | ||
inline constexpr std::byte LowBitsInHalvesByte = std::byte(0x33); | ||
|
||
inline constexpr std::byte HighBitInByte = std::byte(0x80); | ||
inline constexpr std::byte LowBitInByte = std::byte(0x01); | ||
/** @} */ | ||
|
||
/** | ||
* @enum DATA_ENDIAN_TYPE | ||
* @brief Endian type of data in BinaryData class. | ||
* | ||
* @note Default initial type of internal data in BinaryDataEngine class the same as system type. | ||
*/ | ||
enum class DATA_ENDIAN_TYPE | ||
{ | ||
DATA_BIG_ENDIAN = 0x01, // First byte of the multibyte data-type is stored first. | ||
DATA_LITTLE_ENDIAN = 0x02, // Last byte of the multibyte data-type is stored first. | ||
DATA_REVERSE_BIG_ENDIAN = 0x03, // First byte of the multibyte data-type is stored first in reverse bit sequence. | ||
DATA_SYSTEM_ENDIAN = 0xFE, // This endian type determine the system endian type and using only in constructors. | ||
DATA_NO_ENDIAN = 0xFF // This endian type means that endian value does not set. | ||
}; | ||
|
||
|
||
|
||
} // namespace data. |
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 @@ | ||
project(PdlCommon CXX) | ||
|
||
# Build PDL Common library. | ||
add_library(pdl_common STATIC) | ||
add_library(pdl::common ALIAS pdl_common) | ||
set_target_properties(pdl_common PROPERTIES OUTPUT_NAME common) | ||
|
||
target_sources(pdl_common | ||
PRIVATE | ||
BinaryData.cpp | ||
PUBLIC | ||
Types.hpp | ||
BinaryData.hpp | ||
ClassDeclaration.hpp | ||
) | ||
|
||
add_subdirectory(tests) |
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,20 @@ | ||
#pragma once | ||
|
||
|
||
namespace pdl::common | ||
{ | ||
|
||
template <typename Type> | ||
class ClassDeclaration | ||
{ | ||
public: | ||
using Ref = Type &; | ||
using CRef = const Type &; | ||
using Ptr = Type *; | ||
using CPtr = const Type *; | ||
|
||
ClassDeclaration() = default; | ||
virtual ~ClassDeclaration() = default; | ||
}; | ||
|
||
} // namespace common. |
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,13 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
|
||
namespace pdl::common | ||
{ | ||
|
||
using Type = std::string; | ||
using TypeRef = std::string_view; | ||
|
||
} // namespace common. |
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,5 @@ | ||
pdl_test_create(binary_data) | ||
|
||
pdl_test_add_source(binary_data dummy.cpp) | ||
|
||
pdl_test_register(binary_data) |
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,7 @@ | ||
#include <gtest/gtest.h> | ||
|
||
|
||
TEST(pdl_binary_data, test_test) | ||
{ | ||
ASSERT_EQ(1 ,1); | ||
} |
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 @@ | ||
add_subdirectory(unit_tests) |
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,49 @@ | ||
project(PdlUnitTest CXX) | ||
|
||
macro(pdl_test_init) | ||
|
||
enable_testing() | ||
include(GoogleTest) | ||
|
||
endmacro() | ||
|
||
macro(pdl_test_create _name) | ||
|
||
add_executable(${_name}_test) | ||
target_link_libraries(${_name}_test | ||
PRIVATE | ||
gtest | ||
gtest_main | ||
) | ||
|
||
endmacro() | ||
|
||
macro(pdl_test_add_dependency _name _lib) | ||
|
||
target_link_libraries(${_name}_test | ||
PRIVATE | ||
${_lib} | ||
) | ||
|
||
endmacro() | ||
|
||
macro(pdl_test_add_source _name) | ||
|
||
target_sources(${_name}_test | ||
PRIVATE | ||
${ARGN} | ||
) | ||
|
||
endmacro() | ||
|
||
macro(pdl_test_register _name) | ||
|
||
gtest_discover_tests(${_name}_test | ||
EXTRA_ARGS | ||
--gtest_shuffle | ||
--gtest_repeat=5 | ||
--gtest_random_seed=0 | ||
--gtest_output=xml:${PROJECT_BINARY_DIR}/reports/ | ||
) | ||
|
||
endmacro() |