Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clp-core: Refactor the BufferedFileReader to wrap around a ReaderInterface. #523

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
edbcc6d
first batch of change
haiqi96 Jul 26, 2024
21b4471
Remove dictionary utils
haiqi96 Jul 26, 2024
3a3c9ba
fix exception issues and make sure unit tests and clg can build
haiqi96 Jul 26, 2024
2c40e29
Linter
haiqi96 Jul 26, 2024
d503436
Fixes
haiqi96 Jul 26, 2024
1ff5ea8
Rearrange code
haiqi96 Jul 26, 2024
8a7ddc7
fix clo build
haiqi96 Jul 26, 2024
70325a9
fix
haiqi96 Jul 26, 2024
99d45a6
Fix make-dictionaries-readable
haiqi96 Jul 26, 2024
b086953
fix constructors
haiqi96 Jul 26, 2024
746834f
refactor
haiqi96 Jul 26, 2024
d2a6836
Update docstrings and comments. Also updated destructor
haiqi96 Jul 29, 2024
7d347c1
Initial change
haiqi96 Jul 28, 2024
63f0cfd
Linter fix
haiqi96 Aug 7, 2024
4a0a323
Merge branch 'main' into BufferedReaderRefactor
haiqi96 Aug 8, 2024
7192022
Factor out duplicated function
haiqi96 Aug 8, 2024
f6b6757
Add sysfile Reader
haiqi96 Aug 9, 2024
712d10b
Update BufferedFileReader to use move instead of reference
haiqi96 Aug 9, 2024
80532ea
FileDescriptor update
haiqi96 Aug 9, 2024
d30030a
Merge branch 'main' into FileReaderRefactor
haiqi96 Aug 12, 2024
4dabc96
Revert unintended changes
haiqi96 Aug 12, 2024
a8d0747
fix
haiqi96 Aug 12, 2024
ff0b9d8
Missing fix
haiqi96 Aug 12, 2024
b3f2795
Fixes
haiqi96 Aug 12, 2024
4d0d80b
Revert unintended changes
haiqi96 Aug 13, 2024
70c8342
Fix one weird issue
haiqi96 Aug 13, 2024
83ee77e
small fix
haiqi96 Aug 13, 2024
9601fa8
Merge branch 'FileReaderRefactor' into BufferedReaderRefactor
haiqi96 Aug 13, 2024
59db88b
Improvement
haiqi96 Aug 13, 2024
450632a
Merge branch 'main' into BufferedReaderRefactor
haiqi96 Aug 14, 2024
c6c8c9b
Add initial class and Unittest
haiqi96 Aug 14, 2024
d5db2a6
Small fix
haiqi96 Aug 14, 2024
39c9bb3
Add missing unit test file
haiqi96 Aug 15, 2024
8909eab
Fix clang tidy issues
haiqi96 Aug 15, 2024
c5cb603
suppress pointer warning for now
haiqi96 Aug 15, 2024
cfcd0f7
Apply suggestions from code review
haiqi96 Aug 16, 2024
948b315
fixes
haiqi96 Aug 16, 2024
ee41996
Use span to replace pointer arithmetic.
haiqi96 Aug 20, 2024
1b53cf7
Merge branch 'main' into SysFileReader
haiqi96 Aug 20, 2024
d9b4de4
Use CLP array to avoid buffer warning
haiqi96 Aug 20, 2024
707817a
Linter
haiqi96 Aug 20, 2024
2a6248c
Apply suggestions from code review
haiqi96 Aug 21, 2024
aff7a2e
Fixes
haiqi96 Aug 21, 2024
f807eea
Rename class and slight modify the comments
haiqi96 Aug 21, 2024
435e12a
small touch
haiqi96 Aug 21, 2024
1cd11b5
Merge branch 'SysFileReader' into BufferedReaderRefactor
haiqi96 Aug 21, 2024
0c99da6
missing changes in merge
haiqi96 Aug 21, 2024
4acf9b5
Merge branch 'BufferedReaderRefactor' of https://github.com/haiqi96/c…
haiqi96 Aug 22, 2024
d3e54c4
Merge branch 'main' into BufferedReaderRefactor
haiqi96 Aug 22, 2024
fd4eb36
Fixes
haiqi96 Aug 22, 2024
5c301d7
A few more fixes
haiqi96 Aug 22, 2024
ce7376b
A small change
haiqi96 Aug 22, 2024
1bbf2a4
Apply suggestions from code review
haiqi96 Sep 9, 2024
1260043
small fixes
haiqi96 Sep 9, 2024
aaa8c64
allow BufferReader to support null initialization
haiqi96 Sep 9, 2024
c147b41
A few more polishing
haiqi96 Sep 9, 2024
02b0d10
A few more polishing again
haiqi96 Sep 9, 2024
810a77b
Apply suggestions from code review
haiqi96 Sep 11, 2024
654eb35
update unit-test
haiqi96 Sep 16, 2024
c176c67
Merge branch 'BufferedReaderRefactor' of https://github.com/haiqi96/c…
haiqi96 Sep 16, 2024
c2b6333
linter
haiqi96 Sep 16, 2024
e4bbd30
Code review suggestions
haiqi96 Oct 8, 2024
7fc448a
Apply suggestions from code review
haiqi96 Oct 8, 2024
4e5d3ff
update code based on comments
haiqi96 Oct 8, 2024
676dc3c
fix
haiqi96 Oct 8, 2024
dfb1211
Update unit test
haiqi96 Oct 8, 2024
38076be
linter
haiqi96 Oct 8, 2024
a4eb75f
Remove unnecessary function
haiqi96 Oct 8, 2024
17e8cdb
Missing docstrings
haiqi96 Oct 8, 2024
8cc9e89
Other docstrings fixes
haiqi96 Oct 8, 2024
74f57bc
Merge branch 'main' into BufferedReaderRefactor
kirkrodrigues Oct 24, 2024
3d843ec
variable name refactor
haiqi96 Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions components/core/src/clp/BufferReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
#include <cstring>

namespace clp {
BufferReader::BufferReader(char const* data, size_t data_size, size_t pos) {
if (nullptr == data) {
BufferReader::BufferReader(char const* data, size_t data_size, size_t pos)
: m_internal_buf{data},
m_internal_buf_size{data_size},
m_internal_buf_pos{pos} {
if (nullptr == data && (data_size != 0 || pos != 0)) {
haiqi96 marked this conversation as resolved.
Show resolved Hide resolved
haiqi96 marked this conversation as resolved.
Show resolved Hide resolved
throw OperationFailed(ErrorCode_BadParam, __FILENAME__, __LINE__);
}
if (pos > data_size) {
throw OperationFailed(ErrorCode_BadParam, __FILENAME__, __LINE__);
}
m_internal_buf = data;
m_internal_buf_size = data_size;
m_internal_buf_pos = pos;
}

auto BufferReader::peek_buffer(char const*& buf, size_t& peek_size) const -> void {
peek_size = get_remaining_data_size();
buf = m_internal_buf + m_internal_buf_pos;
buf = 0 == peek_size ? nullptr : m_internal_buf + m_internal_buf_pos;
}

auto BufferReader::try_read_to_delimiter(
Expand Down
2 changes: 2 additions & 0 deletions components/core/src/clp/BufferReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class BufferReader : public ReaderInterface {
};

// Constructors
BufferReader() : BufferReader(nullptr, 0, 0) {}

BufferReader(char const* data, size_t data_size) : BufferReader(data, data_size, 0) {}

BufferReader(char const* data, size_t data_size, size_t pos);
Expand Down
Loading
Loading