CIRCT  20.0.0git
Common.cpp
Go to the documentation of this file.
1 //===- Common.cpp ---------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // DO NOT EDIT!
10 // This file is distributed as part of an ESI package. The source for this file
11 // should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp/).
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "esi/Common.h"
16 
17 #include <iostream>
18 #include <sstream>
19 
20 using namespace esi;
21 
22 std::string MessageData::toHex() const {
23  std::ostringstream ss;
24  ss << std::hex;
25  for (size_t i = 0, e = data.size(); i != e; ++i) {
26  // Add spaces every 8 bytes.
27  if (i % 8 == 0 && i != 0)
28  ss << ' ';
29  // Add an extra space every 64 bytes.
30  if (i % 64 == 0 && i != 0)
31  ss << ' ';
32  ss << static_cast<unsigned>(data[i]);
33  }
34  return ss.str();
35 }
36 
37 std::string esi::toHex(uint32_t val) {
38  std::ostringstream ss;
39  ss << std::hex << val;
40  return ss.str();
41 }
std::string toHex() const
Convert the data to a hex string.
Definition: Common.cpp:22
std::vector< uint8_t > data
Definition: Common.h:137
Definition: esi.py:1
std::string toHex(uint32_t val)
Definition: Common.cpp:37