CBMC
dstring.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Container for C-Strings
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "dstring.h"
13 
14 #include <ostream> // IWYU pragma: keep
15 
16 std::ostream &dstringt::operator<<(std::ostream &out) const
17 {
18  return out << as_string();
19 }
20 
21 dstringt get_dstring_number(std::size_t value)
22 {
23  static const dstringt *const dstring_numbers = [] {
24  dstringt *array = new dstringt[DSTRING_NUMBERS_MAX + 1];
25  for(std::size_t i = 0; i <= DSTRING_NUMBERS_MAX; i++)
26  array[i] = dstringt(std::to_string(i));
27  return array;
28  }();
29 
30  return dstring_numbers[value];
31 }
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
std::ostream & operator<<(std::ostream &out) const
Definition: dstring.cpp:16
const std::string & as_string() const
Definition: dstring.h:214
dstringt get_dstring_number(std::size_t value)
Definition: dstring.cpp:21
Container for C-Strings.
constexpr std::size_t DSTRING_NUMBERS_MAX
Definition: magic.h:17
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.