Skip to content

Document dstringt to string conversions #2779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ Within cbmc, strings are represented using \ref irep_idt, or \ref irep_namet
for keys to [named_sub](\ref irept::dt::named_sub) or
[comments](\ref irept::dt::comments). By default these are both
typedefed to \ref dstringt. For debugging purposes you can set `USE_STD_STRING`,
in which case they are both typedefed to `std::string`.
in which case they are both typedefed to `std::string`. You can also easily
convert an [irep_idt](\ref irep_idt) or [irep_namet](\ref irep_namet) to a
`std::string` using the [id2string](\ref id2string) or
[name2string](\ref name2string) function, respectively, or either of them to a
`char*` using the [c_str()](\ref dstringt::c_str) member function.

\ref dstringt stores a string as an index into a large
static table of strings. This makes it easy to compare if two
Expand All @@ -41,7 +45,7 @@ You can refer to this \ref irep_idt as `ID_type`. The other kind of line you
see is `“IREP_ID_TWO(C_source_location, #source_location)”`, which means the
\ref irep_idt for the string “#source_location” can be referred to as
`ID_C_source_location`. The “C” is for comment, meaning that it should be
stored in the ([comments](\ref irept::dt::comments). Any strings that need
stored in the [comments](\ref irept::dt::comments). Any strings that need
to be stored as [irep_idt](\ref irep_idt)s which aren't in `irep_ids.def`
are added to the end of the table when they are first encountered, and the
same index is used for all instances.
Expand Down