mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 08:35:31 +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); }
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace smt {
|
|||
void reset() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
void* m_user_context;
|
||||
void* m_user_context = nullptr;
|
||||
solver::push_eh_t m_push_eh;
|
||||
solver::pop_eh_t m_pop_eh;
|
||||
solver::fresh_eh_t m_fresh_eh;
|
||||
|
@ -56,13 +56,13 @@ namespace smt {
|
|||
solver::fixed_eh_t m_fixed_eh;
|
||||
solver::eq_eh_t m_eq_eh;
|
||||
solver::eq_eh_t m_diseq_eh;
|
||||
solver::context_obj* m_api_context { nullptr };
|
||||
unsigned m_qhead { 0 };
|
||||
solver::context_obj* m_api_context = nullptr;
|
||||
unsigned m_qhead = 0;
|
||||
uint_set m_fixed;
|
||||
vector<prop_info> m_prop;
|
||||
unsigned_vector m_prop_lim;
|
||||
vector<literal_vector> m_id2justification;
|
||||
unsigned m_num_scopes { 0 };
|
||||
unsigned m_num_scopes = 0;
|
||||
literal_vector m_lits;
|
||||
enode_pair_vector m_eqs;
|
||||
stats m_stats;
|
||||
|
|
|
@ -51,7 +51,7 @@ class solver : public check_sat_result {
|
|||
params_ref m_params;
|
||||
symbol m_cancel_backup_file;
|
||||
public:
|
||||
solver() {}
|
||||
solver() {}
|
||||
~solver() override {}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue