1/*******************************************************************\
3Module: Container for C-Strings
5Author: Daniel Kroening, kroening@kroening.com
7\*******************************************************************/
12#ifndef CPROVER_UTIL_DSTRING_H
13#define CPROVER_UTIL_DSTRING_H
40 // this is safe for static objects
48 // this is safe for static objects
58 // This conversion allows the use of dstrings
59 // in switch ... case statements.
60 constexpr operator int()
const {
return no; }
63 // The const char* and const std::string& constructors below are
64 // semantically equivalent to the std::string_view one (both implicitly
65 // convert to std::string_view); they are retained only so that overload
66 // resolution prefers them and avoids an extra conversion, not for any
67 // distinct behaviour.
69 // this one is not safe for static objects
70 // NOLINTNEXTLINE(runtime/explicit)
75 // this one is not safe for static objects
76 // NOLINTNEXTLINE(runtime/explicit)
81 // this one is not safe for static objects
82 // NOLINTNEXTLINE(runtime/explicit)
103 return no==0;
// string 0 is exactly the empty string
109 for(
const char *t =
c_str(); *s != 0; s++, t++)
119 return as_string().compare(0, prefix.size(), prefix) == 0;
127 // the pointer is guaranteed to be stable
138 // ordering -- not the same as lexicographical ordering
142 // comparison with same type
145{
return no==
b.no; }
// really fast equality testing
148{
return no!=
b.no; }
// really fast equality testing
150 // comparison with other types
175 {
unsigned t=
no;
no=
b.no;
b.no=t; }
178 {
no=
b.no;
return *
this; }
190 std::ostream &
operator<<(std::ostream &out)
const;
204 // iterators for the underlying string
205 std::string::const_iterator
begin()
const
210 std::string::const_iterator
end()
const
225 // the reference returned is guaranteed to be stable
230// the reference returned is guaranteed to be stable
234// NOLINTNEXTLINE(readability/identifiers)
247 return a.operator<<(out);
250// NOLINTNEXTLINE [allow specialisation within 'std']
255 struct hash<
dstringt>
// NOLINT(readability/identifiers)
279 typename std::enable_if<std::is_integral<T>::value,
dstringt>::type
285 return std::to_string(value);
288#endif // CPROVER_UTIL_DSTRING_H
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(std::string_view 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
dstringt(std::string_view s)
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