Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) CliToStr

 

CliToStr is a cln::cl_I conversion code snippets to convert a cln::cl_I to an std::string.

 

#include <cassert>
#include <sstream>
#include <string>
#include <cln/cln.h>

///CliToStr converts a cln::cl_I to std::string.
///From http://www.richelbilderbeek.nl/CppCliToStr.htm
const std::string CliToStr(const cln::cl_I& i)
{
  std::stringstream s;
  s << i;
  return s.str();
}

int main()
{
  const std::string s = "12345678901234567890";
  const cln::cl_I i(s.c_str());
  const std::string t = CliToStr(i);
  assert(s==t);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict