mirror of
https://github.com/Z3Prover/z3
synced 2025-06-13 17:36:15 +00:00
updated C++ API for escaped and unescaped strings #5615
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
05e7ed9637
commit
f05ac8a429
5 changed files with 18 additions and 14 deletions
|
@ -187,10 +187,9 @@ extern "C" {
|
|||
svector<char> buff;
|
||||
for (unsigned i = 0; i < str.length(); ++i) {
|
||||
unsigned ch = str[i];
|
||||
if (ch <= 32 || ch >= 127) {
|
||||
if (ch <= 32 || ch >= 127 || (ch == '\\' && i + 1 < str.length() && str[i+1] == 'u')) {
|
||||
buff.reset();
|
||||
buffer.push_back('\\');
|
||||
// buffer.push_back('\\'); // possibly replace by native non-escaped version?
|
||||
buffer.push_back('u');
|
||||
buffer.push_back('{');
|
||||
while (ch > 0) {
|
||||
|
|
|
@ -1100,23 +1100,24 @@ namespace z3 {
|
|||
bool is_string_value() const { return Z3_is_string(ctx(), m_ast); }
|
||||
|
||||
/**
|
||||
\brief for a string value expression return an escaped or unescaped string value.
|
||||
\brief for a string value expression return an escaped string value.
|
||||
\pre expression is for a string value.
|
||||
*/
|
||||
|
||||
std::string get_escaped_string() const {
|
||||
std::string get_string() const {
|
||||
assert(is_string_value());
|
||||
char const* s = Z3_get_string(ctx(), m_ast);
|
||||
check_error();
|
||||
return std::string(s);
|
||||
}
|
||||
|
||||
std::string get_string() const {
|
||||
std::vector<unsigned> get_wstring() const {
|
||||
assert(is_string_value());
|
||||
unsigned n;
|
||||
char const* s = Z3_get_lstring(ctx(), m_ast, &n);
|
||||
check_error();
|
||||
return std::string(s, n);
|
||||
unsigned n = Z3_get_string_length(ctx(), m_ast);
|
||||
std::vector<unsigned> buffer;
|
||||
buffer.resize(n);
|
||||
Z3_get_string_contents(ctx(), m_ast, n, buffer.data());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue