CBMC: /home/runner/work/cbmc/cbmc/src/util/dstring.h Source File

1

2

3

4

5

6

7

8

11

12#ifndef CPROVER_UTIL_DSTRING_H

13#define CPROVER_UTIL_DSTRING_H

14

15#include <iosfwd>

16#include <string>

17

20

21template <typename T>

23

38{

39public:

40

41 #ifdef __GNUC__

42 constexpr

43 #endif

47

48

49 #ifdef __GNUC__

50 constexpr

51 #endif

56

57 #if 0

58

59

60 constexpr operator int() const { return no; }

61 #endif

62

63

64

68

69

70

74

76

79#ifdef __GNUC__

80 constexpr

81#endif

83 : no(other.no)

84 {

85 }

86

87

88

90 {

91 return no==0;

92 }

93

96 {

97 for(const char *t = c_str(); *s != 0; s++, t++)

98 if(*t != *s)

99 return false;

100

101 return true;

102 }

103

106 {

107 return as_string().compare(0, prefix.size(), prefix) == 0;

108 }

109

114

115

120

125

126

127

129

130

131

134

137

138

139

142

149

151 {

152 if(no==b.no)

153 return 0;

154 return as_string().compare(b.as_string());

155 }

156

157

158

161

163 { unsigned t=no; no=b.no; b.no=t; }

164

166 { no=b.no; return *this; }

167

171 {

172 no = other.no;

173 return *this;

174 }

175

176

177

178 std::ostream &operator<<(std::ostream &out) const;

179

180

181

183 {

184 return no;

185 }

186

188 {

189 return no;

190 }

191

192

193 std::string::const_iterator begin() const

194 {

196 }

197

198 std::string::const_iterator end() const

199 {

201 }

202

203private:

204 #ifdef __GNUC__

205 constexpr

206 #endif

210

212

213

216};

217

218

221

222

227

229{

230 return s.hash();

231}

232

234{

235 return a.operator<<(out);

236}

237

238

239namespace std

240{

242template <>

250}

251

252template <>

260

262

265template <typename T>

266static inline

267 typename std::enable_if<std::is_integral<T>::value, dstringt>::type

269{

272 else

273 return std::to_string(value);

274}

275

276#endif

ait supplies three of the four components needed: an abstract interpreter (in this case handling func...

dstringt has one field, an unsigned integer no which is an index into a static table of strings.

bool operator!=(const char *b) const

const std::string & as_string() const

bool operator<(const dstringt &b) const

dstringt(const std::string &s)

bool starts_with(const char *s) const

equivalent of as_string().starts_with(s)

bool operator!=(const std::string &b) const

bool starts_with(const std::string &prefix) const

equivalent of as_string().starts_with(s)

dstringt(const dstringt &)=default

bool operator<(const std::string &b) const

dstringt & operator=(const dstringt &b)

bool operator<=(const std::string &b) const

static dstringt make_from_table_index(unsigned no)

bool operator==(const char *b) const

bool operator!=(const dstringt &b) const

int compare(const dstringt &b) const

std::string::const_iterator end() const

std::ostream & operator<<(std::ostream &out) const

const char * c_str() const

bool operator==(const dstringt &b) const

std::string::const_iterator begin() const

dstringt(dstringt &&other)

Move constructor.

char operator[](size_t i) const

bool operator==(const std::string &b) const

bool operator>=(const std::string &b) const

bool operator>(const std::string &b) const

dstringt & operator=(dstringt &&other)

Move assignment.

const std::string & get_string(size_t no) const

size_t hash_string(const dstringt &s)

dstringt get_dstring_number(std::size_t)

const std::string & as_string(const dstringt &s)

std::ostream & operator<<(std::ostream &out, const dstringt &a)

static std::enable_if< std::is_integral< T >::value, dstringt >::type to_dstring(T value)

equivalent to dstringt(std::to_string(value)), i.e., produces a string from a number

Magic numbers used throughout the codebase.

constexpr std::size_t DSTRING_NUMBERS_MAX

std::string as_string(const ai_verifier_statust &status)

Makes a status message string from a status.

string_containert & get_string_container()

Get a reference to the global string container.

static std::string diagnostics_as_string(const dstringt &dstring)

Helper to give us some diagnostic in a usable form on assertion failure.

size_t operator()(const dstringt &s) const

size_t operator()(const dstringt &dstring) const