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

hexarray & hexdump #12241

Merged
merged 7 commits into from
Oct 8, 2023
Merged

hexarray & hexdump #12241

merged 7 commits into from
Oct 8, 2023

Conversation

maloel
Copy link
Collaborator

@maloel maloel commented Oct 1, 2023

JSON byte-arrays get passed as an array of bytes:

  • Too long
  • Hard to read
  • No range checks (elements can be > 255)
  • No type checks (an array of floats can be converted to an array of bytes, no problem)
  • Not really encapsulated in any abstraction, so hard to refactor or change, if we wish to

This implements a hexarray object that can be used to communicate byte-arrays in a standard way ("0102abcd"). Compatible with regular JSON array-of-bytes representation ([1,2,3]) (with type/range checks). With unit-tests. Added docs.

Tracked on [LRS-899]

maloel added 3 commits October 1, 2023 10:00
(cherry picked from commit 8f01c760d7e9af50b5e1fb8acd54fd197800c9e5)
@maloel maloel requested a review from SamerKhshiboun October 1, 2023 07:03
namespace string {


/*static*/ std::string hexarray::to_string( bytes const & bytearray )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this "static" ? should be commented out or not ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put these there on purpose, since it's not always clear that you're looking at a static function member body. I find it helps me understand where I am.

}


/*static*/ std::ostream & hexarray::to_stream( std::ostream & os, bytes const & bytearray )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@maloel maloel merged commit e360c4b into IntelRealSense:development Oct 8, 2023
16 checks passed
@maloel maloel deleted the hexdump branch October 8, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants