static WString sSwapCase(const WString& s) { WStringBuffer r; r.SetCount(s.GetCount()); for(int i = 0; i < s.GetCount(); i++) r[i] = IsUpper(s[i]) ? ToLower(s[i]) : ToUpper(s[i]); return r; }
static WString sReadLn(const wchar *p) { WStringBuffer wbuf; while(*p && *p <= ' ') p++; while(*p && !(*p == '/' && (p[1] == '/' || p[1] == '*'))) { if(*p <= ' ') { while(*++p && *p <= ' ') ; if(*p && !(*p == '/' && (p[1] == '/' || p[1] == '*'))) wbuf.Cat(' '); } else wbuf.Cat(*p++); } return wbuf; }
void Console::Append(const String& s) { if(s.IsEmpty()) return; if(console) { String t = Filter(s, sCharFilterNoCr); if(*t.Last() == '\n') t.Trim(t.GetCount() - 1); Puts(t); return; } int l, h; GetSelection(l, h); if(GetCursor() == GetLength()) l = -1; EditPos p = GetEditPos(); SetEditable(); MoveTextEnd(); WString t = Filter(s, sAppf).ToWString(); int mg = sb.GetReducedViewSize().cx / GetFont().GetAveWidth(); if(wrap_text && mg > 4) { int x = GetColumnLine(GetCursor()).x; WStringBuffer tt; const wchar *q = t; while(*q) { if(x > mg - 1) { tt.Cat('\n'); tt.Cat(" "); x = 4; } x++; if(*q == '\n') x = 0; tt.Cat(*q++); } Paste(tt); } else Paste(t); SetReadOnly(); if(l >= 0) { SetEditPos(p); SetSelection(l, h); } }
bool ODBCConnection::Fetch0() { LLOG("Fetch0 " << (void *)this << " " << (void *)session); int ret = SQLFetch(session->hstmt); if(ret == SQL_NO_DATA || !IsOk(ret)) return false; fetchrow.Clear(); double dbl; int64 n64; SQL_TIMESTAMP_STRUCT tm; SQLLEN li; for(int i = 0; i < info.GetCount(); i++) { Value v = Null; int type = info[i].type; switch(type) { case DOUBLE_V: if(!IsOk(SQLGetData(session->hstmt, i + 1, SQL_C_DOUBLE, &dbl, sizeof(dbl), &li))) break; if(li != SQL_NULL_DATA) v = dbl; break; case INT64_V: if(!IsOk(SQLGetData(session->hstmt, i + 1, SQL_C_SBIGINT, &n64, sizeof(n64), &li))) break; if(li != SQL_NULL_DATA) v = n64; break; case TIME_V: case DATE_V: if(!IsOk(SQLGetData(session->hstmt, i + 1, SQL_C_TYPE_TIMESTAMP, &tm, sizeof(tm), &li))) break; if(li != SQL_NULL_DATA) { Time m; m.year = tm.year; m.month = (byte)tm.month; m.day = (byte)tm.day; m.hour = (byte)tm.hour; m.minute = (byte)tm.minute; m.second = (byte)tm.second; if(type == DATE_V) v = (Date)m; else v = m; } break; default: int ct = string_type[i]; if(!IsOk(SQLGetData(session->hstmt, i + 1, ct, &tm, 0, &li))) break; if(li != SQL_NULL_DATA && li >= 0) if(ct == SQL_C_WCHAR) { WStringBuffer sb; sb.SetLength(li / 2); if(!IsOk(SQLGetData(session->hstmt, i + 1, ct, ~sb, li + 2, &li))) break; v = WString(sb); } else { StringBuffer sb; sb.SetLength(li); if(!IsOk(SQLGetData(session->hstmt, i + 1, ct, ~sb, li + 1, &li))) break; v = String(sb); } break; } fetchrow.Add(v); } return ret != SQL_NO_DATA && IsOk(ret); }