Skip to content

hexarray & hexdump - #12241

Merged
maloel merged 7 commits into
realsenseai:developmentfrom
maloel:hexdump
Oct 8, 2023
Merged

hexarray & hexdump#12241
maloel merged 7 commits into
realsenseai:developmentfrom
maloel:hexdump

Conversation

@maloel

@maloel maloel commented Oct 1, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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 realsenseai:development Oct 8, 2023
@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