summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorTianyi Liang <tianyi-liang@uiowa.edu>2013-09-23 16:54:32 -0500
committerTianyi Liang <tianyi-liang@uiowa.edu>2013-09-27 09:25:52 -0500
commit4612dd66cee87b7d4b735b416785d539083757fa (patch)
treef8cf493cfc3a8edfe7421cfc40b02b59cdd0d395 /src/util
parentccd1ca4c32e8a3eac8b18911a7b2d32b55203707 (diff)
adds model generation for strings, and a hacked way in arith engine for models
Diffstat (limited to 'src/util')
-rw-r--r--src/util/regexp.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/util/regexp.h b/src/util/regexp.h
index debb57e4c..58f58a40f 100644
--- a/src/util/regexp.h
+++ b/src/util/regexp.h
@@ -122,13 +122,13 @@ public:
String(const std::string &s) {
for(unsigned int i=0; i<s.size(); ++i) {
- d_str.push_back( (unsigned int)s[i] );
+ d_str.push_back( convertCharToUnsignedInt(s[i]) );
}
}
String(const char* s) {
for(unsigned int i=0,len=strlen(s); i<len; ++i) {
- d_str.push_back( (unsigned int)s[i] );
+ d_str.push_back( convertCharToUnsignedInt(s[i]) );
}
}
@@ -207,7 +207,8 @@ public:
std::string toString() const {
std::string str;
for(unsigned int i=0; i<d_str.size(); ++i) {
- str += (char)d_str[i];
+ str += convertUnsignedIntToChar( d_str[i] );
+ //TODO isPrintable: ( "\\" + (convertUnsignedIntToChar( d_str[i] ) );
}
return str;
}
@@ -232,6 +233,22 @@ public:
ret_vec.insert( ret_vec.end(), itr, itr + j );
return String(ret_vec);
}
+
+public:
+ static unsigned int convertCharToUnsignedInt( char c ) {
+ int i = (int)c;
+ i = i-65;
+ return (unsigned int)(i<0 ? i+256 : i);
+ }
+ static char convertUnsignedIntToChar( unsigned int i ){
+ int ii = i+65;
+ return (char)(ii>=256 ? ii-256 : ii);
+ }
+ static bool isPrintable( unsigned int i ){
+ char c = convertUnsignedIntToChar( i );
+ return isprint( (int)c );
+ }
+
};/* class String */
namespace strings {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback