You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by GitBox <gi...@apache.org> on 2018/06/26 00:22:18 UTC

[GitHub] nwangtw commented on a change in pull request #2938: add integration topology test

nwangtw commented on a change in pull request #2938: add integration topology test
URL: https://github.com/apache/incubator-heron/pull/2938#discussion_r197980508
 
 

 ##########
 File path: heron/common/src/cpp/basics/strutils.cpp
 ##########
 @@ -44,3 +44,38 @@ StrUtils::split(
 
   return tokens;
 }
+
+std::vector<char> StrUtils::encode(const std::vector<char>& _input) {
+  std::vector<char> output;
+  char const hex_chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
+      'C', 'D', 'E', 'F' };
+  for (int i = 0; i < _input.size(); ++i) {
+      char const byte = _input[i];
+      output.push_back(hex_chars[(byte & 0xF0) >> 4]);
+      output.push_back(hex_chars[(byte & 0x0F) >> 0]);
+  }
+  return output;
+}
+
+std::vector<char> StrUtils::decode(const std::vector<char>& _input) {
+  std::vector<char> output;
+  int i = 0;
+  while (i < _input.size()) {
+    char chr_1 = _input[i];
+    if (chr_1 <= 57) {
 
 Review comment:
   Give 57, 48 and 55 const variables to be more readable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services