Skip to content

Commit

Permalink
Redesign API (#3)
Browse files Browse the repository at this point in the history
* redesign library

* clean code

* fix pylint

* add methods for scalars

* fix examples

* fix pylint

* fix example

* fix clang build

* fix casting

* cpp-17

* fix clang build

* print types if they missmatch

* use real type

* force type

* update CHANGELOG
  • Loading branch information
atimin committed Jul 28, 2023
1 parent 4a21e9e commit 5e8885a
Show file tree
Hide file tree
Showing 18 changed files with 744 additions and 671 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
python/CMakeFiles
python/*.cmake
python/src/drift_bytes.egg-info
*.so
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Use `set_` prefix for setters, [PR-2](https://github.com/panda-official/DriftBytes/pull/2)
- Redesign API, [PR-3](https://github.com/panda-official/DriftBytes/pull/3)

## 0.1.0 - 2023-07-20

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set_target_properties(
${TARGET_NAME}
PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF
)
target_compile_features(${TARGET_NAME} INTERFACE cxx_std_17)

target_include_directories(
${TARGET_NAME}
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ which is suitable for non-floating point data.

#include <iostream>

using drift_bytes::Bytes;
using drift_bytes::InputBuffer;
using drift_bytes::OutputBuffer;
using drift_bytes::Variant;

int main() {
uint8_t val{42};
auto bytes = Bytes();
bytes.set_scalar(val);
auto new_val = bytes.set_scalar<uint8_t>();
Variant some_value{42};

std::cout << new_val << std::endl;
OutputBuffer buffer;
buffer.push_back(some_value);

InputBuffer input(buffer.str());
Variant new_val = input.pop();

std::cout << new_val << std::endl;
}

```

## Bulding
Expand Down
2 changes: 1 addition & 1 deletion conan/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ project(WaveletBufferTest CXX)
find_package(drift_bytes CONFIG REQUIRED)

add_executable(example src/example.cc)
target_compile_features(example PUBLIC cxx_std_20)
target_compile_features(example PUBLIC cxx_std_17)
target_link_libraries(example drift_bytes::drift_bytes)
15 changes: 10 additions & 5 deletions conan/test_package/src/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

#include <iostream>

using drift_bytes::Bytes;
using drift_bytes::InputBuffer;
using drift_bytes::OutputBuffer;
using drift_bytes::Variant;

int main() {
uint8_t val{42};
auto bytes = Bytes();
bytes.set_scalar(val);
auto new_val = bytes.scalar<uint8_t>();
Variant some_value{42};

OutputBuffer buffer;
buffer.push_back(some_value);

InputBuffer input(buffer.str());
Variant new_val = input.pop();

std::cout << new_val << std::endl;
}

0 comments on commit 5e8885a

Please sign in to comment.